The problem and solver constructors of the JuMP, InfiniteOpt, CasADi and
Pyomo backends of ModelingToolkit, with the same signatures. The Julia
packages do not exist in R: each constructor builds the native direct
collocation problem of DynamicOptProblem() and each collocation object
selects the transcription the backend uses, which solve() then solves
with the native interior point method (the solver argument, Ipopt in
Julia, is kept but not used).
Usage
JuMPDynamicOptProblem(
sys,
op,
tspan,
dt = NULL,
steps = NULL,
guesses = list(),
...
)
InfiniteOptDynamicOptProblem(
sys,
op,
tspan,
dt = NULL,
steps = NULL,
guesses = list(),
...
)
CasADiDynamicOptProblem(
sys,
op,
tspan,
dt = NULL,
steps = NULL,
guesses = list(),
...
)
PyomoDynamicOptProblem(
sys,
op,
tspan,
dt = NULL,
steps = NULL,
guesses = list(),
...
)
JuMPCollocation(solver = NULL, tableau = NULL)
InfiniteOptCollocation(solver = NULL, derivative_method = NULL)
CasADiCollocation(solver = NULL, tableau = NULL)
PyomoCollocation(solver = NULL, derivative_method = NULL)Arguments
- sys
A compiled
Systemwith inputs, costs and constraints.- op, tspan, dt, steps, guesses, ...
As in
DynamicOptProblem().- solver
The optimizer of the Julia backend, such as
"ipopt"; unused.- tableau, derivative_method
The transcription, see above.
Value
A DynamicOptProblem of the backend's class, or a collocation
object of class AbstractCollocation.
Details
JuMPCollocation(solver, tableau)andCasADiCollocation(solver, tableau)transcribe the dynamics with a Runge Kutta tableau, by default the fifth order Radau IIA tableau of ModelingToolkit'sconstructDefault()("RadauIIA5"). The tableau is a name (see below) or a listlist(A = , b = , c = ), such as an explicit tableau.InfiniteOptCollocation(solver, derivative_method)uses backward finite differences by default ("Backward"), or"OrthogonalCollocation(n)"(Lobatto points; 2 is the trapezoidal rule and 3 Hermite Simpson).PyomoCollocation(solver, derivative_method)uses"LagrangeRadau(n)"(Radau IIA, the default withn = 5),"LagrangeLegendre(n)"(Gauss Legendre),"BackwardEuler"or"MidpointEuler".
The names accepted everywhere are "trapezoidal", "hermite_simpson",
"backward_euler", "RadauIIA5", "RK4" and the ones above. As in
ModelingToolkit, JuMP and CasADi hold the inputs constant over a step
(every stage uses the input at the start of the step, and input_sol is
piecewise constant), ignore nominal_values, and Pyomo does not accept
initial_trajectory; with the other backends and with a name or tableau
given to solve() the inputs are free at every collocation point.
With an explicit tableau (such as "RK4"), JuMP and CasADi create no
stage variables: each step is one equality per state, from the stages
evaluated at the state and input of the step's start, and integral costs
use the trapezoidal rule on the nodes. With an implicit tableau (such as
the default) they have derivative stage variables K, one per stage and
state, with the equations K_i = f(x_k + dt sum_j A_ij K_j) and the
update x_{k+1} = x_k + dt sum_i b_i K_i; JuMP declares K at every node
(those of the last node are free), CasADi once per step. Their integral
costs also use the trapezoidal rule on the nodes. A successful solve has
the retcode Default (the retcode of build_solution), a failed one
ConvergenceFailure. The JuMP and InfiniteOpt backends
fix the initial states (bounds with equal values, which the interior
point method removes from the variables), and CasADi adds them as
equality constraints.
Further arguments of DynamicOptProblem(), such as tune_parameters,
initial_trajectory, nominal_values and bounds, are passed through
....
Examples
t <- t_nounits; D <- D_nounits
x <- Variable("x", t)
u <- Variable("u", t, input = TRUE, bounds = c(-1, 1))
sys <- System(list(D(x) ~ u), t, costs = list(-EvalAt(1)(x)), name = "s")
sys <- mtkcompile(sys, inputs = list(u))
prob <- JuMPDynamicOptProblem(sys, list(x ~ 0, u ~ 0), c(0, 1), dt = 0.1)
sol <- solve(prob, JuMPCollocation("ipopt"))
tail(sol$sol[x], 1)
#> [1] 1
iprob <- InfiniteOptDynamicOptProblem(sys, list(x ~ 0, u ~ 0), c(0, 1), dt = 0.1)
tail(solve(iprob, InfiniteOptCollocation("ipopt"))$sol[x], 1)
#> [1] 1