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

node_mapping / phase_mapping could be removed to simplify code #717

Open
EveCharbie opened this issue Jul 14, 2023 · 3 comments
Open

node_mapping / phase_mapping could be removed to simplify code #717

EveCharbie opened this issue Jul 14, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@EveCharbie
Copy link
Collaborator

No description provided.

@EveCharbie EveCharbie added enhancement New feature or request good first issue Good for newcomers labels Jul 14, 2023
@EveCharbie EveCharbie self-assigned this Feb 5, 2025
@Ipuch
Copy link
Collaborator

Ipuch commented Feb 5, 2025

Can you give a little overview of the code area expected to be touched ?

@Ipuch
Copy link
Collaborator

Ipuch commented Feb 10, 2025

DONE !

@Ipuch Ipuch closed this as completed Feb 10, 2025
@Ipuch
Copy link
Collaborator

Ipuch commented Feb 10, 2025

I still have a bunch of questions about these functions @EveCharbie :

I think that passing the ocp was only necessary for phase mapping to work right ?

def initialize(ocp, nlp):
"""
Call the dynamics a first time
Parameters
----------
ocp: OptimalControlProgram
A reference to the ocp
nlp: NonLinearProgram
A reference to the phase
"""
nlp.dynamics_type.type(
ocp,
nlp,
numerical_data_timeseries=nlp.dynamics_type.numerical_data_timeseries,
**nlp.dynamics_type.extra_parameters,
)

Here I question the use of the function itself:

def _apply_phase_mapping(ocp, nlp, name: str) -> BiMapping | None:
"""
Apply the phase mapping to the variable
Parameters
----------
ocp: OptimalControlProgram
A reference to the ocp
nlp: NonLinearProgram
A reference to the phase
name: str
The name of the variable to map
Returns
-------
The mapping or None if no mapping is defined
"""
if nlp.phase_mapping:
if name in nlp.variable_mappings.keys():
double_mapping_to_first = (
nlp.variable_mappings[name].to_first.map(nlp.phase_mapping.to_first.map_idx).T.tolist()[0]
)
double_mapping_to_first = [int(double_mapping_to_first[i]) for i in range(len(double_mapping_to_first))]
double_mapping_to_second = (
nlp.variable_mappings[name].to_second.map(nlp.phase_mapping.to_second.map_idx).T.tolist()[0]
)
double_mapping_to_second = [
int(double_mapping_to_second[i]) for i in range(len(double_mapping_to_second))
]
else:
double_mapping_to_first = nlp.phase_mapping.to_first.map_idx
double_mapping_to_second = nlp.phase_mapping.to_second.map_idx
axes_idx = BiMapping(to_first=double_mapping_to_first, to_second=double_mapping_to_second)
else:
axes_idx = None
return axes_idx

That's only two right but there might have been some stuff hidden in the plot section right ?

@Ipuch Ipuch reopened this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants