Skip to content

Optimal control problems ​

CTModels defines and builds optimal control problems (OCPs) through four focused modules: CTModels.Components, CTModels.Models, CTModels.Building, and CTModels.Solutions. An OCP is assembled incrementally into a mutable PreModel, then frozen into an immutable Model by build.

The model is built through a three-stage pipeline:

text
PreModel  →  declare components  →  build  →  Model
(mutable)    state!/control!/...           (immutable)

The OCP layer is organised by responsibility across four modules:

ModuleDirectoryWhat it provides
CTModels.Componentssrc/Components/Component types (StateModel, TimeDependence, …) and their accessors
CTModels.Modelssrc/Models/Immutable Model type and all model accessor methods
CTModels.Buildingsrc/Building/PreModel, declaration verbs (state!, control!, …), name validation, build
CTModels.Solutionssrc/Solutions/build_solution, solution types, dual model, interpolation

Reading order ​

PageTopicKey symbols
Types and traitsThe noun/trait architectureTimeDependence, AbstractStateModel, Empty*
ComponentsDeclaring the spacesstate!, control!, variable!, time!
Dynamics and objectiveThe equations of motion and costdynamics!, objective!
ConstraintsPath, boundary and box constraintsconstraint!
Building a modelFreezing the PreModelbuild, Model
Displaying modelsBase.show and mathematical renderingModel, PreModel display

The pipeline on an example ​

Getting started builds the complete beam problem through this pipeline: declaration of the spaces, in-place dynamics, Lagrange cost, boundary and box constraints, then build. The pages listed above take each step in turn. build_model is an alias of build; see Building a model for what build checks and guarantees.

Mathematical setting ​

CTModels represents a continuous-time OCP in Bolza form. With state   , control    and an optimisation variable   (free final time, design parameters, …):

Two orthogonal axes shape the representation:

  • Time dependence — whether , depend explicitly on (Autonomous vs NonAutonomous).

  • Time structure — whether / are fixed or free (FixedTimeModel vs FreeTimeModel).

How these axes become traits rather than separate types is the subject of Types and traits.