Skip to content

Commit

Permalink
Allow the user to not expand the dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipuch authored and pariterre committed Apr 4, 2022
1 parent 0a86e9a commit 2f86098
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bioptim/dynamics/configure_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def muscle_driven(
ConfigureProblem.configure_soft_contact_function(ocp, nlp)

@staticmethod
def configure_dynamics_function(ocp, nlp, dyn_func, **extra_params):
def configure_dynamics_function(ocp, nlp, dyn_func, expand: bool = True, **extra_params):
"""
Configure the dynamics of the system
Expand All @@ -352,6 +352,8 @@ def configure_dynamics_function(ocp, nlp, dyn_func, **extra_params):
A reference to the phase
dyn_func: Callable[states, controls, param]
The function to get the derivative of the states
expand: bool
If the dynamics should be expanded with casadi
"""

nlp.parameters = ocp.v.parameters_in_list
Expand All @@ -365,7 +367,9 @@ def configure_dynamics_function(ocp, nlp, dyn_func, **extra_params):
[dynamics],
["x", "u", "p"],
["xdot"],
).expand()
)
if expand:
nlp.dynamics_func = nlp.dynamics_func.expand()

@staticmethod
def configure_contact_function(ocp, nlp, dyn_func: Callable, **extra_params):
Expand Down

0 comments on commit 2f86098

Please sign in to comment.