Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed save and load #804

Closed
wants to merge 5 commits into from
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
1 change: 0 additions & 1 deletion bioptim/examples/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
("Example mapping", "example_mapping.py"),
("Example multiphase", "example_multiphase.py"),
("Example optimal time", "example_optimal_time.py"),
("Example save and load", "example_save_and_load.py"),
("Example simulation", "example_simulation.py"),
("Example Implicit Dynamics", "example_implicit_dynamics.py"),
("Pendulum", "pendulum.py"),
Expand Down
161 changes: 0 additions & 161 deletions bioptim/examples/getting_started/example_save_and_load.py

This file was deleted.

2 changes: 1 addition & 1 deletion bioptim/examples/getting_started/example_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The second part of the example is to actually solve the program and then simulate the results from this solution.
The main goal of this kind of simulation, especially in single shooting (that is not resetting the states at each node)
is to validate the dynamics of multiple shooting. If they both are equal, it usually means that a great confidence
can be held in the solution. Another goal would be to reload fast a previously saved optimized solution
can be held in the solution.
"""

from bioptim import InitialGuess, Solution, Shooting, InterpolationType, SolutionIntegrator
Expand Down
1 change: 1 addition & 0 deletions bioptim/examples/getting_started/pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
During the optimization process, the graphs are updated real-time (even though it is a bit too fast and short to really
appreciate it). Finally, once it finished optimizing, it animates the model using the optimal solution
"""

import platform

from bioptim import (
Expand Down
2 changes: 1 addition & 1 deletion bioptim/examples/moving_horizon_estimation/cyclic_nmpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def prepare_nmpc(
dynamics,
cycle_len,
cycle_duration,
objective_functions=new_objectives,
common_objective_functions=new_objectives,
constraints=constraints,
x_bounds=x_bound,
u_bounds=u_bound,
Expand Down
2 changes: 1 addition & 1 deletion bioptim/examples/moving_horizon_estimation/mhe.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def prepare_mhe(
Dynamics(DynamicsFcn.TORQUE_DRIVEN, expand_dynamics=expand_dynamics, phase_dynamics=phase_dynamics),
window_len,
window_duration,
objective_functions=new_objectives,
common_objective_functions=new_objectives,
x_bounds=x_bounds,
u_bounds=u_bounds,
x_init=x_init_list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def prepare_nmpc(
cycle_duration=cycle_duration,
n_cycles_simultaneous=n_cycles_simultaneous,
n_cycles_to_advance=n_cycles_to_advance,
objective_functions=new_objectives,
common_objective_functions=new_objectives,
constraints=constraints,
x_bounds=x_bounds,
u_bounds=u_bounds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ def prepare_socp(
objective_functions = ObjectiveList()
objective_functions.add(ObjectiveFcn.Mayer.MINIMIZE_TIME, weight=1)
objective_functions.add(
ObjectiveFcn.Mayer.MINIMIZE_CONTROL,
ObjectiveFcn.Lagrange.MINIMIZE_CONTROL,
key="u",
weight=1e-2 / (2 * n_shooting),
node=Node.ALL_SHOOTING,
quadratic=True,
)

Expand Down
2 changes: 1 addition & 1 deletion bioptim/examples/torque_driven_ocp/trampo_quaternions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def prepare_ocp(
# Add objective functions
objective_functions = ObjectiveList()
objective_functions.add(ObjectiveFcn.Mayer.MINIMIZE_MARKERS, marker_index=1, weight=-1)
objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", node=Node.ALL_SHOOTING, weight=100)
objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=100)

# Dynamics
dynamics = DynamicsList()
Expand Down
2 changes: 1 addition & 1 deletion bioptim/gui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def print(self):
print("")
print("")
print(f"**********")
print(f"MODEL: {self.ocp.original_values['bio_model'][phase_idx]}")
print(f"MODEL: {self.ocp.nlp[phase_idx].model.name}")
if isinstance(self.ocp.nlp[phase_idx].tf, (int, float)):
print(f"PHASE DURATION: {round(self.ocp.nlp[phase_idx].tf, 2)} s")
else:
Expand Down
5 changes: 5 additions & 0 deletions bioptim/models/biorbd/biorbd_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def __init__(self, bio_model: str | biorbd.Model, friction_coefficients: np.ndar
self.model = biorbd.Model(bio_model) if isinstance(bio_model, str) else bio_model
self._friction_coefficients = friction_coefficients

@property
def name(self) -> str:
# parse the path and split to get the .bioMod name
return self.model.path().absolutePath().to_string().split("/")[-1]

@property
def path(self) -> str:
return self.model.path().relativePath().to_string()
Expand Down
5 changes: 5 additions & 0 deletions bioptim/models/protocols/biomodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class BioModel(Protocol):
As a reminder for developers: only necessary attributes and methods should appear here.
"""

@property
def name(self) -> str:
"""Get the name of the model"""
return ""

def copy(self):
"""copy the model by reloading one"""

Expand Down
Loading
Loading