# ControlSystem

## System Constructors

ModelingToolkit.ControlSystemType
struct ControlSystem <: ModelingToolkit.AbstractControlSystem

A system describing an optimal control problem. This contains a loss function and ordinary differential equations with control variables that describe the dynamics.

Fields

• loss

The Loss function

• eqs

The ODEs defining the system.

• iv

Independent variable.

• states

Dependent (state) variables. Must not contain the independent variable.

• controls

Control variables.

• ps

Parameter variables. Must not contain the independent variable.

• observed

• 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.

Example

using ModelingToolkit

@variables t x(t) v(t) u(t)
D = Differential(t)

loss = (4-x)^2 + 2v^2 + u^2
eqs = [
D(x) ~ v
D(v) ~ u^3
]

sys = ControlSystem(loss,eqs,t,[x,v],[u],[])
source

## Composition and Accessor Functions

• get_eqs(sys) or equations(sys): The equations that define the system.
• get_states(sys) or states(sys): The set of states in the system.
• get_ps(sys) or parameters(sys): The parameters of the system.
• get_controls(sys) or controls(sys): The control variables of the system

## Transformations

ModelingToolkit.runge_kutta_discretizeFunction
runge_kutta_discretize(sys::ControlSystem,dt,tspan;
tab = ModelingToolkit.constructRadauIIA5())

Transforms a nonlinear optimal control problem into a constrained OptimizationProblem according to a Runge-Kutta tableau that describes a collocation method. Requires a fixed dt over a given timespan. Defaults to using the 5th order RadauIIA tableau, and altnerative tableaus can be specified using the SciML tableau style.

source
ModelingToolkit.structural_simplifyFunction
structural_simplify(sys; simplify)


Structurally simplify algebraic equations in a system and compute the topological sort of the observed equations. When simplify=true, the simplify function will be applied during the tearing process.

source