Skip to content

Commit a812abc

Browse files
committed
debug: only keep oracle in setconstraint! for MHE
1 parent f33775a commit a812abc

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/controller/nonlinmpc.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,13 @@ function get_nonlinops(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT<:Real
774774
end
775775
return nothing
776776
end
777-
function gi_func!(gi_vec, Z̃_arg)
777+
function gi_func!(gi_arg, Z̃_arg)
778778
update_con!(gi, ∇gi, Z̃_∇gi, Z̃_arg)
779-
return gi_vec .= gi
779+
return gi_arg .= gi
780780
end
781-
function ∇gi_func!(∇gi_vec, Z̃_arg)
781+
function ∇gi_func!(∇gi_arg, Z̃_arg)
782782
update_con!(gi, ∇gi, Z̃_∇gi, Z̃_arg)
783-
return diffmat2vec!(∇gi_vec, ∇gi)
783+
return diffmat2vec!(∇gi_arg, ∇gi)
784784
end
785785
gi_min = fill(-myInf, ngi)
786786
gi_max = zeros(JNT, ngi)
@@ -813,13 +813,13 @@ function get_nonlinops(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT<:Real
813813
end
814814
return nothing
815815
end
816-
function geq_func!(geq_vec, Z̃_arg)
816+
function geq_func!(geq_arg, Z̃_arg)
817817
update_con_eq!(geq, ∇geq, Z̃_∇geq, Z̃_arg)
818-
return geq_vec .= geq
818+
return geq_arg .= geq
819819
end
820-
function ∇geq_func!(∇geq_vec, Z̃_arg)
820+
function ∇geq_func!(∇geq_arg, Z̃_arg)
821821
update_con_eq!(geq, ∇geq, Z̃_∇geq, Z̃_arg)
822-
return diffmat2vec!(∇geq_vec, ∇geq)
822+
return diffmat2vec!(∇geq_arg, ∇geq)
823823
end
824824
geq_min = geq_max = zeros(JNT, neq)
825825
∇geq_structure = init_diffstructure(∇geq)
@@ -844,25 +844,25 @@ function get_nonlinops(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT<:Real
844844
)
845845
∇J_prep = prepare_gradient(J!, grad, Z̃_∇J, ∇J_context...; strict)
846846
∇J = Vector{JNT}(undef, nZ̃)
847-
function update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
848-
if isdifferent(Z̃arg, Z̃_∇J)
849-
Z̃_∇J .= Z̃arg
847+
function update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
848+
if isdifferent(Z̃_arg, Z̃_∇J)
849+
Z̃_∇J .= Z̃_arg
850850
J[], _ = value_and_gradient!(J!, ∇J, ∇J_prep, grad, Z̃_∇J, ∇J_context...)
851851
end
852852
end
853-
function J_func(Z̃arg::Vararg{T, N}) where {N, T<:Real}
854-
update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
853+
function J_func(Z̃_arg::Vararg{T, N}) where {N, T<:Real}
854+
update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
855855
return J[]::T
856856
end
857857
∇J_func! = if nZ̃ == 1 # univariate syntax (see JuMP.@operator doc):
858-
function (Z̃arg)
859-
update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
858+
function (Z̃_arg)
859+
update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
860860
return ∇J[]
861861
end
862862
else # multivariate syntax (see JuMP.@operator doc):
863-
function (∇Jarg::AbstractVector{T}, Z̃arg::Vararg{T, N}) where {N, T<:Real}
864-
update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
865-
returnJarg .= ∇J
863+
function (∇J_arg::AbstractVector{T}, Z̃_arg::Vararg{T, N}) where {N, T<:Real}
864+
update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
865+
returnJ_arg .= ∇J
866866
end
867867
end
868868
return g_oracle, geq_oracle, J_func, ∇J_func!

src/estimator/mhe/construct.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ function setconstraint!(
709709
if JuMP.solver_name(optim) "Ipopt"
710710
set_nonlincon!(estim, model, optim)
711711
else
712-
g_oracle = get_nonlinops(estim, optim)
712+
g_oracle, = get_nonlinops(estim, optim)
713713
set_nonlincon_exp!(estim, model, g_oracle)
714714
end
715715
else
@@ -1521,25 +1521,25 @@ function get_nonlinops(
15211521
∇J_prep = prepare_gradient(J!, grad, Z̃_∇J, ∇J_context...; strict)
15221522
estim.Nk[] = 0
15231523
∇J = Vector{JNT}(undef, nZ̃)
1524-
function update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
1525-
if isdifferent(Z̃arg, Z̃_∇J)
1526-
Z̃_∇J .= Z̃arg
1524+
function update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
1525+
if isdifferent(Z̃_arg, Z̃_∇J)
1526+
Z̃_∇J .= Z̃_arg
15271527
J[], _ = value_and_gradient!(J!, ∇J, ∇J_prep, grad, Z̃_∇J, ∇J_context...)
15281528
end
15291529
end
1530-
function J_func(Z̃arg::Vararg{T, N}) where {N, T<:Real}
1531-
update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
1530+
function J_func(Z̃_arg::Vararg{T, N}) where {N, T<:Real}
1531+
update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
15321532
return J[]::T
15331533
end
15341534
∇J_func! = if nZ̃ == 1 # univariate syntax (see JuMP.@operator doc):
1535-
function (Z̃arg)
1536-
update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
1535+
function (Z̃_arg)
1536+
update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
15371537
return ∇J[]
15381538
end
15391539
else # multivariate syntax (see JuMP.@operator doc):
1540-
function (∇Jarg::AbstractVector{T}, Z̃arg::Vararg{T, N}) where {N, T<:Real}
1541-
update_objective!(J, ∇J, Z̃_∇J, Z̃arg)
1542-
returnJarg .= ∇J
1540+
function (∇J_arg::AbstractVector{T}, Z̃_arg::Vararg{T, N}) where {N, T<:Real}
1541+
update_objective!(J, ∇J, Z̃_∇J, Z̃_arg)
1542+
returnJ_arg .= ∇J
15431543
end
15441544
end
15451545
g_oracle, J_func, ∇J_func!

0 commit comments

Comments
 (0)