Skip to content

Commit 51137f9

Browse files
committed
debug test
1 parent 5989091 commit 51137f9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/test_predictive_control.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,10 @@ end
389389
nmpc7 = NonLinMPC(nonlinmodel, Hp=15, Ewt=1e-3, JE=(UE,ŶE,D̂E) -> UE.*ŶE.*D̂E)
390390
@test nmpc7.E == 1e-3
391391
@test nmpc7.JE([1,2],[3,4],[4,6]) == [12, 48]
392-
nmpc8 = NonLinMPC(nonlinmodel, Hp=15, optim=JuMP.Model(OSQP.MathOptInterfaceOSQP.Optimizer))
393-
@test solver_name(nmpc8.optim) == "OSQP"
392+
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "nlp_scaling_max_gradient"=>1.0))
393+
nmpc8 = NonLinMPC(nonlinmodel, Hp=15, optim=optim)
394+
@test solver_name(nmpc8.optim) == "Ipopt"
395+
@test get_attribute(nmpc8.optim, "nlp_scaling_max_gradient") == 1.0
394396
im = InternalModel(nonlinmodel)
395397
nmpc9 = NonLinMPC(im, Hp=15)
396398
@test isa(nmpc9.estim, InternalModel)
@@ -455,11 +457,12 @@ end
455457
nmpc4 = NonLinMPC(nonlinmodel, Hp=15, Mwt=[0], Nwt=[0], Lwt=[1])
456458
u = moveinput!(nmpc4, [0], d, R̂u=fill(12, nmpc4.Hp))
457459
@test u [12] atol=5e-2
458-
nmpc5 = setconstraint!(NonLinMPC(nonlinmodel, Hp=15, Cwt=Inf), ymax=[1])
459-
g_Ymax_end = nmpc5.optim.nlp_model.operators.registered_multivariate_operators[end].f
460-
@test g_Ymax_end((1.0, 1.0)) 0.0 # test gfunc_i(i,::NTuple{N, Float64})
460+
nmpc5 = setconstraint!(NonLinMPC(nonlinmodel, Hp=15, Cwt=Inf), ymin=[1])
461+
g_Ymin_end = nmpc5.optim[:g_Ymin_15].func
462+
# test gfunc_i(i,::NTuple{N, Float64}):
463+
@test g_Ymin_end(20.0, 10.0) 0.0
461464
# test gfunc_i(i,::NTuple{N, ForwardDiff.Dual}) :
462-
@test ForwardDiff.gradient(g_Ymax_end, [1.0, 1.0]) [0.0, 0.0]
465+
@test ForwardDiff.gradient(vec->g_Ymin_end(vec...), [20.0, 10.0]) [-5, -5] atol=1e-3
463466
linmodel3 = LinModel{Float32}(0.5*ones(1,1), ones(1,1), ones(1,1), zeros(1,0), zeros(1,0), 1.0)
464467
nmpc6 = NonLinMPC(linmodel3, Hp=10)
465468
moveinput!(nmpc6, [0]) [0.0]

0 commit comments

Comments
 (0)