OptimizationSystem

System Constructors

ModelingToolkit.OptimizationSystemType
struct OptimizationSystem <: ModelingToolkit.AbstractOptimizationSystem

A scalar equation for optimization.

Fields

  • tag

: tag: a tag for the system. If two system have the same tag, then they are structurally identical.

  • op

: Objective function of the system.

  • states

: Unknown variables.

  • ps

: Parameters.

  • var_to_name

: Array variables.

  • observed

: Observed variables.

  • constraints

: List of constraint equations of the system.

  • name

: The unique name of the system.

  • systems

: The internal systems.

  • defaults

: The default values to use when initial guess and/or parameters are not supplied in OptimizationProblem.

  • metadata

: metadata: metadata for the system, to be used by downstream packages.

  • complete

: complete: if a model sys is complete, then sys.x no longer performs namespacing.

Examples

@variables x y z
@parameters a b c

obj = a * (y - x) + x * (b - z) - y + x * y - c * z
cons = [x^2 + y^2 ≲ 1]
@named os = OptimizationSystem(obj, [x, y, z], [a, b, c]; constraints = cons)
source

Composition and Accessor Functions

  • get_op(sys): The objective to be minimized.
  • get_states(sys) or states(sys): The set of states for the optimization.
  • get_ps(sys) or parameters(sys): The parameters for the optimization.
  • get_constraints(sys) or constraints(sys): The constraints for the optimization.

Transformations

Analyses

Applicable Calculation and Generation Functions

calculate_gradient
calculate_hessian
generate_gradient
generate_hessian
hessian_sparsity

Problem Constructors

SciMLBase.OptimizationProblemMethod
function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem,u0map,
                                          parammap=DiffEqBase.NullParameters();
                                          grad = false,
                                          hess = false, sparse = false,
                                          cons_j = false, cons_h = false,
                                          checkbounds = false,
                                          linenumbers = true, parallel=SerialForm(),
                                          kwargs...) where iip

Generates an OptimizationProblem from an OptimizationSystem and allows for automatically symbolically calculating numerical enhancements.

Certain solvers require setting cons_j, cons_h to true for constrained-optimization problems.

source

Expression Constructors

ModelingToolkit.OptimizationProblemExprType
function DiffEqBase.OptimizationProblemExpr{iip}(sys::OptimizationSystem,
                                          parammap=DiffEqBase.NullParameters();
                                          u0=nothing,
                                          grad = false,
                                          hes = false, sparse = false,
                                          checkbounds = false,
                                          linenumbers = true, parallel=SerialForm(),
                                          kwargs...) where iip

Generates a Julia expression for an OptimizationProblem from an OptimizationSystem and allows for automatically symbolically calculating numerical enhancements.

source