@@ -26,11 +26,11 @@ struct Euler <: Discretization
2626
2727 # NLP variables size ([state, control]_1..N, final state, variable)
2828 dim_NLP_variables = dim_NLP_steps * step_variables_block + dim_NLP_x + dim_NLP_v
29-
29+
3030 # NLP constraints size ([dynamics, path]_1..N, final path, boundary, variable)
3131 dim_NLP_constraints = dim_NLP_steps * (state_stage_eqs_block + step_pathcons_block) + step_pathcons_block + dim_boundary_cons
3232
33- if explicit
33+ if explicit
3434 info = " Euler (explicit), 1st order"
3535 else
3636 info = " Euler (implicit), 1st order"
@@ -54,12 +54,12 @@ function get_OCP_control_at_time_step(xu, docp::DOCP{Euler}, i)
5454 # final time case
5555 (i == docp. time. steps + 1 ) && (i = docp. time. steps)
5656 offset = (i- 1 ) * docp. discretization. _step_variables_block + docp. dims. NLP_x
57- else
57+ else
5858 # initial time case
5959 (i == 1 ) && (i = 2 )
6060 offset = (i- 2 ) * docp. discretization. _step_variables_block + docp. dims. NLP_x
6161 end
62- return @view xu[(offset + 1 ): (offset + docp. dims. NLP_u)]
62+ return @view xu[(offset+ 1 ): (offset+ docp. dims. NLP_u)]
6363end
6464
6565
@@ -87,11 +87,11 @@ function setWorkArray(docp::DOCP{Euler}, xu, time_grid, v)
8787 u = get_OCP_control_at_time_step (xu, docp, index)
8888
8989 # OCP dynamics
90- CTModels. dynamics (docp. ocp)((@view work[offset+ 1 : offset+ docp. dims. OCP_x]), t, x, u, v)
90+ CTModels. dynamics (docp. ocp)((@view work[( offset+ 1 ) : ( offset+ docp. dims. OCP_x) ]), t, x, u, v)
9191 # lagrange cost
9292 if docp. flags. lagrange
9393 work[offset+ docp. dims. NLP_x] = CTModels. lagrange (docp. ocp)(t, x, u, v)
94- end
94+ end
9595 end
9696 return work
9797end
@@ -104,7 +104,7 @@ Set the constraints corresponding to the state equation
104104Convention: 1 <= i <= dim_NLP_steps+1
105105"""
106106function setStepConstraints! (docp:: DOCP{Euler} , c, xu, v, time_grid, i, work)
107-
107+
108108 # offset for previous steps
109109 offset = (i- 1 )* (docp. discretization. _state_stage_eqs_block + docp. discretization. _step_pathcons_block)
110110
@@ -121,20 +121,20 @@ function setStepConstraints!(docp::DOCP{Euler}, c, xu, v, time_grid, i, work)
121121 offset_dyn_i = (i- 1 )* docp. dims. NLP_x
122122
123123 # state equation: euler rule
124- @views @. c[offset+ 1 : offset+ docp. dims. OCP_x] = xip1 - (xi + hi * work[offset_dyn_i+ 1 : offset_dyn_i+ docp. dims. OCP_x])
124+ @views @. c[( offset+ 1 ) : ( offset+ docp. dims. OCP_x) ] = xip1 - (xi + hi * work[( offset_dyn_i+ 1 ) : ( offset_dyn_i+ docp. dims. OCP_x) ])
125125 if docp. flags. lagrange
126126 c[offset+ docp. dims. NLP_x] = get_lagrange_state_at_time_step (xu, docp, i+ 1 ) - (get_lagrange_state_at_time_step (xu, docp, i) + hi * work[offset_dyn_i+ docp. dims. NLP_x])
127127 end
128128 offset += docp. dims. NLP_x
129129
130130 end
131-
131+
132132 # 2. path constraints
133133 if docp. discretization. _step_pathcons_block > 0
134134 ui = get_OCP_control_at_time_step (xu, docp, i)
135- CTModels. path_constraints_nl (docp. ocp)[2 ]((@view c[offset+ 1 : offset+ docp. dims. path_cons]), ti, xi, ui, v)
135+ CTModels. path_constraints_nl (docp. ocp)[2 ]((@view c[( offset+ 1 ) : ( offset+ docp. dims. path_cons) ]), ti, xi, ui, v)
136136 end
137-
137+
138138end
139139
140140
@@ -213,7 +213,7 @@ function DOCP_Jacobian_pattern(docp::DOCP{Euler})
213213 uf_start = var_offset- docp. discretization. _step_variables_block + docp. dims. NLP_x + 1
214214 uf_end = var_offset- docp. discretization. _step_variables_block + docp. dims. NLP_x + docp. dims. NLP_u
215215 add_nonzero_block! (Is, Js, c_offset+ 1 , c_offset+ c_block, xf_start, xf_end)
216- add_nonzero_block! (Is, Js, c_offset+ 1 ,c_offset+ c_block, uf_start, uf_end)
216+ add_nonzero_block! (Is, Js, c_offset+ 1 , c_offset+ c_block, uf_start, uf_end)
217217 add_nonzero_block! (Is, Js, c_offset+ 1 , c_offset+ c_block, v_start, v_end)
218218
219219 # 3. boundary constraints (x0, xf, v)
@@ -258,7 +258,7 @@ function DOCP_Hessian_pattern(docp::DOCP{Euler})
258258 # -> grouped with term 3. for boundary conditions
259259 # 0.2 lagrange case (lf)
260260 # -> 2nd order term is zero
261-
261+
262262 # 1. main loop over steps
263263 # 1.0 v / v term
264264 add_nonzero_block! (Is, Js, v_start, v_end, v_start, v_end)
@@ -317,7 +317,7 @@ function DOCP_Hessian_pattern(docp::DOCP{Euler})
317317
318318 # 3.1 null initial condition for lagrangian cost state l0
319319 # -> 2nd order term is zero
320-
320+
321321 # build and return sparse matrix
322322 nnzj = length (Is)
323323 Vs = ones (Bool, nnzj)
0 commit comments