@@ -237,7 +237,8 @@ function build_model(pre_ocp::PreModel)::Model
237237 @ensure __is_dynamics_set (pre_ocp) CTBase. UnauthorizedCall (" the dynamics must be set before building the model." )
238238 @ensure __is_dynamics_complete (pre_ocp) CTBase. UnauthorizedCall (" all the components of the dynamics must be set before building the model." )
239239 @ensure __is_objective_set (pre_ocp) CTBase. UnauthorizedCall (" the objective must be set before building the model." )
240- @ensure ! isnothing (pre_ocp. definition) CTBase. UnauthorizedCall (" the definition must be set before building the model." )
240+ @ensure __is_definition_set (pre_ocp) CTBase. UnauthorizedCall (" the definition must be set before building the model." )
241+ @ensure __is_autonomous_set (pre_ocp) CTBase. UnauthorizedCall (" the time dependence, autonomous=true or false, must be set before building the model." )
241242
242243 # extract components from PreModel
243244 times = pre_ocp. times
@@ -252,9 +253,10 @@ function build_model(pre_ocp::PreModel)::Model
252253 objective = pre_ocp. objective
253254 constraints = build_constraints (pre_ocp. constraints)
254255 definition = pre_ocp. definition
256+ TD = is_autonomous (pre_ocp) ? Autonomous : NonAutonomous
255257
256258 # create the model
257- model = Model (
259+ model = Model {TD} (
258260 times, state, control, variable, dynamics, objective, constraints, definition
259261 )
260262
265267# Getters
266268# ------------------------------------------------------------------------------ #
267269
270+ # time dependence
271+ """
272+ $(TYPEDSIGNATURES)
273+
274+ Return `true` if the model is autonomous.
275+ """
276+ function is_autonomous (
277+ :: Model {
278+ Autonomous,
279+ <: TimesModel ,
280+ <: AbstractStateModel ,
281+ <: AbstractControlModel ,
282+ <: AbstractVariableModel ,
283+ <: Function ,
284+ <: AbstractObjectiveModel ,
285+ <: AbstractConstraintsModel ,
286+ })
287+ return true
288+ end
289+
290+ function is_autonomous (
291+ :: Model {
292+ NonAutonomous,
293+ <: TimesModel ,
294+ <: AbstractStateModel ,
295+ <: AbstractControlModel ,
296+ <: AbstractVariableModel ,
297+ <: Function ,
298+ <: AbstractObjectiveModel ,
299+ <: AbstractConstraintsModel ,
300+ })
301+ return false
302+ end
303+
268304# State
269305"""
270306$(TYPEDSIGNATURES)
@@ -273,6 +309,7 @@ Get the state from the model.
273309"""
274310function state (
275311 ocp:: Model {
312+ <: TimeDependence ,
276313 <: TimesModel ,
277314 T,
278315 <: AbstractControlModel ,
@@ -320,6 +357,7 @@ Get the control from the model.
320357"""
321358function control (
322359 ocp:: Model {
360+ <: TimeDependence ,
323361 <: TimesModel ,
324362 <: AbstractStateModel ,
325363 T,
@@ -367,6 +405,7 @@ Get the variable from the model.
367405"""
368406function variable (
369407 ocp:: Model {
408+ <: TimeDependence ,
370409 <: TimesModel ,
371410 <: AbstractStateModel ,
372411 <: AbstractControlModel ,
@@ -414,6 +453,7 @@ Get the times from the model.
414453"""
415454function times (
416455 ocp:: Model {
456+ <: TimeDependence ,
417457 T,
418458 <: AbstractStateModel ,
419459 <: AbstractControlModel ,
@@ -452,6 +492,7 @@ Get the initial time from the model, for a fixed initial time.
452492"""
453493function initial_time (
454494 ocp:: Model {
495+ <: TimeDependence ,
455496 <: TimesModel{FixedTimeModel{T},<:AbstractTimeModel} ,
456497 <: AbstractStateModel ,
457498 <: AbstractControlModel ,
@@ -471,6 +512,7 @@ Get the initial time from the model, for a free initial time.
471512"""
472513function initial_time (
473514 ocp:: Model {
515+ <: TimeDependence ,
474516 <: TimesModel{FreeTimeModel,<:AbstractTimeModel} ,
475517 <: AbstractStateModel ,
476518 <: AbstractControlModel ,
@@ -491,6 +533,7 @@ Get the initial time from the model, for a free initial time.
491533"""
492534function initial_time (
493535 ocp:: Model {
536+ <: TimeDependence ,
494537 <: TimesModel{FreeTimeModel,<:AbstractTimeModel} ,
495538 <: AbstractStateModel ,
496539 <: AbstractControlModel ,
@@ -555,6 +598,7 @@ Get the final time from the model, for a fixed final time.
555598"""
556599function final_time (
557600 ocp:: Model {
601+ <: TimeDependence ,
558602 <: TimesModel{<:AbstractTimeModel,FixedTimeModel{T}} ,
559603 <: AbstractStateModel ,
560604 <: AbstractControlModel ,
@@ -574,6 +618,7 @@ Get the final time from the model, for a free final time.
574618"""
575619function final_time (
576620 ocp:: Model {
621+ <: TimeDependence ,
577622 <: TimesModel{<:AbstractTimeModel,FreeTimeModel} ,
578623 <: AbstractStateModel ,
579624 <: AbstractControlModel ,
@@ -594,6 +639,7 @@ Get the final time from the model, for a free final time.
594639"""
595640function final_time (
596641 ocp:: Model {
642+ <: TimeDependence ,
597643 <: TimesModel{<:AbstractTimeModel,FreeTimeModel} ,
598644 <: AbstractStateModel ,
599645 <: AbstractControlModel ,
@@ -642,6 +688,7 @@ Get the objective from the model.
642688"""
643689function objective (
644690 ocp:: Model {
691+ <: TimeDependence ,
645692 <: AbstractTimesModel ,
646693 <: AbstractStateModel ,
647694 <: AbstractControlModel ,
@@ -675,6 +722,7 @@ Get the Mayer cost from the model.
675722"""
676723function mayer (
677724 ocp:: Model {
725+ <: TimeDependence ,
678726 <: AbstractTimesModel ,
679727 <: AbstractStateModel ,
680728 <: AbstractControlModel ,
@@ -694,6 +742,7 @@ Get the Mayer cost from the model.
694742"""
695743function mayer (
696744 ocp:: Model {
745+ <: TimeDependence ,
697746 <: AbstractTimesModel ,
698747 <: AbstractStateModel ,
699748 <: AbstractControlModel ,
@@ -727,6 +776,7 @@ Get the Lagrange cost from the model.
727776"""
728777function lagrange (
729778 ocp:: Model {
779+ <: TimeDependence ,
730780 <: AbstractTimesModel ,
731781 <: AbstractStateModel ,
732782 <: AbstractControlModel ,
@@ -746,6 +796,7 @@ Get the Lagrange cost from the model.
746796"""
747797function lagrange (
748798 ocp:: Model {
799+ <: TimeDependence ,
749800 <: AbstractTimesModel ,
750801 <: AbstractStateModel ,
751802 <: AbstractControlModel ,
@@ -775,6 +826,7 @@ Get the dynamics from the model.
775826"""
776827function dynamics (
777828 ocp:: Model {
829+ <: TimeDependence ,
778830 <: AbstractTimesModel ,
779831 <: AbstractStateModel ,
780832 <: AbstractControlModel ,
@@ -795,6 +847,7 @@ Get the constraints from the model.
795847"""
796848function constraints (
797849 ocp:: Model {
850+ <: TimeDependence ,
798851 <: AbstractTimesModel ,
799852 <: AbstractStateModel ,
800853 <: AbstractControlModel ,
@@ -823,6 +876,7 @@ Get the nonlinear path constraints from the model.
823876"""
824877function path_constraints_nl (
825878 ocp:: Model {
879+ <: TimeDependence ,
826880 <: TimesModel ,
827881 <: AbstractStateModel ,
828882 <: AbstractControlModel ,
@@ -842,6 +896,7 @@ Get the nonlinear boundary constraints from the model.
842896"""
843897function boundary_constraints_nl (
844898 ocp:: Model {
899+ <: TimeDependence ,
845900 <: TimesModel ,
846901 <: AbstractStateModel ,
847902 <: AbstractControlModel ,
@@ -861,6 +916,7 @@ Get the box constraints on state from the model.
861916"""
862917function state_constraints_box (
863918 ocp:: Model {
919+ <: TimeDependence ,
864920 <: TimesModel ,
865921 <: AbstractStateModel ,
866922 <: AbstractControlModel ,
@@ -880,6 +936,7 @@ Get the box constraints on control from the model.
880936"""
881937function control_constraints_box (
882938 ocp:: Model {
939+ <: TimeDependence ,
883940 <: TimesModel ,
884941 <: AbstractStateModel ,
885942 <: AbstractControlModel ,
@@ -899,6 +956,7 @@ Get the box constraints on variable from the model.
899956"""
900957function variable_constraints_box (
901958 ocp:: Model {
959+ <: TimeDependence ,
902960 <: TimesModel ,
903961 <: AbstractStateModel ,
904962 <: AbstractControlModel ,
0 commit comments