From b4565ea26c6c119ff15f1e1fcda2260b2929df05 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 24 Oct 2022 11:03:58 +0000 Subject: [PATCH 1/4] test --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 242fd6a38..37c852a65 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It interfaces the robust [`Ipopt`](https://github.com/coin-or/Ipopt) and the fas ## Status -| Type | Status | +| Type | Status | jih |---|---| | License | License | | Continuous integration | [![Build status](https://ci.appveyor.com/api/projects/status/om07r8jhng61qx7y/branch/master?svg=true)](https://ci.appveyor.com/project/pariterre/bioptim/branch/master) | From 8ce6c51359854fd697e01b454157fedaf916e880 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 24 Oct 2022 11:03:58 +0000 Subject: [PATCH 2/4] Revert "test" This reverts commit b4565ea26c6c119ff15f1e1fcda2260b2929df05. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37c852a65..242fd6a38 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It interfaces the robust [`Ipopt`](https://github.com/coin-or/Ipopt) and the fas ## Status -| Type | Status | jih +| Type | Status | |---|---| | License | License | | Continuous integration | [![Build status](https://ci.appveyor.com/api/projects/status/om07r8jhng61qx7y/branch/master?svg=true)](https://ci.appveyor.com/project/pariterre/bioptim/branch/master) | From 29a567ac14a242b5fa056aa7562a9a33f45650c3 Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 8 Nov 2022 11:40:06 -0100 Subject: [PATCH 3/4] fix target shape with multi threads --- bioptim/interfaces/interface_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bioptim/interfaces/interface_utils.py b/bioptim/interfaces/interface_utils.py index 0739477c4..0f9b26351 100644 --- a/bioptim/interfaces/interface_utils.py +++ b/bioptim/interfaces/interface_utils.py @@ -251,7 +251,7 @@ def get_x_and_u_at_idx(_penalty, _idx): if penalty.multi_thread: if penalty.target is not None and len(penalty.target[0].shape) != 2: raise NotImplementedError("multi_thread penalty with target shape != [n x m] is not implemented yet") - target = penalty.target if penalty.target is not None else [] + target = penalty.target[0] if penalty.target is not None else [] x = nlp.cx() u = nlp.cx() From e3023ebf01c4e02b14048bfc30973e22c6e5b470 Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 8 Nov 2022 12:25:36 -0100 Subject: [PATCH 4/4] add test multi threads target --- .../examples/muscle_driven_ocp/muscle_activations_tracker.py | 4 ++++ tests/test_global_muscle_tracking.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bioptim/examples/muscle_driven_ocp/muscle_activations_tracker.py b/bioptim/examples/muscle_driven_ocp/muscle_activations_tracker.py index f3f031958..f4f8d8306 100644 --- a/bioptim/examples/muscle_driven_ocp/muscle_activations_tracker.py +++ b/bioptim/examples/muscle_driven_ocp/muscle_activations_tracker.py @@ -153,6 +153,7 @@ def prepare_ocp( kin_data_to_track: str = "markers", use_residual_torque: bool = True, ode_solver: OdeSolver = OdeSolver.COLLOCATION(), + n_threads: int = 1, ) -> OptimalControlProgram: """ Prepare the ocp to solve @@ -177,6 +178,8 @@ def prepare_ocp( If residual torque are present or not in the dynamics ode_solver: OdeSolver The ode solver to use + n_threads: int + The number of threads Returns ------- @@ -240,6 +243,7 @@ def prepare_ocp( u_bounds, objective_functions, ode_solver=ode_solver, + n_threads=n_threads, ) diff --git a/tests/test_global_muscle_tracking.py b/tests/test_global_muscle_tracking.py index 99852c0a5..e36f0b53a 100644 --- a/tests/test_global_muscle_tracking.py +++ b/tests/test_global_muscle_tracking.py @@ -12,7 +12,8 @@ @pytest.mark.parametrize("ode_solver", [OdeSolver.RK4, OdeSolver.COLLOCATION, OdeSolver.IRK]) -def test_muscle_activations_and_states_tracking(ode_solver): +@pytest.mark.parametrize("n_threads", [1, 2]) +def test_muscle_activations_and_states_tracking(ode_solver, n_threads): # Load muscle_activations_tracker from bioptim.examples.muscle_driven_ocp import muscle_activations_tracker as ocp_module @@ -42,6 +43,7 @@ def test_muscle_activations_and_states_tracking(ode_solver): use_residual_torque=use_residual_torque, kin_data_to_track="q", ode_solver=ode_solver(), + n_threads=n_threads, ) solver = Solver.IPOPT() # solver.set_maximum_iterations(10)