Skip to content

Commit

Permalink
add update constraints dim
Browse files Browse the repository at this point in the history
  • Loading branch information
ocots committed Jun 20, 2024
1 parent 15f5c25 commit 5a74f24
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 5a74f24

@jbcaillau
Copy link
Member

@jbcaillau jbcaillau commented on 5a74f24 Jun 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocots Looking into constraint! after this issue, just came across this unnoted commit adding __set_dim_constraints. I was about to blame innocent @BaptisteCbl but looks like you're the one 😱

#166

Please sign in to comment.