@@ -3,16 +3,36 @@ module OptimalControlProblems
33using CTBase
44using CTDirect
55import CTModels: CTModels, time_grid, state, control, costate
6- import ExaModels: ExaModels, variable
6+ import ExaModels: ExaModels, ExaModel, variable
77using DocStringExtensions
88using OrderedCollections: OrderedDict
9+ using SolverCore
10+ import ADNLPModels: ADNLPModels, ADNLPModel
911
1012# -----------------
1113# SHOULD NO BE HERE
1214nlp_model(docp:: CTDirect.DOCP ) = docp. nlp
1315ocp_model(docp:: CTDirect.DOCP ) = docp. ocp
16+ function build_ocp_solution(docp:: CTDirect.DOCP , nlp_solution:: SolverCore.AbstractExecutionStats )
17+ nlp_model_backend = if nlp_model(docp) isa ADNLPModel
18+ CTDirect. ADNLPBackend()
19+ elseif nlp_model(docp) isa ExaModel
20+ CTDirect. ExaBackend()
21+ else
22+ throw(CTBase. IncorrectArgument(" The NLP model is of unknown type." ))
23+ end
24+ return CTDirect. build_OCP_solution(
25+ docp;
26+ primal= nlp_solution. solution,
27+ dual= nlp_solution. multipliers,
28+ mult_LB= nlp_solution. multipliers_L,
29+ mult_UB= nlp_solution. multipliers_U,
30+ nlp_model= nlp_model_backend,
31+ docp_solution= nlp_solution
32+ )
33+ end
1434
15- export nlp_model, ocp_model
35+ export nlp_model, ocp_model, build_ocp_solution
1636
1737# -----------------
1838
0 commit comments