Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipuch committed Nov 2, 2023
1 parent 69a93be commit 8ef80dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
52 changes: 24 additions & 28 deletions bioptim/optimization/solution/simplified_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ def __init__(self, nlp: NonLinearProgram):
self.s_scaling = nlp.s_scaling
self.phase_dynamics = nlp.phase_dynamics

def get_integrated_values(
self, states: dict, controls: dict, parameters: dict, stochastic_variables: dict
) -> dict:
def get_integrated_values(self, states: dict, controls: dict, parameters: dict, stochastic_variables: dict) -> dict:
"""
TODO :
Expand Down Expand Up @@ -282,18 +280,18 @@ def get_integrated_values(
integrated_values_data = np.zeros((nb_elements, self.ns))
for i_node in range(self.ns):
integrated_values_data[:, i_node] = np.reshape(
integrated_values_this_time[i_node * nb_elements: (i_node + 1) * nb_elements],
integrated_values_this_time[i_node * nb_elements : (i_node + 1) * nb_elements],
(nb_elements,),
)
integrated_values_num[key] = integrated_values_data

return integrated_values_num

def _generate_time(
self,
time_phase: np.ndarray,
keep_intermediate_points: bool = None,
shooting_type: Shooting = None,
self,
time_phase: np.ndarray,
keep_intermediate_points: bool = None,
shooting_type: Shooting = None,
):
"""
Generate time vector steps for a phase considering all the phase final time
Expand Down Expand Up @@ -352,12 +350,12 @@ def _generate_time(

@staticmethod
def _define_step_times(
dynamics_step_time: list,
ode_solver_steps: int,
keep_intermediate_points: bool = None,
continuous: bool = True,
is_direct_collocation: bool = None,
include_starting_collocation_point: bool = False,
dynamics_step_time: list,
ode_solver_steps: int,
keep_intermediate_points: bool = None,
continuous: bool = True,
is_direct_collocation: bool = None,
include_starting_collocation_point: bool = False,
) -> np.ndarray:
"""
Define the time steps for the integration of the whole phase
Expand Down Expand Up @@ -503,11 +501,11 @@ def __init__(self, ocp):
self.n_threads = ocp.n_threads

def get_integrated_values(
self,
states: list[np.ndarray],
controls: list[np.ndarray],
parameters: np.ndarray,
stochastic_variables: list[np.ndarray],
self,
states: list[np.ndarray],
controls: list[np.ndarray],
parameters: np.ndarray,
stochastic_variables: list[np.ndarray],
):
"""
TODO:
Expand Down Expand Up @@ -535,11 +533,11 @@ def get_integrated_values(
return integrated_values_num

def _generate_time(
self,
time_phase: list[float],
keep_intermediate_points: bool = None,
merge_phases: bool = False,
shooting_type: Shooting = None,
self,
time_phase: list[float],
keep_intermediate_points: bool = None,
merge_phases: bool = False,
shooting_type: Shooting = None,
) -> np.ndarray | list[np.ndarray]:
"""
Generate time integration vector
Expand Down Expand Up @@ -571,14 +569,12 @@ def _generate_time(
time_vector.append(phase_time_vector)

if merge_phases:
return concatenate_optimization_variables(
time_vector, continuous_phase=shooting_type == Shooting.SINGLE
)
return concatenate_optimization_variables(time_vector, continuous_phase=shooting_type == Shooting.SINGLE)
else:
return time_vector

def _complete_controls(
self, controls: dict[str, list[dict[str, np.ndarray]]]
self, controls: dict[str, list[dict[str, np.ndarray]]]
) -> dict[str, list[dict[str, np.ndarray]]]:
"""
Controls don't necessarily have dimensions that matches the states. This method aligns them
Expand Down
1 change: 0 additions & 1 deletion bioptim/optimization/solution/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1993,4 +1993,3 @@ def print_constraints(ocp, sol):
self.print_cost(CostType.CONSTRAINTS)
else:
raise ValueError("print can only be called with CostType.OBJECTIVES or CostType.CONSTRAINTS")

1 change: 1 addition & 0 deletions bioptim/optimization/solution/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np


def concatenate_optimization_variables_dict(
variable: list[dict[np.ndarray]], continuous: bool = True
) -> list[dict[np.ndarray]]:
Expand Down

0 comments on commit 8ef80dd

Please sign in to comment.