From d7366c539ede81667a6a99acd4eb52c99045756a Mon Sep 17 00:00:00 2001 From: Kevin CO Date: Mon, 4 Aug 2025 09:06:19 -0400 Subject: [PATCH 1/5] . --- bioptim/gui/plot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bioptim/gui/plot.py b/bioptim/gui/plot.py index 69a1ce658..1ff698c66 100644 --- a/bioptim/gui/plot.py +++ b/bioptim/gui/plot.py @@ -635,10 +635,15 @@ def _add_vertical_lines(self, ax): def _add_bounds_to_plot(self, i, nlp, variable, ctr, ax, mapping_to_first_index): """Add bounds to a specific plot""" - if nlp.plot[variable].bounds.type == InterpolationType.EACH_FRAME: + if nlp.plot[variable].bounds.type in [InterpolationType.EACH_FRAME, InterpolationType.ALL_POINTS]: ns = nlp.plot[variable].bounds.min.shape[1] - 1 else: ns = nlp.ns + t = ( + [np.linspace(0, ns, ns + 1) for i in range(len(self.t))] + if nlp.plot[variable].bounds.type == InterpolationType.ALL_POINTS + else self.t + ) # TODO: introduce repeat for the COLLOCATIONS min/max_bounds only for states graphs. # For now the plots in COLLOCATIONS with LINEAR are not giving the right values @@ -652,8 +657,8 @@ def _add_bounds_to_plot(self, i, nlp, variable, ctr, ax, mapping_to_first_index) bounds_min = np.concatenate((bounds_min, [bounds_min[-1]])) bounds_max = np.concatenate((bounds_max, [bounds_max[-1]])) - self.plots_bounds.append([ax.step(self.t[i], bounds_min, where="post", **self.plot_options["bounds"]), i]) - self.plots_bounds.append([ax.step(self.t[i], bounds_max, where="post", **self.plot_options["bounds"]), i]) + self.plots_bounds.append([ax.step(t[i], bounds_min, where="post", **self.plot_options["bounds"]), i]) + self.plots_bounds.append([ax.step(t[i], bounds_max, where="post", **self.plot_options["bounds"]), i]) def _add_new_axis(self, variable: Str, nb: Int, n_rows: Int, n_cols: Int): """ From 4d7c1f3ee1eb2272ef6f2620ef6ae02d94ba5299 Mon Sep 17 00:00:00 2001 From: Kevin CO Date: Tue, 19 Aug 2025 14:27:11 -0400 Subject: [PATCH 2/5] reducing memorie consumption and speed up solution building for large oc --- bioptim/optimization/solution/solution.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bioptim/optimization/solution/solution.py b/bioptim/optimization/solution/solution.py index 14884199d..4f5f8ecc0 100644 --- a/bioptim/optimization/solution/solution.py +++ b/bioptim/optimization/solution/solution.py @@ -256,12 +256,11 @@ def from_initial_guess(cls, ocp, sol: list): dt, sol_states, sol_controls, sol_params, sol_algebraic_states = sol - vector = np.ndarray((0, 1)) - # For time if len(dt.shape) == 1: dt = dt[:, np.newaxis] - vector = np.concatenate((vector, dt)) + + state_vector = [dt] # For states for p, ss in enumerate(sol_states): @@ -278,9 +277,8 @@ def from_initial_guess(cls, ocp, sol: list): for i in range(all_ns[p] * nb_intermediate_frames + 1): for key in ss.keys(): - vector = np.concatenate( - (vector, ss[key].init.evaluate_at(i, nb_intermediate_frames)[:, np.newaxis]) - ) + state_vector.append(ss[key].init.evaluate_at(i, nb_intermediate_frames)[:, None]) + vector = np.vstack(state_vector) # For controls for p, ss in enumerate(sol_controls): From d623d45bcb853c49eba5a132fa2a8c31e24109b2 Mon Sep 17 00:00:00 2001 From: Kevin CO Date: Fri, 7 Nov 2025 13:41:32 -0500 Subject: [PATCH 3/5] quick fix --- bioptim/optimization/receding_horizon_optimization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bioptim/optimization/receding_horizon_optimization.py b/bioptim/optimization/receding_horizon_optimization.py index 5242a7922..a41755ed8 100644 --- a/bioptim/optimization/receding_horizon_optimization.py +++ b/bioptim/optimization/receding_horizon_optimization.py @@ -763,8 +763,8 @@ def solve( ) if self.parameters.shape != 0 and get_all_iterations: - final_solution_parameters_dict = [{key: None} for key in solution[0].parameters.keys()][0] - for key in solution[0].parameters.keys(): + final_solution_parameters_dict = [{key: None} for key in solution[1][0].parameters.keys()][0] + for key in solution[1][0].parameters.keys(): key_val = [] for sol in solution[1]: key_val.append(sol.parameters[key]) From 3966dd60a1a1d04c7cc16506db425ec452dd6a08 Mon Sep 17 00:00:00 2001 From: mickaelbegon Date: Wed, 6 May 2026 13:11:27 -0400 Subject: [PATCH 4/5] Require NumPy 2.4 in env and CI --- .github/workflows/run_tests_linux.yml | 2 +- .github/workflows/run_tests_osx_win.yml | 2 +- environment.yml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests_linux.yml b/.github/workflows/run_tests_linux.yml index 11e664382..8ac224170 100644 --- a/.github/workflows/run_tests_linux.yml +++ b/.github/workflows/run_tests_linux.yml @@ -40,7 +40,7 @@ jobs: - name: Install extra dependencies run: | - conda install pytest-cov black pytest pytest-cov codecov packaging pytest-mpl -cconda-forge + conda install "numpy>=2.4,<3" pytest-cov black pytest pytest-cov codecov packaging pytest-mpl -cconda-forge sudo apt install -y librhash-dev - name: Install ACADOS on Linux diff --git a/.github/workflows/run_tests_osx_win.yml b/.github/workflows/run_tests_osx_win.yml index dda9242a4..b28f36d08 100644 --- a/.github/workflows/run_tests_osx_win.yml +++ b/.github/workflows/run_tests_osx_win.yml @@ -47,7 +47,7 @@ jobs: conda list - name: Install extra dependencies - run: conda install pytest-cov black pytest pytest-cov codecov packaging -cconda-forge + run: conda install "numpy>=2.4,<3" pytest-cov black pytest pytest-cov codecov packaging -cconda-forge - name: Install ACADOS on Mac run: | diff --git a/environment.yml b/environment.yml index 1c89ee207..7c15d1249 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,8 @@ channels: - conda-forge dependencies: - biorbd >=1.11.1 +- numpy >=2.4,<3 - matplotlib - pyqt - pyqtgraph -- python-graphviz \ No newline at end of file +- python-graphviz From 98811838deb8679e8e68a3a53cb7327a9cc68a33 Mon Sep 17 00:00:00 2001 From: mickaelbegon Date: Wed, 6 May 2026 13:11:33 -0400 Subject: [PATCH 5/5] Fix SelectionMapping for NumPy 2 --- bioptim/misc/mapping.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bioptim/misc/mapping.py b/bioptim/misc/mapping.py index c04d0c536..eebd7f1b6 100644 --- a/bioptim/misc/mapping.py +++ b/bioptim/misc/mapping.py @@ -408,11 +408,12 @@ def __init__( dependency_matrix: list = [None for _ in range(len(first))] oppose = [] for i in range(len(first)): - if first[i] != 0 and first[i] > 0: - dependency_matrix[i] = int(first[i] - 1) - if first[i] < 0: + value = first[i, 0] + if value != 0 and value > 0: + dependency_matrix[i] = int(value - 1) + if value < 0: oppose.append(i) - dependency_matrix[i] = int(abs(first[i]) - 1) + dependency_matrix[i] = int(abs(value) - 1) def _build_to_second(dependency_matrix: AnyList, independent_indices: AnyTuple): """