@@ -54,11 +54,12 @@ function __constraint!(
5454 n:: Dimension ,
5555 m:: Dimension ,
5656 q:: Dimension ;
57- rg:: Union{OrdinalRange{<: Int},Nothing} = nothing ,
57+ rg:: Union{Int, OrdinalRange{Int},Nothing} = nothing ,
5858 f:: Union{Function,Nothing} = nothing ,
59- lb:: Union{ctVector,Nothing} = nothing ,
60- ub:: Union{ctVector,Nothing} = nothing ,
59+ lb:: Union{ctNumber, ctVector,Nothing} = nothing ,
60+ ub:: Union{ctNumber, ctVector,Nothing} = nothing ,
6161 label:: Symbol = __constraint_label (),
62+ codim_f:: Union{Dimension,Nothing} = nothing ,
6263)
6364
6465 # checkings: the constraint must not be set before
@@ -153,6 +154,14 @@ function __constraint!(
153154 end
154155
155156 (:: Nothing , :: Function , :: ctVector , :: ctVector ) => begin
157+ # ensure that codim_f has same length as lb if codim_f is not nothing
158+ if codim_f != = nothing
159+ @ensure (
160+ length (lb) == codim_f,
161+ CTBase. IncorrectArgument (" The length of `lb` and `ub` must match codim_f = $codim_f ." )
162+ )
163+ end
164+
156165 # set the constraint
157166 if type ∈ [:boundary , :path ]
158167 ocp_constraints[label] = (type, f, lb, ub)
@@ -203,6 +212,7 @@ function constraint!(
203212 lb:: Union{ctNumber,ctVector,Nothing} = nothing ,
204213 ub:: Union{ctNumber,ctVector,Nothing} = nothing ,
205214 label:: Symbol = __constraint_label (),
215+ codim_f:: Union{Dimension,Nothing} = nothing ,
206216)
207217
208218 # checkings: times, state and control must be set before adding constraints
@@ -238,6 +248,7 @@ function constraint!(
238248 lb= as_vector (lb),
239249 ub= as_vector (ub),
240250 label= label,
251+ codim_f= codim_f,
241252 )
242253end
243254
0 commit comments