Skip to content

Commit

Permalink
blacked
Browse files Browse the repository at this point in the history
  • Loading branch information
EveCharbie committed Jul 17, 2023
1 parent e45bc11 commit 7ef44d4
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions bioptim/interfaces/acados_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,14 +593,33 @@ def add_nonlinear_ls_mayer(acados, objectives, x, u, p, s, node=None):

if J.type.get_type() == ObjectiveFunction.LagrangeFunction:
add_nonlinear_ls_lagrange(
self, J, nlp.states.cx_start, nlp.controls.cx_start, nlp.parameters.cx, nlp.stochastic_variables.cx_start
self,
J,
nlp.states.cx_start,
nlp.controls.cx_start,
nlp.parameters.cx,
nlp.stochastic_variables.cx_start,
)

# Deal with first and last node
add_nonlinear_ls_mayer(self, J, nlp.states.cx_start, nlp.controls.cx_start, nlp.parameters.cx, nlp.stochastic_variables.cx_start)
add_nonlinear_ls_mayer(
self,
J,
nlp.states.cx_start,
nlp.controls.cx_start,
nlp.parameters.cx,
nlp.stochastic_variables.cx_start,
)

elif J.type.get_type() == ObjectiveFunction.MayerFunction:
add_nonlinear_ls_mayer(self, J, nlp.states.cx_start, nlp.controls.cx_start, nlp.parameters.cx, nlp.stochastic_variables.cx_start)
add_nonlinear_ls_mayer(
self,
J,
nlp.states.cx_start,
nlp.controls.cx_start,
nlp.parameters.cx,
nlp.stochastic_variables.cx_start,
)
else:
raise RuntimeError("The objective function is not Lagrange nor Mayer.")

Expand All @@ -610,7 +629,14 @@ def add_nonlinear_ls_mayer(acados, objectives, x, u, p, s, node=None):
nlp = ocp.nlp[0] # Assume 1 phase
for j, J in enumerate(ocp.J):
J.node = [Node.END]
add_nonlinear_ls_mayer(self, J, nlp.states.cx_start, nlp.controls.cx_start, nlp.parameters.cx, nlp.stochastic_variables.cx_start)
add_nonlinear_ls_mayer(
self,
J,
nlp.states.cx_start,
nlp.controls.cx_start,
nlp.parameters.cx,
nlp.stochastic_variables.cx_start,
)

# Set costs
self.acados_ocp.model.cost_y_expr = (
Expand Down

0 comments on commit 7ef44d4

Please sign in to comment.