9696# ------------------------------------------------------------------------------ #
9797
9898# ------------------------------------------------------------------------------ #
99- # Trait contract — time & variable dependence
99+ # Trait contract — time, variable & control dependence
100100#
101101# CTModels no longer defines the boolean predicates `is_autonomous`,
102- # `is_nonautonomous`, `is_variable`, `is_nonvariable`, `has_variable`: these are
103- # generic functions owned by `CTBase.Traits`. A `Model` only declares that it has
104- # the traits and reports the trait values; the predicates then follow generically.
102+ # `is_nonautonomous`, `is_variable`, `is_nonvariable`, `has_variable`,
103+ # `is_control_free`, `has_control`: these are generic functions owned by
104+ # `CTBase.Traits`. A `Model` only declares that it has the traits and reports the
105+ # trait values; the predicates then follow generically.
105106#
106107# - time dependence is read from the `TD` type parameter,
107108# - variable dependence is read from the *type* of the variable model
108- # (`EmptyVariableModel` ⟹ Fixed, any other ⟹ NonFixed) — not from the dimension.
109+ # (`EmptyVariableModel` ⟹ Fixed, any other ⟹ NonFixed) — not from the dimension,
110+ # - control dependence is read from the *type* of the control model
111+ # (`EmptyControlModel` ⟹ ControlFree, any other ⟹ WithControl) — not from the
112+ # dimension.
109113# ------------------------------------------------------------------------------ #
110114
111115Traits. has_time_dependence_trait (:: Model ) = true
@@ -118,37 +122,11 @@ Traits.variable_dependence(ocp::Model) = _variable_dependence(ocp.variable)
118122_variable_dependence (:: EmptyVariableModel ) = Traits. Fixed
119123_variable_dependence (:: AbstractVariableModel ) = Traits. NonFixed
120124
121- """
122- $(TYPEDSIGNATURES)
123-
124- Check whether the problem is control-free (no control input).
125-
126- # Arguments
127- - `ocp::Model`: The optimal control problem.
128-
129- # Returns
130- - `Bool`: `true` if the problem has no control input, `false` otherwise.
131-
132- See also: [`CTModels.Models.has_control`](@ref), [`CTModels.Models.control_dimension`](@ref).
133- """
134- function is_control_free (ocp:: Model ):: Bool
135- return control_dimension (ocp) == 0
136- end
125+ Traits. has_control_dependence_trait (:: Model ) = true
137126
138- """
139- $(TYPEDSIGNATURES)
140-
141- Check whether the problem has control input.
142-
143- # Arguments
144- - `ocp::Model`: The optimal control problem.
145-
146- # Returns
147- - `Bool`: `true` if the problem has control input, `false` otherwise.
148-
149- See also: [`CTModels.Models.is_control_free`](@ref).
150- """
151- has_control (ocp:: Model ):: Bool = ! is_control_free (ocp)
127+ Traits. control_dependence (ocp:: Model ) = _control_dependence (ocp. control)
128+ _control_dependence (:: EmptyControlModel ) = Traits. ControlFree
129+ _control_dependence (:: AbstractControlModel ) = Traits. WithControl
152130
153131"""
154132$(TYPEDSIGNATURES)
0 commit comments