[Dev] One source of truth per problem, and the equality of the modelings checked by computation

Ouverte
#391 1 commentaire 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@ocots y travaille déjà.

Depuis le 6/11/2026.

Évaluation

Cette issue n'a pas encore été évaluée.

Description

Written by Claude (Claude Code) at the request of ocots, from a design discussion with ocots.

Goal

Each problem should have one source of truth for what is shared between modelings, and an automatic check for what is written more than once. Today a problem is written once per modeling (OptimalControl @def, its scalarized variant, JuMP), plus its metadata. Nothing checks that the dynamics, costs and constraints of two modelings are the same function. #371 compares NLPs, which happens after discretization and mixes the formulation with the transcription.

What we know

  • Declarative data (parameters, bounds, initial guess, reference values, names) can be shared directly: #377 (shared initial guess), #379 (declared fields), #376 (features computed from the model).
  • ProblemData (ext/JuMPModels/schemes/data.jl, #368, #369) already describes a problem by continuous functions (x, u, v, t), with no discretization in it. These functions are generic Julia code. They can be called with numbers, JuMP variables or symbolic variables, so the same data could feed a ModelingToolkit modeling (#308).
  • The @def models stay hand-written. They are the showcase of OptimalControl, and two independent writings make a better oracle than one generated from the other.
  • Exa is the only reason OptimalControl needs @def. The Exa model is generated from the syntax by CTParser (build_examodel). A model built from functions with the functional API of CTModels has no Exa builder. control-toolbox/CTDirect.jl#673 removes this limit: the components get a traceable form, and one transcription in CTDirect serves every modeler.

Proposal (to be discussed)

  1. Shared declarative data: one source per problem, read by every modeling (#377, #379).
  2. Equality of the functions, by computation: for every problem available in both OptimalControl and JuMP, evaluate the dynamics, the Lagrange and Mayer costs, and the path and boundary constraints of the @def model and of ProblemData at random points, and require equality. This checks the formulation before any discretization, without a hand-written list. Differences that are wanted (scaling with state_expressions, component names) must be recognised by computation and reported.
  3. ModelingToolkit (optional): build the MTK modeling from ProblemData instead of writing it by hand (#308).
  4. Target, after control-toolbox/CTDirect.jl#673: a ProblemData could become a CTModels Model with its traceable form, hence solvable with Exa without @def. Its transcription by CTDirect would then be compared with the hand-written JuMP transcription (schemes/build.jl), which stays an independent oracle.

Related

#257, #284, #308, #371, #376, #377, #379; control-toolbox/CTDirect.jl#673 and control-toolbox/CTDirect.jl#674.

How to work on this theme

This is a theme issue: it describes the work to do and what is known so far, it is not meant to be closed by a single PR.

  1. Whoever takes it first defines the work precisely and splits it into sub-issues (they can live in any repository of the organization).
  2. Work proceeds through the sub-issues; tick the checklist below as they are closed.
  3. Close the theme when everything is done or explicitly dropped.
Sub-issues
  • to be created when the theme is taken
Langage dominant
Julia
Étoiles
13
Forks
1
Merge moyen
3 h 9 min
PR mergées (30 j)
47

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de control-toolbox/OptimalControlProblems.jl

Toutes les issues de control-toolbox/OptimalControlProblems.jl

Issues similaires

Plus d'issues Julia

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.