Skip to content
Draft
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
3 changes: 3 additions & 0 deletions bioptim/optimization/non_linear_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def update_init(
self, x_init: InitialGuessList | None, u_init: InitialGuessList | None, a_init: InitialGuessList | None
) -> None:

if u_init is not None and u_init.type == InterpolationType.ALL_POINTS:
raise ValueError("InterpolationType.ALL_POINTS cannot be used for control initial guesses")

if x_init is not None or a_init is not None:
not_direct_collocation = not self.dynamics_type.ode_solver.is_direct_collocation
x_init_all_point = x_init.type == InterpolationType.ALL_POINTS if x_init is not None else False
Expand Down
4 changes: 2 additions & 2 deletions tests/shard2/test_global_getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ def test_initial_guesses(ode_solver, interpolation, random_init, phase_dynamics)

np.random.seed(42)

if interpolation == InterpolationType.ALL_POINTS and ode_solver.is_direct_shooting:
with pytest.raises(ValueError, match="InterpolationType.ALL_POINTS must only be used with direct collocation"):
if interpolation == InterpolationType.ALL_POINTS:
with pytest.raises(ValueError, match="InterpolationType.ALL_POINTS cannot be used for control initial guesses"):
_ = ocp_module.prepare_ocp(
biorbd_model_path=bioptim_folder + "/examples/models/cube.bioMod",
final_time=1,
Expand Down
Loading