-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Box constraints for the direct method & more #4
Comments
Doing, on this base (see this issue in the last sprint):
|
Updates are in order for the NLP construction as
Testing whether there is a range of a function allows to decide whether the constraint is linear (a box) or not when constructing the NLP model. NB. The current version of the code factorises several kind of constraints which is hard to maintain / update 😬 |
@PierreMartinon @joseph-gergaud any idea of the format you would like to retrieve box constraints on state and control
|
@PierreMartinon @joseph-gergaud
Check this commit. Should be ready for
|
@ocots Some minor changes in
Check this commit |
At this line, we have function constraint!(ocp::OptimalControlModel, type::Symbol, lb::Real, ub::Real, label::Symbol=gensym(:anonymous))
if type ∈ [ :initial, :final ]
ocp.constraints[label] = (type, :ineq, x -> x, ub, lb)
elseif type ∈ [ :control, :state ]
ocp.constraints[label] = (type, :ineq, 1:state_dimension(ocp), ub, lb)
else
throw(IncorrectArgument("the following type of constraint is not valid: " * String(type) *
". Please choose in [ :initial, :final ] or check the arguments of the constraint! method."))
end
end Isn't? function constraint!(ocp::OptimalControlModel, type::Symbol, lb::Real, ub::Real, label::Symbol=gensym(:anonymous))
if type ∈ [ :initial, :final ]
ocp.constraints[label] = (type, :ineq, x -> x, ub, lb)
elseif type ∈ [ :control]
ocp.constraints[label] = (type, :ineq, 1:control_dimension(ocp), ub, lb)
elseif type ∈ [ :state ]
ocp.constraints[label] = (type, :ineq, 1:state_dimension(ocp), ub, lb)
else
throw(IncorrectArgument("the following type of constraint is not valid: " * String(type) *
". Please choose in [ :initial, :final ] or check the arguments of the constraint! method."))
end
end |
Indeed! fixed 🙏🏽 |
I'll start integrating the box constraints in the direct part next week ! |
Je voulais aussi m'y remettre la semaine prochaine. On pourrait travaille ensemble comme à Nice (voir mes dispo en pièce jointe). |
Oui ! Je suis libre sauf vendredi, donc je pourrais passer mercredi ?
(lundi et mardi ont l'air un peu pris)
Pierre
…On 10-Mar-23 10:15, joseph-gergaud wrote:
Je voulais aussi m'y remettre la semaine prochaine. On pourrait
travaille ensemble comme à Nice (voir mes dispo en pièce jointe).
Calendrier — semaine — de 12:03:2023 à 18:03:2023.pdf
<https://github.com/control-toolbox/CTBase.jl/files/10940445/Calendrier.semaine.de.12.03.2023.a.18.03.2023.pdf>
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AECBGHMANWSISSUMPZA5DG3W3LWJ7ANCNFSM6AAAAAAVVU36Y4>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Pierre,
On dit mercredi à 9h00 dans mon bureau ?
Joseph
… Le 10 mars 2023 à 12:14, Pierre Martinon ***@***.***> a écrit :
Oui ! Je suis libre sauf vendredi, donc je pourrais passer mercredi ?
(lundi et mardi ont l'air un peu pris)
Pierre
On 10-Mar-23 10:15, joseph-gergaud wrote:
>
> Je voulais aussi m'y remettre la semaine prochaine. On pourrait
> travaille ensemble comme à Nice (voir mes dispo en pièce jointe).
>
> Calendrier — semaine — de 12:03:2023 à 18:03:2023.pdf
> <https://github.com/control-toolbox/CTBase.jl/files/10940445/Calendrier.semaine.de.12.03.2023.a.18.03.2023.pdf>
>
> —
> Reply to this email directly, view it on GitHub
> <#4 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AECBGHMANWSISSUMPZA5DG3W3LWJ7ANCNFSM6AAAAAAVVU36Y4>.
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub <#4 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJC65POOIHY4I5AGSJQAYV3W3MEINANCNFSM6AAAAAAVVU36Y4>.
You are receiving this because you were mentioned.
|
Of course, before integrating the changes from |
@ocots Looks like these functions are only used in the test: correct? With the additional type of constraints, these computations must be updated (and might not completely make sense: case of inequalities...) My first guess would be to suppress them ☠️. function initial_condition(ocp::OptimalControlModel)
function final_condition(ocp::OptimalControlModel)
function initial_constraint(ocp::OptimalControlModel)
function final_constraint(ocp::OptimalControlModel) Note that labelled constraint can be retrieved: constraint!(ocp, :initial, x0, :eq1)
x -> constraint(ocp, :eq1) - x0 === x -> x - x0
constraint!(ocp, :initial, 3:5, y0, :eq2)
x -> constraint(ocp, :eq2) - y0 === x -> x[3:5] - y0 etc. |
@ocots At least used in
|
The functions function parse_ocp_direct_shooting(ocp::OptimalControlModel)
# parsing ocp
dy = dynamics(ocp)
co = lagrange(ocp)
cf = final_constraint(ocp)
x0 = initial_condition(ocp)
n = state_dimension(ocp)
m = control_dimension(ocp)
return dy, co, cf, x0, n, m
end This function Remark. The functions # check validity
ξ, ψ, ϕ = nlp_constraints(ocp)
dim_ξ = length(ξ[1]) # dimension of the boundary constraints
dim_ψ = length(ψ[1])
if dim_ξ != 0 && dim_ψ != 0
error("direct shooting is implemented for problems without constraints")
end |
@ocots OK I if simply move the two functions |
We can write the functions here to keep them in mind and you can remove them from function initial_condition(ocp::OptimalControlModel)
cs = constraints(ocp)
x0 = nothing
for (_, c) ∈ cs
type, _, _, val = c
if type == :initial
x0 = val
end
end
return x0
end
function final_condition(ocp::OptimalControlModel)
cs = constraints(ocp)
xf = nothing
for (_, c) ∈ cs
type, _, _, val = c
if type == :final
xf = val
end
end
return xf
end
function initial_constraint(ocp::OptimalControlModel)
cs = constraints(ocp)
c0 = nothing
for (_, c) ∈ cs
type, _, f, val = c
if type == :initial
c0 = x -> f(x) - val
end
end
return c0
end
function final_constraint(ocp::OptimalControlModel)
cs = constraints(ocp)
cf = nothing
for (_, c) ∈ cs
type, _, f, val = c
if type == :final
cf = x -> f(x) - val
end
end
return cf
end |
@jbcaillau Concerning your question about the boxes at t0 / tf and all t, there is no distinction in the NLP: the time grid includes t0 and tf so there is only boxes 'for all t' and no specific boxes for t0/tf (there are however the generic boundary conditions at t0/tf) For the format, the triple (LB,IND,UB) could be a triple of flattened values or use vectors of vectors. Flat format: (no need for ordering)
Nested format:
Either form works for us. |
@jbcaillau Not sure that this should be a |
OK: we can
|
For me it was ok to give a vector of the same size as the range. Still, the most important for @PierreMartinon and @joseph-gergaud is just in which format we give them the constraints, via Remark. the name |
Flat non-ordered is ok for us.
|
@PierreMartinon @joseph-gergaud For the record:
|
@ocots tests passed in branch
|
I will handle |
@ocots Cannot see the review...?
|
You should see comments directly in the PR: #10 |
@ocots @joseph-gergaud @PierreMartinon OK for a meeting next Thursday (30/3)? /polls "10:00" "15:00" "17:00" |
Any time. |
good. installed this poll app, does not seem to work 💩 |
I didn't move it but you have something similar here:
I will replace these pieces of code (piece of codes / piece of code) when I will have something good. |
Test: /polls Option1 'Option 2' "Option 3" |
Maybe poll is only in the description of a new issue. |
Pas de contrainte pour moi
…On 27-Mar-23 14:06, Jean-Baptiste Caillau wrote:
@PierreMartinon <https://github.com/PierreMartinon> @joseph-gergaud
<https://github.com/joseph-gergaud> #4 (comment)
<#4 (comment)>
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AECBGHNS4ET3IO3XJ233Z63W6F7DLANCNFSM6AAAAAAVVU36Y4>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
C'est ok pour moi jeudi à 10h00 |
@ocots @PierreMartinon @joseph-gergaud 10:00 it is, this Thursday |
The constraints have to be added in the
CTBase
package. Then, it will be possible to update theCTDirect
package.Remarks.
ipopt
solver is more efficient if the box constraints are taken into account.The text was updated successfully, but these errors were encountered: