Skip to content

Commit 639ed6a

Browse files
committed
fix: use symbolic indexing for solutions of pprobs
1 parent a818178 commit 639ed6a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

test/extensions/dynamic_optimization.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ const M = ModelingToolkit
6969
pprob = PyomoDynamicOptProblem(
7070
lksys, [u0map; parammap], tspan; guesses = guess, dt = 0.01)
7171
psol = solve(pprob, PyomoCollocation("ipopt", LagrangeLegendre(3)))
72-
@show psol.sol
73-
@test psol.sol(0.6)[1] 3.5
74-
@test psol.sol(0.3)[1] 7.0
72+
@test psol.sol(0.6; idxs = x(t)) 3.5
73+
@test psol.sol(0.3; idxs = x(t)) 7.0
7574

7675
iprob = InfiniteOptDynamicOptProblem(
7776
lksys, [u0map; parammap], tspan; guesses = guess, dt = 0.01)
@@ -161,7 +160,7 @@ end
161160
pprob = PyomoDynamicOptProblem(block, [u0map; parammap], tspan; dt = 0.01)
162161
psol = solve(pprob, PyomoCollocation("ipopt", BackwardEuler()))
163162
@test is_bangbang(psol.input_sol, [-1.0], [1.0])
164-
@test (psol.sol.u[end][2], 0.25, rtol = 1e-3)
163+
@test (psol.sol[x(t)][end], 0.25, rtol = 1e-3)
165164

166165
spline = ctrl_to_spline(isol.input_sol, ConstantInterpolation)
167166
oprob = ODEProblem(block_ode, [u0map; u_interp => spline], tspan)
@@ -251,7 +250,7 @@ end
251250

252251
pprob = PyomoDynamicOptProblem(rocket, [u0map; pmap], (ts, te); dt = 0.001, cse = false)
253252
psol = solve(pprob, PyomoCollocation("ipopt", LagrangeRadau(4)))
254-
@test psol.sol.u[end][1] > 1.012
253+
@test psol.sol[h(t)][end] > 1.012
255254

256255
# Test solution
257256
@parameters (T_interp::CubicSpline)(..)

0 commit comments

Comments
 (0)