Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
EveCharbie committed Sep 23, 2024
1 parent 3998582 commit 70ece1d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bioptim/dynamics/configure_new_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,4 +640,4 @@ def append_faked_optim_var(name: str, optim_var, keys: list):
to_second.extend(list(np.array(optim_var[key].mapping.to_second.map_idx) + len(to_second)))
to_first.extend(list(np.array(optim_var[key].mapping.to_first.map_idx) + len(to_first)))

optim_var.append_fake(name, index, None, BiMapping(to_second, to_first))
optim_var.append_fake(name, index, BiMapping(to_second, to_first))
7 changes: 5 additions & 2 deletions bioptim/dynamics/configure_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,15 +1496,18 @@ def configure_integrated_value(
initial_vector = StochasticBioModel.reshape_to_vector(initial_matrix)
cx_scaled_next_formatted = [initial_vector for _ in range(n_cx)]
nlp.integrated_values.append(
name, cx_scaled_next_formatted, cx_scaled_next_formatted, initial_matrix, dummy_mapping, 0
name=name,
cx=cx_scaled_next_formatted,
cx_scaled=[initial_matrix for i in range(n_cx)], # Only the first value is used
mapping=dummy_mapping,
node_index=0
)
for node_index in range(1, nlp.ns + 1): # cannot use phase_dynamics == PhaseDynamics.SHARED_DURING_THE_PHASE
cx_scaled_next = nlp.integrated_value_functions[name](nlp, node_index)
cx_scaled_next_formatted = [cx_scaled_next for _ in range(n_cx)]
nlp.integrated_values.append(
name,
cx_scaled_next_formatted,
cx_scaled_next_formatted,
cx_scaled_next,
dummy_mapping,
node_index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,20 @@ def generate_data(
name="q",
cx=[symbolic_q, symbolic_q, symbolic_q],
cx_scaled=[symbolic_q, symbolic_q, symbolic_q],
mx=symbolic_q,
mapping=nlp.variable_mappings["q"],
node_index=node_index,
)
nlp.states.append(
name="qdot",
cx=[symbolic_qdot, symbolic_qdot, symbolic_qdot],
cx_scaled=[symbolic_qdot, symbolic_qdot, symbolic_qdot],
mx=symbolic_qdot,
mapping=nlp.variable_mappings["qdot"],
node_index=node_index,
)
nlp.states.append(
name="muscles",
cx=[symbolic_mus_states, symbolic_mus_states, symbolic_mus_states],
cx_scaled=[symbolic_mus_states, symbolic_mus_states, symbolic_mus_states],
mx=symbolic_mus_states,
mapping=nlp.variable_mappings["muscles"],
node_index=node_index,
)
Expand All @@ -139,31 +136,27 @@ def generate_data(
name="tau",
cx=[symbolic_tau, symbolic_tau, symbolic_tau],
cx_scaled=[symbolic_tau, symbolic_tau, symbolic_tau],
mx=symbolic_tau,
mapping=nlp.variable_mappings["tau"],
node_index=node_index,
)
nlp.controls.append(
name="muscles",
cx=[symbolic_mus_controls, symbolic_mus_controls, symbolic_mus_controls],
cx_scaled=[symbolic_mus_controls, symbolic_mus_controls, symbolic_mus_controls],
mx=symbolic_mus_controls,
mapping=nlp.variable_mappings["muscles"],
node_index=node_index,
)
nlp.states_dot.append(
name="qdot",
cx=[symbolic_qdot, symbolic_qdot, symbolic_qdot],
cx_scaled=[symbolic_qdot, symbolic_qdot, symbolic_qdot],
mx=symbolic_qdot,
mapping=nlp.variable_mappings["qdot"],
node_index=node_index,
)
nlp.states_dot.append(
name="qddot",
cx=[symbolic_qddot, symbolic_qddot, symbolic_qddot],
cx_scaled=[symbolic_qddot, symbolic_qddot, symbolic_qddot],
mx=symbolic_qddot,
mapping=nlp.variable_mappings["qddot"],
node_index=node_index,
)
Expand Down
5 changes: 0 additions & 5 deletions bioptim/optimization/optimal_control_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,15 +1704,10 @@ def _define_numerical_timeseries(self, dynamics):
f"{key}_phase{i_phase}_{i_component}_cx",
variable_shape[0],
)
mx = MX.sym(
f"{key}_phase{i_phase}_{i_component}_mx",
variable_shape[0],
)

numerical_timeseries[-1].append(
name=f"{key}_{i_component}",
cx=[cx, cx, cx],
mx=mx,
bimapping=BiMapping(
Mapping(list(range(variable_shape[0]))), Mapping(list(range(variable_shape[0])))
),
Expand Down

0 comments on commit 70ece1d

Please sign in to comment.