Skip to content

Commit 4492c83

Browse files
committed
changed: using stored nonlinear constraints in getinfo
1 parent 00341a1 commit 4492c83

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/controller/nonlinmpc.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,9 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
573573
else
574574
∇J, ∇²J = gradient(J!, mpc.gradient, mpc.Z̃, J_cache...), nothing
575575
end
576-
JNT = typeof(optim).parameters[1]
577-
nonlin_constraints = JuMP.all_constraints(
578-
optim, JuMP.Vector{JuMP.VariableRef}, MOI.VectorNonlinearOracle{JNT}
579-
)
580-
g_con, geq_con = nonlin_constraints
581-
display(g_con)
582-
display(geq_con)
583-
λ, λeq = JuMP.dual.(g_con), JuMP.dual.(geq_con)
584-
println(JuMP.dual.(JuMP.FixBoundRef.(optim[:Z̃var])))
576+
nonlincon = optim[:nonlinconstraint]
577+
nonlinconeq = optim[:nonlinconstrainteq]
578+
λ, λeq = JuMP.dual.(nonlincon), JuMP.dual.(nonlinconeq)
585579
display(λ)
586580
display(λeq)
587581

src/estimator/mhe/execute.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,10 @@ function addinfo!(
201201
else
202202
∇J, ∇²J = gradient(J!, estim.gradient, estim.Z̃, J_cache...), nothing
203203
end
204-
JNT = typeof(optim).parameters[1]
205-
nonlin_constraints = JuMP.all_constraints(
206-
optim, JuMP.Vector{JuMP.VariableRef}, MOI.VectorNonlinearOracle{JNT}
207-
)
208-
g_con = nonlin_constraints[1]
209-
λ = JuMP.dual.(g_con)
204+
nonlincon = optim[:nonlinconstraint]
205+
λ = JuMP.dual.(nonlincon)
210206
display(λ)
207+
211208
∇g_cache = (Cache(V̂), Cache(X̂0), Cache(û0), Cache(k0), Cache(ŷ0))
212209
function g!(g, Z̃, V̂, X̂0, û0, k0, ŷ0)
213210
update_prediction!(V̂, X̂0, û0, k0, ŷ0, g, estim, Z̃)

0 commit comments

Comments
 (0)