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:
PreModel → declare components → build → Model
(mutable) state!/control!/... (immutable)The OCP layer is organised by responsibility across four modules:
| Module | Directory | What it provides |
|---|---|---|
CTModels.Components | src/Components/ | Component types (StateModel, TimeDependence, …) and their accessors |
CTModels.Models | src/Models/ | Immutable Model type and all model accessor methods |
CTModels.Building | src/Building/ | PreModel, declaration verbs (state!, control!, …), name validation, build |
CTModels.Solutions | src/Solutions/ | build_solution, solution types, dual model, interpolation |
Reading order
| Page | Topic | Key symbols |
|---|---|---|
| Types and traits | The noun/trait architecture | TimeDependence, AbstractStateModel, Empty* |
| Components | Declaring the spaces | state!, control!, variable!, time! |
| Dynamics and objective | The equations of motion and cost | dynamics!, objective! |
| Constraints | Path, boundary and box constraints | constraint! |
| Building a model | Freezing the PreModel | build, Model |
| Displaying models | Base.show and mathematical rendering | Model, 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
Two orthogonal axes shape the representation:
Time dependence — whether
, depend explicitly on ( AutonomousvsNonAutonomous).Time structure — whether
/ are fixed or free ( FixedTimeModelvsFreeTimeModel).
How these axes become traits rather than separate types is the subject of Types and traits.