@@ -573,12 +573,6 @@ 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- nonlincon = optim[:nonlinconstraint ]
577- nonlinconeq = optim[:nonlinconstrainteq ]
578- λ, λeq = JuMP. dual .(nonlincon), JuMP. dual .(nonlinconeq)
579- display (λ)
580- display (λeq)
581-
582576 ∇g_cache = (
583577 Cache (ΔŨ), Cache (x̂0end), Cache (Ue), Cache (Ŷe), Cache (U0), Cache (Ŷ0),
584578 Cache (Û0), Cache (K0), Cache (X̂0),
@@ -589,7 +583,6 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
589583 return nothing
590584 end
591585 ∇g = jacobian (g!, g, mpc. jacobian, mpc. Z̃, ∇g_cache... )
592- #=
593586 if ! isnothing (mpc. hessian)
594587 function ℓ_g (Z̃, λ, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, geq, g)
595588 update_predictions! (ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃)
@@ -600,11 +593,13 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
600593 Cache (Û0), Cache (K0), Cache (X̂0),
601594 Cache (gc), Cache (geq), Cache (g)
602595 )
596+ nonlincon = optim[:nonlinconstraint ]
597+ λ = JuMP. dual .(nonlincon) # FIXME : does not work for now
598+ λ = ones (NT, ng)
603599 ∇²ℓg = hessian (ℓ_g, mpc. hessian, mpc. Z̃, Constant (λ), ∇²g_cache... )
604600 else
605601 ∇²ℓg = nothing
606602 end
607- =# ∇²ℓg = nothing # TODO : delete this line when enabling the above block
608603 geq_cache = (
609604 Cache (ΔŨ), Cache (x̂0end), Cache (Ue), Cache (Ŷe), Cache (U0), Cache (Ŷ0),
610605 Cache (Û0), Cache (K0), Cache (X̂0),
@@ -615,9 +610,23 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
615610 return nothing
616611 end
617612 ∇geq = jacobian (geq!, geq, mpc. jacobian, mpc. Z̃, geq_cache... )
618- ∇²ℓgeq = nothing # TODO : implement later
619-
620-
613+ if ! isnothing (mpc. hessian)
614+ ∇²geq_cache = (
615+ Cache (ΔŨ), Cache (x̂0end), Cache (Ue), Cache (Ŷe), Cache (U0), Cache (Ŷ0),
616+ Cache (Û0), Cache (K0), Cache (X̂0),
617+ Cache (gc), Cache (geq), Cache (g)
618+ )
619+ function ℓ_geq (Z̃, λeq, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, geq, g)
620+ update_predictions! (ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃)
621+ return dot (λeq, geq)
622+ end
623+ nonlinconeq = optim[:nonlinconstrainteq ]
624+ λeq = JuMP. dual .(nonlinconeq) # FIXME : does not work for now
625+ λeq = ones (NT, neq)
626+ ∇²ℓgeq = hessian (ℓ_geq, mpc. hessian, mpc. Z̃, Constant (λeq), ∇²geq_cache... )
627+ else
628+ ∇²ℓgeq = nothing
629+ end
621630 info[:∇J ] = ∇J
622631 info[:∇²J ] = ∇²J
623632 info[:∇g ] = ∇g
0 commit comments