diff --git a/src/model.jl b/src/model.jl index 259d70c7..75b654f9 100644 --- a/src/model.jl +++ b/src/model.jl @@ -655,12 +655,14 @@ function constraint!( ". Please choose in [ :initial, :final, :control, :state, :variable ] or check the arguments of the constraint! method.")) end ocp.constraints[label] = (type, fun_rg, lb, ub) - nothing # to force to return nothing end # _ => throw(IncorrectArgument("Provided arguments are inconsistent.")) end + # update constraints dimensions + __set_dim_constraints(ocp) + end """ @@ -805,6 +807,7 @@ function remove_constraint!(ocp::OptimalControlModel, label::Symbol) ". Please check the list of constraints: ocp.constraints.")) end delete!(ocp.constraints, label) + __set_dim_constraints(ocp) # update constraints dimensions nothing end @@ -1006,6 +1009,12 @@ function nlp_constraints(ocp::OptimalControlModel) end +# +function __set_dim_constraints(ocp::OptimalControlModel) + nlp_constraints(ocp) + nothing +end + # getters for constraints dimensions dim_control_constraints(ocp::OptimalControlModel) = ocp.dim_control_constraints dim_state_constraints(ocp::OptimalControlModel) = ocp.dim_state_constraints