Dynamic Optimization Solvers
Currently 4 backends are exposed for solving dynamic optimization problems using collocation: JuMP, InfiniteOpt, CasADi, and Pyomo.
Please note that there are differences in how to construct the collocation solver for the different cases. For example, the Python based ones, CasADi and Pyomo, expect the solver to be passed in as a string (CasADi and Pyomo come pre-loaded with Ipopt, but other solvers may need to be manually installed using pip
or conda
), while JuMP/InfiniteOpt expect the optimizer object to be passed in directly:
JuMPCollocation(Ipopt.Optimizer, constructRK4())
CasADiCollocation("ipopt", constructRK4())
JuMP and CasADi collocation require an ODE tableau to be passed in. These can be constructed by calling the constructX()
functions from DiffEqDevTools. The list of tableaus can be found here. If none is passed in, both solvers will default to using Radau second-order with five collocation points.
Pyomo and InfiniteOpt each have their own built-in collocation methods.
- InfiniteOpt: The list of InfiniteOpt collocation methods can be found in the table on this page. If none is passed in, the solver defaults to
FiniteDifference(Backward())
, which is effectively implicit Euler. - Pyomo: The list of Pyomo collocation methods can be found at the bottom of this page. If none is passed in, the solver defaults to a
LagrangeRadau(3)
.
Some examples of the latter two collocations:
PyomoCollocation("ipopt", LagrangeRadau(2))
InfiniteOptCollocation(Ipopt.Optimizer, OrthogonalCollocation(3))
ModelingToolkit.JuMPCollocation
— FunctionJuMP Collocation solver. Takes two arguments:
solver
: a optimization solver such as Ipopttableau
: An ODE RK tableau. Load a tableau by calling a function likeconstructRK4
and may be found at https://docs.sciml.ai/DiffEqDevDocs/stable/internals/tableaus/. If this argument is not passed in, the solver will default to Radau second order.
ModelingToolkit.InfiniteOptCollocation
— FunctionInfiniteOpt Collocation solver.
solver
: an optimization solver such as Ipoptderivative_method
: the method used by InfiniteOpt to compute derivatives. The list of possible options can be found at https://infiniteopt.github.io/InfiniteOpt.jl/stable/guide/derivative/. Defaults to FiniteDifference(Backward()).
ModelingToolkit.CasADiCollocation
— FunctionCasADi Collocation solver.
solver
: an optimization solver such as Ipopt. Should be given as a string or symbol in all lowercase, e.g. "ipopt"tableau
: An ODE RK tableau. Load a tableau by calling a function likeconstructRK4
and may be found at https://docs.sciml.ai/DiffEqDevDocs/stable/internals/tableaus/. If this argument is not passed in, the solver will default to Radau second order.
ModelingToolkit.PyomoCollocation
— FunctionPyomo Collocation solver.
solver
: an optimization solver such as Ipopt. Should be given as a string or symbol in all lowercase, e.g. "ipopt"derivative_method
: a derivative method from Pyomo. The choices here are ForwardEuler, BackwardEuler, MidpointEuler, LagrangeRadau, or LagrangeLegendre. The last two should additionally have a number indicating the number of collocation points per timestep, e.g. PyomoCollocation("ipopt", LagrangeRadau(3)). Defaults to LagrangeRadau(5).
Missing docstring for CommonSolve.solve(::AbstractDynamicOptProblem)
. Check Documenter's build log for details.
Problem constructors
ModelingToolkit.JuMPDynamicOptProblem
— FunctionJuMPDynamicOptProblem(sys::System, op, tspan; dt, steps, guesses, kwargs...)
Convert an System representing an optimal control system into a JuMP model for solving using optimization. Must provide either dt
, the timestep between collocation points (which, along with the timespan, determines the number of points), or directly provide the number of points as steps
.
To construct the problem, please load InfiniteOpt along with ModelingToolkit.
ModelingToolkit.InfiniteOptDynamicOptProblem
— FunctionInfiniteOptDynamicOptProblem(sys::System, op, tspan; dt)
Convert an System representing an optimal control system into a InfiniteOpt model for solving using optimization. Must provide dt
for determining the length of the interpolation arrays.
Related to JuMPDynamicOptProblem
, but directly adds the differential equations of the system as derivative constraints, rather than using a solver tableau.
To construct the problem, please load InfiniteOpt along with ModelingToolkit.
ModelingToolkit.CasADiDynamicOptProblem
— FunctionCasADiDynamicOptProblem(sys::System, op, tspan; dt, steps, guesses, kwargs...)
Convert an System representing an optimal control system into a CasADi model for solving using optimization. Must provide either dt
, the timestep between collocation points (which, along with the timespan, determines the number of points), or directly provide the number of points as steps
.
To construct the problem, please load CasADi along with ModelingToolkit.
ModelingToolkit.PyomoDynamicOptProblem
— FunctionPyomoDynamicOptProblem(sys::System, op, tspan; dt, steps)
Convert an System representing an optimal control system into a Pyomo model for solving using optimization. Must provide either dt
, the timestep between collocation points (which, along with the timespan, determines the number of points), or directly provide the number of points as steps
.
To construct the problem, please load Pyomo along with ModelingToolkit.