Skip to content

Commit b67af59

Browse files
committed
debug: correct index for d̂0
1 parent f354040 commit b67af59

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/controller/transcription.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,21 +1336,23 @@ function con_nonlinprogeq!(
13361336
nΔU, nX̂ = nu*Hc, nx̂*Hp
13371337
D̂0 = mpc.D̂0
13381338
X̂0_Z̃ = @views Z̃[(nΔU+1):(nΔU+nX̂)]
1339-
x̂0 = @views mpc.estim.x̂0[1:nx̂]
1340-
d0 = @views mpc.d0[1:nd]
1341-
#TODO: allow parallel for loop or threads?
1342-
for j=1:Hp
1339+
Threads.@threads for j=1:Hp
1340+
#for j=1:Hp
1341+
if j < 2
1342+
x̂0 = @views mpc.estim.x̂0[1:nx̂]
1343+
d̂0 = @views mpc.d0[1:nd]
1344+
else
1345+
x̂0 = @views X̂0_Z̃[(1 + nx̂*(j-2)):(nx̂*(j-1))]
1346+
d̂0 = @views D̂0[(1 + nd*(j-2)):(nd*(j-1))]
1347+
end
13431348
u0 = @views U0[(1 + nu*(j-1)):(nu*j)]
13441349
û0 = @views Û0[(1 + nu*(j-1)):(nu*j)]
13451350
k0 = @views K0[(1 + nk*(j-1)):(nk*j)]
1346-
d0next = @views D̂0[(1 + nd*(j-1)):(nd*j)]
13471351
x̂0next = @views X̂0[(1 + nx̂*(j-1)):(nx̂*j)]
13481352
x̂0next_Z̃ = @views X̂0_Z̃[(1 + nx̂*(j-1)):(nx̂*j)]
13491353
ŝnext = @views geq[(1 + nx̂*(j-1)):(nx̂*j)]
1350-
f̂!(x̂0next, û0, k0, mpc.estim, model, x̂0, u0, d0)
1354+
f̂!(x̂0next, û0, k0, mpc.estim, model, x̂0, u0, d̂0)
13511355
ŝnext .= x̂0next .- x̂0next_Z̃
1352-
x̂0 = x̂0next_Z̃ # using states in Z̃ for next iteration (allow parallel for)
1353-
d0 = d0next
13541356
end
13551357
return geq
13561358
end

0 commit comments

Comments
 (0)