Skip to content

Commit d9a7442

Browse files
committed
check tests working
1 parent 2839e10 commit d9a7442

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

ext/MTKCasADiDynamicOptExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function init_model(sys, tspan, steps, u0map, pmap, u0; is_free_t = false)
115115
V = CasADi.variable!(opti, length(ctrls), steps)
116116
set_initial!(opti, U, DM(repeat(u0, 1, steps)))
117117
c0 = MTK.value.([pmap[c] for c in ctrls])
118-
set_initial!(opti, V, DM(repeat(c0, 1, steps)))
118+
!isempty(c0) && set_initial!(opti, V, DM(repeat(c0, 1, steps)))
119119

120120
U_interp = MXLinearInterpolation(U, tsteps, tsteps[2]-tsteps[1])
121121
V_interp = MXLinearInterpolation(V, tsteps, tsteps[2]-tsteps[1])
@@ -337,6 +337,7 @@ function DiffEqBase.solve(prob::CasADiDynamicOptProblem, solver::Union{String, S
337337
@unpack opti, U, V, tₛ = model
338338

339339
opti = add_solve_constraints(prob, tableau)
340+
silent && solver_options["print_level"] = 0
340341
solver!(opti, "$solver", plugin_options, solver_options)
341342

342343
failed = false

ext/MTKInfiniteOptExt.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ function add_jump_cost_function!(model::InfiniteModel, sys, tspan, pmap; is_free
173173
return
174174
end
175175
jcosts = substitute_jump_vars(model, sys, pmap, jcosts; is_free_t)
176-
@show jcosts
177176
tₛ = is_free_t ? model[:tf] : 1
178177

179178
# Substitute integral
@@ -338,7 +337,7 @@ Solve JuMPDynamicOptProblem. Arguments:
338337
Returns a DynamicOptSolution, which contains both the model and the ODE solution.
339338
"""
340339
function DiffEqBase.solve(
341-
prob::JuMPDynamicOptProblem, jump_solver, tableau_getter = constructDefault; silent = false)
340+
prob::JuMPDynamicOptProblem, jump_solver, tableau_getter = MTK.constructDefault; silent = false)
342341
model = prob.model
343342
tableau = tableau_getter()
344343
silent && set_silent(model)

test/downstream/dynamic_optimization.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ using CasADi
99

1010
const M = ModelingToolkit
1111

12-
probtypes = [JuMPDynamicOptProblem, InfiniteOptDynamicOptProblem, CasADiDynamicOptProblem]
13-
solvers = [Ipopt.Optimizer, Ipopt.Optimizer, "opti"]
14-
15-
function test_dynamic_opt_probs(tableaus, true_sol, args...; kwargs...)
16-
for (probtype, solver, tableau) in zip(probtypes, solvers tableaus)
17-
prob = probtype(args...; kwargs...)
18-
sol = solve(prob, solver, tableau, silent = true)
19-
end
20-
end
21-
2212
@testset "ODE Solution, no cost" begin
2313
# Test solving without anything attached.
2414
@parameters α=1.5 β=1.0 γ=3.0 δ=1.0
@@ -41,7 +31,7 @@ end
4131
oprob = ODEProblem(sys, u0map, tspan, parammap)
4232
osol = solve(oprob, SimpleRK4(), dt = 0.01)
4333
cprob = CasADiDynamicOptProblem(sys, u0map, tspan, parammap, dt = 0.01)
44-
csol = solve(oprob, "ipopt", constructRK4)
34+
csol = solve(cprob, "ipopt", constructRK4)
4535
@test jsol.sol.u osol.u
4636
@test csol.sol.u osol.u
4737

@@ -54,7 +44,7 @@ end
5444
isol = solve(iprob, Ipopt.Optimizer,
5545
derivative_method = InfiniteOpt.FiniteDifference(InfiniteOpt.Backward()),
5646
silent = true) # 11.540 ms, 4.00 MiB
57-
@test (isol2.sol.u, osol2.u, rtol = 0.001)
47+
@test (isol.sol.u, osol2.u, rtol = 0.001)
5848
csol2 = solve(cprob, "ipopt", constructImplicitEuler, silent = true)
5949
@test (csol2.sol.u, osol2.u, rtol = 0.001)
6050

0 commit comments

Comments
 (0)