@@ -542,13 +542,13 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
542542 info[:gc ] = LHS
543543 info[:sol ] = JuMP. solution_summary (mpc. optim, verbose= true )
544544 # --- objective derivatives ---
545- model, optim = mpc. estim. model, mpc. optim
545+ model, optim, con = mpc. estim. model, mpc. optim, mpc . con
546546 transcription = mpc. transcription
547547 nu, ny, nx̂, nϵ = model. nu, model. ny, mpc. estim. nx̂, mpc. nϵ
548548 nk = get_nk (model, transcription)
549549 Hp, Hc = mpc. Hp, mpc. Hc
550- ng = length (mpc . con. i_g)
551- nc, neq = mpc . con. nc, mpc . con. neq
550+ ng = length (con. i_g)
551+ nc, neq = con. nc, con. neq
552552 nU, nŶ, nX̂, nK = mpc. Hp* nu, Hp* ny, Hp* nx̂, Hp* nk
553553 nΔŨ, nUe, nŶe = nu* Hc + nϵ, nU + nu, nŶ + ny
554554 ΔŨ = zeros (NT, nΔŨ)
@@ -574,8 +574,8 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
574574 ∇J, ∇²J = gradient (J!, mpc. gradient, mpc. Z̃, J_cache... ), nothing
575575 end
576576 # --- inequality constraint derivatives ---
577- old_i_g = copy (mpc . con. i_g)
578- mpc . con. i_g .= 1 # temporarily set all constraints as finite so g is entirely computed
577+ old_i_g = copy (con. i_g)
578+ con. i_g .= 1 # temporarily set all constraints as finite so g is entirely computed
579579 ∇g_cache = (
580580 Cache (ΔŨ), Cache (x̂0end), Cache (Ue), Cache (Ŷe), Cache (U0), Cache (Ŷ0),
581581 Cache (Û0), Cache (K0), Cache (X̂0),
@@ -586,7 +586,7 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
586586 return nothing
587587 end
588588 ∇g = jacobian (g!, g, mpc. jacobian, mpc. Z̃, ∇g_cache... )
589- if ! isnothing (mpc. hessian)
589+ if ! isnothing (mpc. hessian) && any (con . i_g)
590590 function ℓ_g (Z̃, λ, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, geq, g)
591591 update_predictions! (ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃)
592592 return dot (λ, g)
@@ -603,7 +603,7 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
603603 else
604604 ∇²ℓg = nothing
605605 end
606- mpc . con. i_g .= old_i_g # restore original finite/infinite constraint indices
606+ con. i_g .= old_i_g # restore original finite/infinite constraint indices
607607 # --- equality constraint derivatives ---
608608 geq_cache = (
609609 Cache (ΔŨ), Cache (x̂0end), Cache (Ue), Cache (Ŷe), Cache (U0), Cache (Ŷ0),
@@ -615,7 +615,7 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
615615 return nothing
616616 end
617617 ∇geq = jacobian (geq!, geq, mpc. jacobian, mpc. Z̃, geq_cache... )
618- if ! isnothing (mpc. hessian)
618+ if ! isnothing (mpc. hessian) && con . neq > 0
619619 ∇²geq_cache = (
620620 Cache (ΔŨ), Cache (x̂0end), Cache (Ue), Cache (Ŷe), Cache (U0), Cache (Ŷ0),
621621 Cache (Û0), Cache (K0), Cache (X̂0),
0 commit comments