@@ -533,7 +533,7 @@ function init_optimization!(
533533 init_nonlincon! (mpc, model, transcription, gfuncs, ∇gfuncs!, geqfuncs, ∇geqfuncs!)
534534 set_nonlincon! (mpc, model, transcription, optim)
535535 else
536- # Test new experimental feature:
536+ # ========= Test new experimental feature ========================================
537537
538538 model = mpc. estim. model
539539 jac = mpc. jacobian
@@ -580,21 +580,23 @@ function init_optimization!(
580580 Z̃_∇g .= Z̃_arg
581581 value_and_jacobian! (gfunc!, g, ∇g, ∇g_prep, jac, Z̃_∇g, ∇g_context... )
582582 end
583+ return nothing
583584 end
584585 function gfunc_set! (g_arg, Z̃_arg)
585586 update_con! (g, ∇g, Z̃_∇g, Z̃_arg)
586- return g_arg .= g
587+ g_arg .= g
588+ return nothing
587589 end
588590 function ∇gfunc_set! (∇g_arg, Z̃_arg)
589591 update_con! (g, ∇g, Z̃_∇g, Z̃_arg)
590- return ∇g_arg .= nonzeros (∇g)
592+ diffmat2vec! (∇g_arg, ∇g)
593+ return nothing
591594 end
592595
593596 g_min = fill (- myInf, ng)
594597 g_max = fill (+ myInf, ng)
595598
596- I_∇g, J_∇g = SparseArrays. findnz (∇g)
597- ∇g_structure = collect (zip (I_∇g, J_∇g))
599+ ∇g_structure = init_diffstructure (∇g)
598600
599601 g_set = Ipopt. _VectorNonlinearOracle (;
600602 dimension = nZ̃,
@@ -606,10 +608,6 @@ function init_optimization!(
606608 )
607609 @constraint (optim, Z̃var in g_set)
608610
609-
610-
611-
612-
613611 function geqfunc! (geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g)
614612 update_predictions! (ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃)
615613 return nothing
@@ -629,21 +627,23 @@ function init_optimization!(
629627 Z̃_∇geq .= Z̃_arg
630628 value_and_jacobian! (geqfunc!, geq, ∇geq, ∇geq_prep, jac, Z̃_∇geq, ∇geq_context... )
631629 end
630+ return nothing
632631 end
633632 function geqfunc_set! (geq_arg, Z̃_arg)
634633 update_con_eq! (geq, ∇geq, Z̃_∇geq, Z̃_arg)
635- return geq_arg .= geq
634+ geq_arg .= geq
635+ return nothing
636636 end
637637 function ∇geqfunc_set! (∇geq_arg, Z̃_arg)
638638 update_con_eq! (geq, ∇geq, Z̃_∇geq, Z̃_arg)
639- return ∇geq_arg .= nonzeros (∇geq)
639+ diffmat2vec! (∇geq_arg, ∇geq)
640+ return nothing
640641 end
641642
642643 geq_min = zeros (JNT, mpc. con. neq)
643644 geq_max = zeros (JNT, mpc. con. neq)
644645
645- I_∇geq, J_∇geq = SparseArrays. findnz (∇geq)
646- ∇geq_structure = collect (zip (I_∇geq, J_∇geq))
646+ ∇geq_structure = init_diffstructure (∇geq)
647647
648648 #=
649649 # Langragian of the optimization problem:
0 commit comments