-
-
Notifications
You must be signed in to change notification settings - Fork 40
Optimization based solvers #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Benchmark ResultsClick to check benchmark results
|
This comment was marked as outdated.
This comment was marked as outdated.
I think this PR is ready to go now. The optimal control interface still needs some more work considering the complex whole-time interval inequality(similar to |
if prob isa NonlinearLeastSquaresProblem | ||
return __FastShortcutBVPCompatibleNLLSPolyalg(eltype(prob.u0)) | ||
else | ||
return __FastShortcutBVPCompatibleNonlinearPolyalg(eltype(prob.u0)) | ||
end | ||
end | ||
|
||
# Some optimization algorithms (solvers from interfacing packages) don't support the __solve(prob) interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, we should handle this upstream, which ones?
retcode = ifelse(SciMLBase.successful_retcode(nlsol), odesol.retcode, nlsol.retcode) | ||
return SciMLBase.solution_new_original_retcode(odesol, nlsol, retcode, nlsol.resid) | ||
end | ||
function __build_solution(prob::AbstractBVProblem, odesol, optsol::SciMLBase.OptimizationSolution) | ||
retcode = ifelse(SciMLBase.successful_retcode(optsol), odesol.retcode, optsol.retcode) | ||
return SciMLBase.solution_new_original_retcode(odesol, optsol, retcode, zeros(length(first(odesol)))) # Need a patch in SciMLBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what needs a patch?
zeros(T, N*M) | ||
else | ||
lcons_length = length(prob.lcons) | ||
vcat(prob.lcons, zeros(T, N*M - lcons_length)) | ||
end | ||
ucons = if isnothing(prob.ucons) | ||
zeros(T, N*M) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using zero is likely not good? That will mess with the stability of the solver quite a bit. If inequality constraints are given then the lcons / ucons should be required from the user.
jac_prototype = jac_prototype) | ||
return __internal_nlsolve_problem(prob, resid_prototype, y, nlf, y, p) | ||
else | ||
optf = OptimizationFunction{true}(__default_cost(prob.f), AutoFiniteDiff(), # Need to investigate the ForwardDiff dual problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what problem?
jac_prototype = jac_prototype) | ||
return __internal_nlsolve_problem(prob, resid_prototype, y, nlf, y, p) | ||
else | ||
optf = OptimizationFunction{true}( | ||
__default_cost(prob.f), get_dense_ad(alg.jac_alg.diffmode), | ||
cons = loss, cons_j = jac, cons_jac_prototype = jac_prototype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not easy to see from this, but when doing multiple shooting with this the codegen should be a little different from the nonlinear solve. With multiple shooting you have the endpoint conditions, and you put those into the nonlinear equation to be satisfied. In the optimization, they should be moved to the equality constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of those things are small. Let's make those into issues, but merge and continue with smaller changes.
Part of #336
Some TODOs: