formulation
Render a whole :class:~openscvx.problem.Problem as a Mayer-form formulation.
Where the expression visitors (arithmetic, math, ...) turn a single AST
node into LaTeX, this module assembles the problem — objective, dynamics,
path constraints, box bounds, and boundary conditions — into one classic
optimal-control block::
minimize <Mayer terms>
subject to <dynamics>, <path constraints>, <box bounds>, <boundary conditions>
A Mayer form puts the entire objective on the boundary of the trajectory
(terms like t(t_f) or x_i(t_0)) rather than as a running integral; this
is exactly how OpenSCvx problems are posed, since initial/final boundary
types are the only source of cost.
The block renders the pre-augmentation, user-authored problem. The solver
augments dynamics with a time-dilation control and per-CTCS penalty states
(_-prefixed), but those are machinery, not math the user wrote — so anything
named with a leading underscore is filtered out. CTCS constraints render as the
continuous-time path constraints they stand for, which is the whole point of the
Mayer story.
Each of the two configurable sections has its own detail levels. Dynamics:
"inline"— one\dot{<state>} = <expr>row per equation in the formulation."separate"— the formulation carries\dot{x} = f(x, u)and the per-state definitions follow as their own block.
Constraints add a middle level:
"inline"— full constraint bodies with their annotations."symbolic"— numberedg_i(x, u) \le 0/h_j(x, u) = 0references only,\forall t/ node annotations kept visible."separate"— symbolic references with the residual bodies appended as a definition block. Theg_i/h_jnumbering lines up between the references and the definitions.
The output is a complete display-math fragment: the Mayer form as a
subequations/align block (per-row numbering, drops into a paper as-is),
with each "separate" definition block a bare align, joined by newlines
and no connective text — any where/spacing glue is the author's editorial
call. No $$ wrapping. env="aligned" swaps the paper envelope for plain
aligned blocks that renderers without subequations support (MathJax,
KaTeX) can typeset inside $$.
problem_to_latex(symbolic: SymbolicProblem, dynamics_dict: dict, lam_cost: Union[float, np.ndarray], *, dynamics: str, constraints: str, weights: str = 'symbolic', env: Literal['align', 'aligned'] = 'align') -> str
¶
Assemble a Mayer-form LaTeX formulation of a problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbolic
|
SymbolicProblem
|
The preprocessed :class: |
required |
dynamics_dict
|
dict
|
The user-authored |
required |
lam_cost
|
Union[float, ndarray]
|
Objective weights — a scalar or an |
required |
dynamics
|
str
|
Detail level for the dynamics section — |
required |
constraints
|
str
|
Detail level for the constraint section — |
required |
weights
|
str
|
How objective coefficients render — |
'symbolic'
|
env
|
Literal['align', 'aligned']
|
Output envelope. |
'align'
|
Returns:
| Type | Description |
|---|---|
str
|
One LaTeX display-math fragment: the formulation block followed, in |
str
|
|
str
|
joined by newlines with no connective glue. No |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |