API Reference
JuDO.BoundaryConditionExpr — Type
BoundaryConditionExpr{L,R} <: JuMP.AbstractJuMPScalarA boundary condition expression representing conditions on the initial or final values of variables or phases.
JuDO.BoundaryOperator — Type
BoundaryOperator()A boundary operator representing either the initial or final value of a variable or phase.
JuDO.DerivativeTerm — Type
DerivativeTerm <: JuMP.AbstractJuMPScalarRepresents the time-derivative of a DynamicVarRef, optionally scaled by a coefficient. Created by calling derivative(x) on a dynamic variable.
Fields
var: theDynamicVarRefbeing differentiated.coef: scalar multiplier (default1.0).
JuDO.DyBoundaryConstraint — Type
DyBoundaryConstraint <: JuMP.AbstractConstraintInternal constraint object produced by JuMP.build_constraint when a BoundaryConditionExpr is constrained with ==, <=, or >=. Holds the parsed boundary expression and the MOI set encoding the right-hand side.
Fields
expr: theBoundaryConditionExprrepresenting the boundary condition.set: an MOI scalar set (EqualTo,LessThan, orGreaterThan).
JuDO.DynamicAffExpr — Type
DynamicAffExpr{Ctype, Vtype} <: JuMP.AbstractJuMPScalarAn affine expression over dynamic variables of the form
constant + Σ coeff_i * var_iwhere each var_i is a DynamicVarRef. Produced automatically by arithmetic operations such as x + 2.0 or 3*x - y.
Fields
constant: scalar offset of typeCtype(typicallyFloat64).terms: ordered mapping from eachDynamicVarRefto its coefficient.
JuDO.DynamicQuadExpr — Type
DynamicQuadExpr{Ctype, Vtype} <: JuMP.AbstractJuMPScalarA quadratic expression over dynamic variables of the form
affine_part + Σ coeff_ij * var_i * var_jProduced automatically by operations such as x * y or x^2.
Fields
aff: the affine part as aDynamicAffExpr.terms: ordered mapping fromJuMP.UnorderedPair{Vtype}to its coefficient.
JuDO.DynamicVar — Type
DynamicVar <: JuMP.AbstractVariableRepresents a single dynamic (state or control) variable that evolves continuously over a given phase. Stores JuMP-level bound information plus JuDO-specific fields for initial/final point values and trajectory bounds.
Fields
Jumpinfo: standard JuMPVariableInfocarrying lower/upper bounds.Phase: integer index of the phase this variable belongs to.Initial_value: optional fixed value at the start of the phase.Final_value: optional fixed value at the end of the phase.Trajectory_bound: two-element vector[lb, ub]bounding the trajectory.
JuDO.Integral — Type
Integral <: JuMP.AbstractJuMPScalarRepresents a definite integral of a dynamic expression over a phase, used to express Lagrange (running-cost) objectives. Created via the integral() function.
Fields
expr: the integrand as a JuMP scalar expression.phase: integer index of the phase over which the integral is taken.
JuDO.NonlinearExpr — Type
NonlinearExpr <: JuMP.AbstractJuMPScalarAn expression tree node used to represent nonlinear dynamic expressions that cannot be captured by DynamicAffExpr or DynamicQuadExpr. Mirrors the structure of Julia's Expr type.
Fields
head: node type, typically:call.args: vector whose first element is the operatorSymbol(e.g.:sin,:*) and whose remaining elements are sub-expressions or numbers.
JuDO.Phase — Type
PhaseA sentinel type used to tag a JuDO phase object. It carries no data and is used internally to distinguish phase-related dispatch.
JuDO.PhaseVar — Type
PhaseVar <: JuMP.AbstractVariableStores the user-specified bounds for a phase (the independent variable domain, usually time). The Initial and Final fields hold the start and end values of the domain, which may be fixed numbers or free JuMP.VariableRefs.
Fields
Initial: lower bound of the phase domain (-Infif unbounded).Final: upper bound of the phase domain (Infif unbounded).
JuDO.PhaseVarRef — Type
PhaseVarRef{M<:JuMP.AbstractModel} <: JuMP.AbstractVariableRefA reference to a phase that has been registered in a DynModel. Holds a pointer to the parent model, an integer index, and the symbolic name assigned by the @phase macro.
Fields
model: theDynModelthat owns this phase.Index: integer position of the phase in the model's internal registry.name: theSymbolused as the phase identifier (e.g.:t).
JuDO.DynModel — Method
DynModel(args...; kwargs...) -> JuMP.ModelConstruct a dynamic optimization model. DynModel wraps a standard JuMP.Model and initialises the internal data structures required for dynamic optimization:
:Phases/:Phasenum— registry of phases and their count.:variables/:varnum— registry of dynamic variables and their count.:phase_name_to_idx/:var_name_to_idx— name-to-index lookup dictionaries.
Any positional or keyword arguments are forwarded to JuMP.Model, so an optimizer can be attached at construction time:
using JuDO, Interesso
model = DynModel(Interesso.Optimizer)JuDO.dyn_value — Method
value(m::JuMP.Model, var::DynamicVarRef)
Get the value of a dynamic variable.JuDO.final — Method
final(x) -> BoundaryOperatorReturn a BoundaryOperator that evaluates x at the end of its phase. Use inside @constraint or @objective:
@constraint(model, final(x) == 1.0)
@objective(model, Max, final(altitude))JuDO.get_phase — Method
get_phase(model) -> OrderedDict{Int, PhaseVar}Return the ordered dictionary mapping phase indices to their PhaseVar data stored in model.
JuDO.get_phasenum — Method
get_phasenum(model) -> Dict{Symbol, Int}Return the counter dictionary (key :phase) tracking how many phases have been added to model.
JuDO.get_solutions — Method
get_solutions(m::JuMP.Model)Return a dictionary mapping dynamic variable names to their solutions.
JuDO.get_var — Method
get_var(model) -> OrderedDict{Int, DynamicVar}Return the ordered dictionary mapping variable indices to their DynamicVar data stored in model.
JuDO.get_varnum — Method
get_varnum(model) -> Dict{Symbol, Int}Return the counter dictionary (key :var) tracking how many dynamic variables have been added to model.
JuDO.initial — Method
initial(x) -> BoundaryOperatorReturn a BoundaryOperator that evaluates x at the start of its phase. Use inside @constraint or @objective:
@constraint(model, initial(x) == 0.0)
@objective(model, Min, initial(fuel))JuDO.integral — Method
JuMP.integral(expr::JuMP.AbstractJuMPScalar, phase::Int) -> IntegralCreates an integral representation for the given expression and phase.
JuDO.objective_has_measures — Method
objective_has_measures(model::JuMP.Model) -> BoolReturns true if the objective function contains any measure variables.
JuDO.optimize! — Method
optimize!(m::JuMP.Model)
Optimize the model. Keyword arguments are a convenience shorthand for callingJuMP.set_attribute individually before optimizing.
JuDO.phase_final — Method
phase_final(t::PhaseVarRef)Returns the final time of the phase t.
- If the final time is fixed (e.g., final(t) == 10), returns that value.
- If the final time is free/optimized (e.g., final(t) <= 10), queries the solver for the result.
JuDO.phase_initial — Method
phase_initial(t::PhaseVarRef)Returns the initial time of the phase t defined in the model.
JuDO.to_NDF — Function
to_NDF(f::AbstractDynamicFunction)Convert an AbstractDynamicFunction into its NonlinearDynamicFunction equivalent.
This function builds a nested expression tree to represent the input function.
JuDO.warmstart! — Method
warmstart!(m::DynModel, interpolant::DOI.AbstractDynamicSolution, var::DynamicVarRef)
set the interpolant for a dynamic variable in the modelJuMP.build_variable — Method
Extending Jump.build_variable
JuMP.derivative — Method
derivative(x::DynamicVarRef) -> DerivativeTermReturn a DerivativeTerm representing the derivative of the dynamic variable x with respect to its phase domain (e.g. time). Use this inside a @constraint to specify differential equations:
@constraint(model, derivative(x) == -x + u)JuMP.set_attribute — Method
JuMP.set_attribute(m::JuMP.Model, ::DOI.GeneralBounds, value::DOI.AbstractBounds)Set the bounds enforcement strategy. value must subtype DOI.AbstractBounds. Refer to the attached solver's documentation for supported concrete types (e.g. ExactBounds(), BernsteinBounds()).
JuMP.set_attribute — Method
JuMP.set_attribute(m::JuMP.Model, ::DOI.GeneralIntervals, value::DOI.AbstractIntervals)Set the mesh interval structure. value must subtype DOI.AbstractIntervals. Refer to the attached solver's documentation for supported concrete types (e.g. FixedIntervals(n), FlexibleIntervals(n, flexibility)).
JuMP.set_attribute — Method
JuMP.set_attribute(m::JuMP.Model, ::DOI.GeneralMethod, value::DOI.AbstractMethod)Set the discretization method. value must subtype DOI.AbstractMethod. Refer to the attached solver's documentation for supported concrete types (e.g. Collocation(), DAIR(n)).
JuMP.set_attribute — Method
JuMP.set_attribute(m::JuMP.Model, ::DOI.GeneralPoints, value::DOI.AbstractPoints)Set the collocation point scheme. value must subtype DOI.AbstractPoints. Refer to the attached solver's documentation for supported concrete types (e.g. LGRPoints(n), LGLPoints(n)).
JuMP.set_attribute — Method
JuMP.set_attribute(m::JuMP.Model, attr::MOI.AbstractOptimizerAttribute, value)Generic fallback for any backend-specific MOI.AbstractOptimizerAttribute not covered by a more specific overload (e.g. CTDirectDOI.GridSize, CTDirectDOI.DiscMethod).
JuMP.set_attribute — Method
JuMP.set_attribute(m::JuMP.Model, ::MOI.Silent, value::Bool)Silence (or un-silence) the inner NLP solver. Routes to the inner optimizer rather than the Interesso layer, since MOI.Silent is an NLP-solver attribute.
set_attribute(model, MOI.Silent(), true) # suppress Ipopt output
set_attribute(model, MOI.Silent(), false) # restore Ipopt outputJuDO.@phase — Macro
@phase(model, name)
@phase(model, name, start, stop)Register a new phase (independent variable domain) in model under the identifier name.
- Unbounded form —
@phase(model, t): creates a phase with bounds[-Inf, Inf]. Use this when the start or end time will be determined by the optimizer or set later via boundary constraints. - Bounded form —
@phase(model, t, 0, 10): fixes the phase domain to[start, stop]and immediately adds the corresponding equality constraints to the backend.
Returns a PhaseVarRef that can be passed to @variable, initial, final, and other JuDO functions.
Examples
model = DynModel(Interesso.Optimizer)
@phase(model, t) # free phase
@phase(model, t, 0.0, 1.0) # fixed phase from 0 to 1