# OptimizationSystem

## System Constructors

ModelingToolkit.OptimizationSystemType
struct OptimizationSystem <: AbstractTimeIndependentSystem

A scalar equation for optimization.

Fields

• op

Vector of equations defining the system.

• states

Unknown variables.

• ps

Parameters.

• var_to_name

Array variables.

• observed

• constraints

• name

Name: the name of the system. These are required to have unique names.

• systems

systems: The internal systems

• defaults

defaults: The default values to use when initial conditions and/or parameters are not supplied in ODEProblem.

Examples

@variables x y z
@parameters σ ρ β

op = σ*(y-x) + x*(ρ-z)-y + x*y - β*z
@named os = OptimizationSystem(op, [x,y,z],[σ,ρ,β])

## Composition and Accessor Functions

• get_eqs(sys) or equations(sys): The equation 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.

## Applicable Calculation and Generation Functions

calculate_gradient
calculate_hessian
generate_hessian
hessian_sparsity

## Problem Constructors

SciMLBase.OptimizationProblemType

Defines a optimization problem. Documentation Page: https://galacticoptim.sciml.ai/dev/API/optimization_problem/

Mathematical Specification of a Optimization Problem

To define an Optimization Problem, you simply need to give the function $f$ which defines the cost function to minimize:

$$$min_u f(u,p)$$$

$u₀$ is an initial guess of the minimum. f should be specified as f(u,p) and u₀ should be an AbstractArray (or number) whose geometry matches the desired geometry of u. Note that we are not limited to numbers or vectors for u₀; one is allowed to provide u₀ as arbitrary matrices / higher-dimension tensors as well.

Problem Type

Constructors

OptimizationProblem{iip}(f, x, p = SciMLBase.NullParameters(),;
lb = nothing,
ub = nothing,
lcons = nothing,
ucons = nothing,
sense = nothing,
kwargs...)

isinplace optionally sets whether the function is in-place or not. This is determined automatically, but not inferred. Note that for OptimizationProblem, in-place only refers to the Jacobian and Hessian functions, and thus by default if the OptimizationFunction is not defined directly then iip = true is done by default.

Parameters are optional, and if not given, then a NullParameters() singleton will be used, which will throw nice errors if you try to index non-existent parameters. Any extra keyword arguments are passed on to the solvers. For example, if you set a callback in the problem, then that callback will be added in every solve call.

lb and ub are the upper and lower bounds for box constraints on the optimization. They should be an AbstractArray matching the geometry of u, where (lb[I],ub[I]) is the box constraint (lower and upper bounds) for u[I].

lcons and ucons are the upper and lower bounds for equality constraints on the optimization. They should be an AbstractArray matching the geometry of u, where (lcons[I],ucons[I]) is the constraint (lower and upper bounds) for cons[I].

If f is a standard Julia function, it is automatically converted into an OptimizationFunction with NoAD(), i.e., no automatic generation of the derivative functions.

Any extra keyword arguments are captured to be sent to the optimizers.

Fields

• f: The function in the problem.
• u0: The initial guess for the optima.
• p: The parameters for the problem. Defaults to NullParameters.
• lb: the lower bounds for the optimization of u.
• ub: the upper bounds for the optimization of u.
• lcons:
• ucons:
• sense:
• kwargs: The keyword arguments passed on to the solvers.