-
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
Preparing for inplace NLP #232
Comments
@jbcaillau To update: In model.jl5 possible nonlinear (= defined by functions, now inplace) constraints to treat, associated respectively with (type, f::BoundaryConstraint, lb, ub) && if type ∈ [:initial, :final, :boundary] end # ϕ
(:control, f::ControlConstraint, lb, ub) # ξ
(:state, f::StateConstraint, lb, ub) # η
(:mixed, f::MixedConstraint, lb, ub) # ψ
(:variable, f::VariableConstraint, lb, ub) # θ Also (see function constraint!(
ocp::OptimalControlModel{T, V},
type::Symbol;
rg::Union{OrdinalRange{<:Integer}, Index, Integer, Nothing}=nothing,
f::Union{Function, Nothing}=nothing,
lb::Union{ctVector, Nothing}=nothing,
ub::Union{ctVector, Nothing}=nothing,
val::Union{ctVector, Nothing}=nothing,
label::Symbol=__constraint_label()) where {T <: TimeDependence, V <: VariableDependence} Also: function constraint(ocp::OptimalControlModel{T, V}, label::Symbol) where {T <: TimeDependence, V <: VariableDependence} In onepass.jlp_constraint!(p, ocp, e1, e2, e3, label=gensym(); log=false) p_dynamics!(p, ocp, x, t, e, label=nothing; log=false) p_lagrange!(p, ocp, e, type; log=false) p_mayer!(p, ocp, e, type; log=false) p_bolza!(p, ocp, e1, e2, type; log=false) NB.
Misc
Type changes
Mayer_(ocp, f_::Function; variable::Bool = false) = is_in_place(ocp) ? Mayer!(f_; variable) : Mayer(f_; variable)
|
@PierreMartinon any preliminary comments?
|
@PierreMartinon back on this issue. on your side, ready for inplace in CTDirect.jl with trapezoidal scheme? Target above: #232 (comment) |
@ocots we'll need to be able to run tests like @def o begin
t ∈ [ 0, 1 ], time
x = [ r, v ] ∈ R², state
u ∈ R, control
w = r + 2v
r(0) == 0, (1)
v(0) == 1, (♡)
ẋ(t) == [ v(t), w(t)^2 ]
∫( u(t)^2 + x₁(t) ) → min
end
x = [ 1, 2 ]
x0 = 2 * x
xf = 3 * x
u = 3
@test constraint(o, :eq1)(x0, xf) == x0[1]
@test constraint(o, Symbol("♡"))(x0, xf) == x0[2]
@test o.dynamics(x, u) == [ x[2], (x[1] + 2x[2])^2 ]
@test o.lagrange(x, u) == u^2 + x[1] It is better not to rewrite test but to update the getters (such as |
CTBase.jl/src/optimal_control_model-getters.jl Lines 565 to 589 in 5db9d88
|
@ocots excellent. do think you could |
Hi guys, |
OK
Not sure that the question makes sense:
Same thing for (nonlinear) boundary conditions, BTW. Am I missing sth? |
@PierreMartinon meeting tomorrow (tuesday) 14:00 @ocots @joseph-gergaud welcome to join if you're around! |
@PierreMartinon Parametric type: struct TypeParamExample{T<:Number}
x::T
end and for a function: julia> function f(x::T, y::T) where {T <: Number}
return x + y
end
f (generic function with 1 method)
julia> f(1, 2)
3
julia> f(1, 2.0)
ERROR: MethodError: no method matching f(::Int64, ::Float64)
Closest candidates are:
f(::T, ::T) where T<:Number
@ Main REPL[5]:1
Stacktrace:
[1] top-level scope
@ REPL[7]:1 |
@jbcaillau |
@joseph-gergaud @PierreMartinon should be OK provided in place functions returned by |
|
@PierreMartinon catch-up this Monday 9/9 at 14:00 on zoom @ocots @joseph-gergaud welcome if you're around! |
@PierreMartinon closing this issue, in favour of #288 (please answer there!) |
@PierreMartinon aiming to providing inplace function as a result of
nlp_constraints!
, having inplace signatures forξ, η, ψ, ϕ, θ
:Related to: control-toolbox/CTDirect.jl#188
@ocots I'll need some help to update the unit tests.
The text was updated successfully, but these errors were encountered: