From bfc7606f286f099ef1d47eaad8bb17517eb05299 Mon Sep 17 00:00:00 2001 From: Ipuch Date: Thu, 2 Nov 2023 14:13:46 -0400 Subject: [PATCH] remove useless helper. --- .../optimization/optimal_control_program.py | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/bioptim/optimization/optimal_control_program.py b/bioptim/optimization/optimal_control_program.py index 4ac3c13c5..cfef222d9 100644 --- a/bioptim/optimization/optimal_control_program.py +++ b/bioptim/optimization/optimal_control_program.py @@ -2019,52 +2019,3 @@ def _scale_values(values, scaling_entities, penalty, scaling_data): scaling = np.repeat(complete_scaling, number_of_repeat, axis=0) return values / scaling - - -def concatenate_optimization_variables( - variable: list[np.ndarray] | np.ndarray, - continuous_phase: bool = True, - continuous_interval: bool = True, - merge_phases: bool = True, -) -> np.ndarray | list[dict[np.ndarray]]: - """ - # TODO: remove from here I don't this function to be here forever, duplicated of solution helper. - This function concatenates the decision variables of the phases of the system - into a single array, omitting the last element of each phase except for the last one. - - Parameters - ---------- - variable : list or dict - list of decision variables of the phases of the system - continuous_phase: bool - If the arrival value of a node should be discarded [True] or kept [False]. The value of an integrated - continuous_interval: bool - If the arrival value of a node of each interval should be discarded [True] or kept [False]. - Only useful in direct multiple shooting - merge_phases: bool - If the decision variables of each phase should be merged into a single array [True] or kept separated [False]. - - Returns - ------- - z_concatenated : np.ndarray or dict - array of the decision variables of the phases of the system concatenated - """ - if len(variable[0].shape): - if isinstance(variable[0][0], np.ndarray): - z_final = [] - for zi in variable: - z_final.append(concatenate_optimization_variables(zi, continuous_interval)) - - if merge_phases: - return concatenate_optimization_variables(z_final, continuous_phase) - else: - return z_final - else: - final_tuple = [] - for i, y in enumerate(variable): - if i < (len(variable) - 1) and continuous_phase: - final_tuple.append(y[:, :-1] if len(y.shape) == 2 else y[:-1]) - else: - final_tuple.append(y) - - return np.hstack(final_tuple)