Skip to content

Commit fd1f7b9

Browse files
committed
debug: JE default values with p arg
1 parent 2a7f0f2 commit fd1f7b9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/controller/nonlinmpc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function NonLinMPC(
204204
L_Hp = diagm(repeat(Lwt, Hp)),
205205
Cwt = DEFAULT_CWT,
206206
Ewt = DEFAULT_EWT,
207-
JE::Function = (_,_,_) -> 0.0,
207+
JE::Function = (_,_,_,_) -> 0.0,
208208
p = model.p,
209209
optim::JuMP.GenericModel = JuMP.Model(DEFAULT_NONLINMPC_OPTIMIZER, add_bridges=false),
210210
kwargs...
@@ -270,7 +270,7 @@ function NonLinMPC(
270270
L_Hp = diagm(repeat(Lwt, Hp)),
271271
Cwt = DEFAULT_CWT,
272272
Ewt = DEFAULT_EWT,
273-
JE::JEFunc = (_,_,_) -> 0.0,
273+
JE::JEFunc = (_,_,_,_) -> 0.0,
274274
p::P = estim.model.p,
275275
optim::JM = JuMP.Model(DEFAULT_NONLINMPC_OPTIMIZER, add_bridges=false),
276276
) where {NT<:Real, SE<:StateEstimator{NT}, JM<:JuMP.GenericModel, JEFunc<:Function, P<:Any}

test/test_predictive_control.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ end
493493
@test nmpc6.L_Hp Diagonal(diagm(repeat(Float64[0, 1], 15)))
494494
nmpc7 = NonLinMPC(nonlinmodel, Hp=15, Ewt=1e-3, JE=(UE,ŶE,D̂E,p) -> p*UE.*ŶE.*D̂E, p=2)
495495
@test nmpc7.E == 1e-3
496-
@test nmpc7.JE([1,2],[3,4],[4,6],2) == 2*[1,2].*[3.4].*[4,6]
496+
@test nmpc7.JE([1,2],[3,4],[4,6],2) == 2*[1,2].*[3,4].*[4,6]
497497
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "nlp_scaling_max_gradient"=>1.0))
498498
nmpc8 = NonLinMPC(nonlinmodel, Hp=15, optim=optim)
499499
@test solver_name(nmpc8.optim) == "Ipopt"
@@ -537,8 +537,8 @@ end
537537
@test info[:Ŷ][end] r[1] atol=5e-2
538538
Hp = 1000
539539
R̂y = fill(r[1], Hp)
540-
JE = (_ , ŶE, _ ) -> sum((ŶE[2:end] - R̂y).^2)
541-
nmpc = NonLinMPC(linmodel, Mwt=[0], Nwt=[0], Cwt=Inf, Ewt=1, JE=JE, Hp=Hp, Hc=1)
540+
JE = (_ , ŶE, _ , R̂y) -> sum((ŶE[2:end] - R̂y).^2)
541+
nmpc = NonLinMPC(linmodel, Mwt=[0], Nwt=[0], Cwt=Inf, Ewt=1, JE=JE, p=R̂y, Hp=Hp, Hc=1)
542542
preparestate!(nmpc, [10])
543543
u = moveinput!(nmpc)
544544
@test u [1] atol=5e-2

0 commit comments

Comments
 (0)