Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_osx_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
11 changes: 8 additions & 3 deletions bioptim/gui/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down
9 changes: 5 additions & 4 deletions bioptim/misc/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions bioptim/optimization/receding_horizon_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
10 changes: 4 additions & 6 deletions bioptim/optimization/solution/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ channels:
- conda-forge
dependencies:
- biorbd >=1.11.1
- numpy >=2.4,<3
- matplotlib
- pyqt
- pyqtgraph
- python-graphviz
- python-graphviz