JuliaSmoothOptimizers / BundleAdjustmentModels.jl

Julia repository of bundle adjustment problems
Mozilla Public License 2.0
9 stars 5 forks source link

NLSModels API #39

Open tmigot opened 3 years ago

tmigot commented 3 years ago

Thanks @AntoninKns for this great repo!

I was checking the BundleAdjustmentModel, which follows the NLSModel API, and I have a couple of comments:

dpo commented 2 years ago

@AntoninKns

AntoninKns commented 2 years ago

All issues have been fixed apart for the jprod_residual! and jtprod_residual!.

AndrewLister-STFC commented 1 year ago

I just tried to run your problems with the JSOSolvers and found I needed:

function NLPModels.jtprod_residual!(model::BundleAdjustmentModel{Float64, Vector{Float64}}, x, v, jv)
    mul!(jv, NLPModels.jac_residual(model, x)', v)
end
function NLPModels.jprod_residual!(model::BundleAdjustmentModel{Float64, Vector{Float64}}, x, v, jv)
    mul!(jv, NLPModels.jac_residual(model, x), v)
end

Not sure if you'd rather do something smarter but it's a quick workaround.

tmigot commented 1 year ago

Hi @AndrewLister-STFC ! Thank you for your interest and sorry for the delay of my response as we are understaffed at the moment.

You are right it is indeed a good workaround. I think long term we would have hope for a more efficient solution that would not evaluate (and therefore store) the Jacobian residual. My suggestion would be to combine this with ADNLPModel ( adapting this tuto https://jso.dev/ADNLPModels.jl/dev/mixed/ ) that will use AD for these operations.

Maybe this solution works with https://github.com/JuliaSmoothOptimizers/BundleAdjustmentModels.jl/pull/84 only.