1111from ..utils import TestUtils
1212
1313
14- @pytest .mark .parametrize (
15- "phase_dynamics" ,
16- [
17- PhaseDynamics .SHARED_DURING_THE_PHASE ,
18- PhaseDynamics .ONE_PER_NODE ,
19- ],
20- )
21- @pytest .mark .parametrize (
22- "use_sx" ,
23- [
24- True ,
25- False ,
26- ],
27- )
14+ @pytest .mark .parametrize ("phase_dynamics" , [PhaseDynamics .SHARED_DURING_THE_PHASE , PhaseDynamics .ONE_PER_NODE ])
15+ @pytest .mark .parametrize ("use_sx" , [True , False ])
2816def test_example_param_obj_and_param_scaling (
2917 phase_dynamics ,
3018 use_sx ,
3119):
32-
33- if platform == "darwin" or platform == "win32" :
34- pytest .skip ("This test is not working on MacOS or Windows" )
35-
3620 from bioptim .examples .toy_examples .feature_examples import example_parameter_scaling as ocp_module
3721
3822 bioptim_folder = TestUtils .bioptim_folder ()
3923
4024 final_time = 1
41- n_shooting = 10
25+ n_shooting = 20
4226
4327 ocp_to_track = ocp_module .generate_dat_to_track (
4428 biorbd_model_path = bioptim_folder + "/examples/models/pendulum_wrong_gravity.bioMod" ,
@@ -67,7 +51,7 @@ def test_example_param_obj_and_param_scaling(
6751 sol = ocp .solve (Solver .IPOPT (show_online_optim = False ))
6852
6953 # Test the objective values
70- TestUtils .assert_objective_value (sol = sol , expected_value = 35328792.2512389 , decimal = 4 )
54+ TestUtils .assert_objective_value (sol = sol , expected_value = 35479.23885709513 , decimal = 4 )
7155
7256 g = np .array (sol .constraints )
7357 npt .assert_equal (g .shape , (0 , 1 ))
@@ -81,11 +65,11 @@ def test_example_param_obj_and_param_scaling(
8165 npt .assert_almost_equal (qdot [:, - 1 ], np .array ([0.0 , 0.0 ]), decimal = 5 )
8266
8367 npt .assert_almost_equal (q [:, 0 ], np .array ([0.0 , 0.0 ]), decimal = 5 )
84- npt .assert_almost_equal (q [:, 5 ], np .array ([- 0.26673 , 2.53154 ]), decimal = 5 )
68+ npt .assert_almost_equal (q [:, 5 ], np .array ([- 0.27469 , 0.24421 ]), decimal = 5 )
8569 npt .assert_almost_equal (q [:, - 1 ], np .array ([0.0 , 3.14 ]), decimal = 5 )
8670
8771 param_not_scaled = sol .decision_parameters (scaled = False )
8872 param_scaled = sol .decision_parameters (scaled = True )
8973
90- npt .assert_almost_equal (param_not_scaled ["gravity_xyz" ], np .array ([0.0 , 3.89005766 , - 14.71310026 ]), decimal = 5 )
91- npt .assert_almost_equal (param_scaled ["gravity_xyz" ], np .array ([0.0 , 3.89005766 , - 1.47131003 ]), decimal = 5 )
74+ npt .assert_almost_equal (param_not_scaled ["gravity_xyz" ], np .array ([0.0 , 0.01281 , - 5 ]), decimal = 5 )
75+ npt .assert_almost_equal (param_scaled ["gravity_xyz" ], np .array ([0.0 , 0.01281 , - 0.5 ]), decimal = 5 )
0 commit comments