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

[RTR] Fixed add_penalty_plot index #665

Merged
merged 17 commits into from
May 25, 2023

Conversation

EveCharbie
Copy link
Collaborator

@EveCharbie EveCharbie commented May 5, 2023

Tries to fix issue #641


This change is Reviewable

@EveCharbie
Copy link
Collaborator Author

@lsechoir I think you had problems with add_plot_penalty too, can you try this fix to see if it helps in your case?

@codecov
Copy link

codecov bot commented May 5, 2023

Codecov Report

Patch coverage: 65.00% and project coverage change: -0.01 ⚠️

Comparison is base (2cce426) 81.82% compared to head (d3764bb) 81.81%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #665      +/-   ##
==========================================
- Coverage   81.82%   81.81%   -0.01%     
==========================================
  Files         112      112              
  Lines       12919    12953      +34     
==========================================
+ Hits        10571    10598      +27     
- Misses       2348     2355       +7     
Impacted Files Coverage Δ
bioptim/gui/plot.py 73.48% <55.71%> (+0.46%) ⬆️
bioptim/dynamics/configure_problem.py 90.92% <76.47%> (-0.35%) ⬇️
bioptim/limits/penalty.py 89.65% <100.00%> (+0.13%) ⬆️
bioptim/limits/penalty_option.py 88.59% <100.00%> (-0.15%) ⬇️
bioptim/optimization/optimal_control_program.py 87.38% <100.00%> (-0.16%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@EveCharbie
Copy link
Collaborator Author

EveCharbie commented May 5, 2023

@pariterre I changed the behavior of the plots. Now it shows all plots even if there is a mapping. I find it easier to understand and it fixes the issue with indexing the plots. What do you think? (If it is ok, I will clean it, ex the legend)
Screenshot from 2023-05-05 14-35-42

@EveCharbie EveCharbie changed the title Fixed add_penalty_plot index [RTR] Fixed add_penalty_plot index May 5, 2023
@pariterre
Copy link
Member

I understand how it simplifies things... but not sure I like creating useless graphs... @Ipuch ?

Copy link
Member

@pariterre pariterre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @EveCharbie)


bioptim/dynamics/configure_problem.py line 1113 at r2 (raw file):

            as_controls,
            as_states_dot,
            axes_idx=axes_idx  # nlp.variable_mappings[name].to_first,

Remove if not necessary


bioptim/gui/plot.py line 99 at r2 (raw file):

            self.phase_mappings = None  # Will be set later
        elif isinstance(axes_idx, (tuple, list)):
            self.phase_mappings = BiMapping(axes_idx) # ?

What is the question here?

@pariterre
Copy link
Member

Please have a look why tests fail

@pariterre pariterre changed the title [RTR] Fixed add_penalty_plot index Fixed add_penalty_plot index May 8, 2023
@EveCharbie
Copy link
Collaborator Author

Test does not pass because it is not a final version, I just wanted your insights before cleaning the code.

@Ipuch
Copy link
Collaborator

Ipuch commented May 8, 2023

I don't care about having extra graphs if it eases the code. Anyways we don't use them for publication but only to check our results.
If it helps to understand which dof are mapped, I'm down for this PR.
The little extra would be to write on which graph to refer to if mapped with another dof, or None if just remove.
Or display the same value as it is mapped ?

Copy link
Collaborator Author

@EveCharbie EveCharbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 5 files reviewed, 2 unresolved discussions (waiting on @pariterre)


bioptim/dynamics/configure_problem.py line 1113 at r2 (raw file):

Previously, pariterre (Pariterre) wrote…

Remove if not necessary

Done.


bioptim/gui/plot.py line 99 at r2 (raw file):

Previously, pariterre (Pariterre) wrote…

What is the question here?

Done.

@EveCharbie EveCharbie changed the title Fixed add_penalty_plot index [RTR] Fixed add_penalty_plot index May 15, 2023
Copy link
Member

@pariterre pariterre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 5 files at r3, 4 of 4 files at r4, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @EveCharbie)


bioptim/limits/penalty_option.py line 571 at r4 (raw file):

        else:
            target_mapping = BiMapping(
                to_first=list(range(controller.get_nlp.controls[key].cx_start.shape[0])),

congtroller.controls[key].cx.shape


bioptim/limits/penalty_option.py line 572 at r4 (raw file):

            target_mapping = BiMapping(
                to_first=list(range(controller.get_nlp.controls[key].cx_start.shape[0])),
                to_second=list(range(controller.get_nlp.controls[key].cx_start.shape[0])),

congtroller.controls[key].cx.shape


bioptim/limits/penalty_option.py line 593 at r4 (raw file):

        self.target_plot_name = combine_to
        # if the target is n x ns, we need to add a dimension (n x ns + 1) to make it compatible with the plot
        if self.target[0].shape[1] == controller.get_nlp.ns:

congtroller.ns?


bioptim/optimization/optimal_control_program.py line 1034 at r4 (raw file):

                x_scaling = np.vstack([self.nlp[penalty.phase].x_scaling["all"].scaling for _ in range(x_shape)]).T

            x /= x_scaling

check this?


bioptim/optimization/optimal_control_program.py line 1035 at r4 (raw file):

            x /= x_scaling
            if u.size != 0:

wait for me?

@pariterre pariterre changed the title [RTR] Fixed add_penalty_plot index [RTM] Fixed add_penalty_plot index May 18, 2023
Copy link
Collaborator Author

@EveCharbie EveCharbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 5 files reviewed, 5 unresolved discussions (waiting on @pariterre)


bioptim/limits/penalty_option.py line 571 at r4 (raw file):

Previously, pariterre (Pariterre) wrote…

congtroller.controls[key].cx.shape

Done.


bioptim/limits/penalty_option.py line 572 at r4 (raw file):

Previously, pariterre (Pariterre) wrote…

congtroller.controls[key].cx.shape

Done.


bioptim/limits/penalty_option.py line 593 at r4 (raw file):

Previously, pariterre (Pariterre) wrote…

congtroller.ns?

Done.


bioptim/optimization/optimal_control_program.py line 1034 at r4 (raw file):

Previously, pariterre (Pariterre) wrote…

check this?

did not disapear, dont know why ?


bioptim/optimization/optimal_control_program.py line 1035 at r4 (raw file):

Previously, pariterre (Pariterre) wrote…

wait for me?

Merged you PR

@EveCharbie EveCharbie changed the title [RTM] Fixed add_penalty_plot index [RTR] Fixed add_penalty_plot index May 20, 2023
Copy link
Member

@pariterre pariterre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 4 of 4 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @EveCharbie)

@pariterre pariterre merged commit 0b98d71 into pyomeca:master May 25, 2023
5 of 7 checks passed
@EveCharbie EveCharbie deleted the bug_plot_penalty branch May 30, 2023 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants