Public API
This page lists exported symbols of CTSolvers.Optimization.
From CTSolvers.Optimization
CTSolvers.Optimization [Module]
CTSolvers.Optimization Module
Optimization module.
This module defines the abstract optimization problem interface (AbstractOptimizationProblem) and the value types of the model/solution building contract (BuiltModel, NoCache). The generic build_model / build_solution functions are owned here (and re-exported) but their canonical NotImplemented stubs — the modeler contract — live in Modelers (Modelers/contract.jl), typed on AbstractNLPModeler; concrete methods live in the package providing the problem (e.g. CTDirect), dispatched on (problem, modeler).
Solver-side utilities (e.g. extract_solver_infos) live in Solvers.
AbstractOptimizationProblem [Abstract Type]
CTSolvers.Optimization.AbstractOptimizationProblem Type
abstract type AbstractOptimizationProblemAbstract base type for optimization problems.
This is a general type that represents any optimization problem, not necessarily tied to optimal control. Subtypes can represent various problem formulations including discretized optimal control problems, general NLP problems, etc.
Subtypes implement the build_model / build_solution contract (by multiple dispatch on (problem, modeler)) to construct and interpret NLP back-end models and solutions.
Example
struct MyOptimizationProblem <: AbstractOptimizationProblem
objective::Function
constraints::Vector{Function}
endBuiltModel [Struct]
CTSolvers.Optimization.BuiltModel Type
struct BuiltModel{TP<:CTSolvers.Optimization.AbstractOptimizationProblem, TN, TC<:CTBase.Core.AbstractCache}Immutable bundle produced by CTSolvers.Optimization.build_model and consumed by CTSolvers.Optimization.build_solution.
It pairs the optimization problem with the backend NLP model and an optional, immutable build-time cache. This replaces the previous pattern of mutating a backend cache attached to the problem: any auxiliary produced while building the NLP (e.g. an ExaModels getter) is stored here once, never mutated.
Fields
problem::TP: The optimization problem (e.g.DiscretizedModel), giving access to the original OCP, the discretizer, and the discretize-time cache (docp).nlp::TN: The backend NLP model. Left untyped because its package (e.g.NLPModels) is a weak dependency.cache::TC: Immutable build-time auxiliary (<: CTBase.Core.AbstractCache), populated bybuild_model.CTSolvers.Optimization.NoCachewhen the backend needs none.
Type parameters
TP <: AbstractOptimizationProblemTNTC <: CTBase.Core.AbstractCache
See also: CTSolvers.Optimization.build_model, CTSolvers.Optimization.build_solution, CTSolvers.Optimization.NoCache.
NoCache [Struct]
CTSolvers.Optimization.NoCache Type
struct NoCache <: CTBase.Core.AbstractCacheEmpty cache for backends whose build_model produces no auxiliary data.
Used as the cache field of a CTSolvers.Optimization.BuiltModel when nothing besides the NLP needs to be carried to build_solution (e.g. the ADNLP backend). Reusable by any backend, including the future ODE side.
build_model [Function]
CTSolvers.Optimization.build_model Function
Build a backend NLP model from an optimization problem and an initial guess.
Generic function for the model-building contract. Concrete methods must be provided by the package supplying the optimization problem (e.g. CTDirect for CTSolvers.DOCP.DiscretizedModel), dispatching on the concrete (problem, modeler) pair.
Arguments
prob::CTSolvers.Optimization.AbstractOptimizationProblem: The optimization problem.initial_guess: Initial guess passed to the NLP backend.modeler::CTSolvers.Modelers.AbstractNLPModeler: The modeler strategy (e.g.ADNLP,Exa).
Returns
CTSolvers.Optimization.BuiltModel: immutable bundle of the problem, the backend NLP model, and an optional build-time cache.
Throws
CTBase.Exceptions.NotImplemented: when no concrete method exists for this(problem, modeler)pair.
See also: CTSolvers.Optimization.build_solution, CTSolvers.Optimization.BuiltModel.
build_solution [Function]
CTSolvers.Optimization.build_solution Function
Build a problem-level solution from NLP solver statistics.
Generic function for the solution-building contract. Concrete methods must be provided by the package supplying the optimization problem, dispatching on the concrete (built, modeler) pair.
Arguments
built::CTSolvers.Optimization.BuiltModel: The bundle returned byCTSolvers.Optimization.build_model.model_solution: NLP solver output (execution statistics from SolverCore).modeler::CTSolvers.Modelers.AbstractNLPModeler: The modeler strategy used to build.
Returns
- A solution object appropriate for the problem type.
Throws
CTBase.Exceptions.NotImplemented: when no concrete method exists for this(built, modeler)pair.
See also: CTSolvers.Optimization.build_model, CTSolvers.Optimization.BuiltModel.