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

[RTM] sol.graphs crashes if Meyer term in objective #644

Merged
merged 16 commits into from
Apr 21, 2023

Conversation

lsechoir
Copy link
Contributor

@lsechoir lsechoir commented Apr 4, 2023

All Submissions:

  • Have you followed the guidelines in our Contributing document [docs/contribution.md]?
  • [x ] Have you checked to ensure there aren't other open [Pull Requests] for the same update/change?
  • [x ] Have you opened/linked the issue related to your pull request? [Release 2.2.2] sol.graphs crashes if mayer term in objective #478
  • Have you used the tag [WIP] for on-going changes, and removed it when the pull request was ready?
  • When ready to merge, have you sent a comment pinging @pariterre in it?

New Feature Submissions:

  1. Does your submission pass the tests (if not please explain why this is intended)?
  2. Did you write a proper documentation (docstrings and ReadMe)
  3. Have you linted your code locally prior to submission (using the command: black . -l120 --exclude "external/*")?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new examples for your core changes, as applicable?
  • Have you written new tests for your core changes, as applicable?

This change is Reviewable

@lsechoir lsechoir changed the title sol.graphs crashes if Meyer term in objective [WIP] [WIP] sol.graphs crashes if Meyer term in objective Apr 4, 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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @lsechoir)


bioptim/examples/getting_started/example_multiphase.py line 66 at r1 (raw file):

    # Add objective functions
    objective_functions = ObjectiveList()
    # objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=100, phase=0)

Don't forget to reintroduce

Code quote:

    # objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=100, phase=0)
    # objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=100, phase=1)
    # objective_functions.add(ObjectiveFcn.Lagrange.MINIMIZE_CONTROL, key="tau", weight=100, phase=2)

bioptim/gui/plot.py line 388 at r1 (raw file):

                    ]
                    # for nlp_tp in self.ocp.nlp :
                    #     print(f'nlp_tp is {nlp_tp} and nlp_tp.plot is {nlp_tp.plot}')

Don't forget to remove

Code quote:

                    # for nlp_tp in self.ocp.nlp :
                    #     print(f'nlp_tp is {nlp_tp} and nlp_tp.plot is {nlp_tp.plot}')
                    #     print(f' new plot_func is {self.plot_func[variable]}')

bioptim/gui/plot.py line 421 at r1 (raw file):

                    plot_type = self.plot_func[variable][i].type
                  #  if _ in [8 9 12 13] :
                   #     plot_type = PlotType.INTEGRATED

Don't forget to remove

Code quote:

                  #  if _ in [8 9 12 13] :
                   #     plot_type = PlotType.INTEGRATED

bioptim/gui/plot.py line 599 at r1 (raw file):

        -------

        """

I assume this will become relevent

Code quote:

    @staticmethod
    def save():
        """

        Returns
        -------

        """

bioptim/gui/plot.py line 664 at r1 (raw file):

            for key in self.variable_sizes[i]:
                # print(f' key is {key}')

Don't forget to remove

Code quote:

    # print(f' key is {key}')

bioptim/gui/plot.py line 728 at r1 (raw file):

                        #if self.plot_func[key][i].parameters:
                        print(f' key is {key} and phase is {i}')
                        print(self.plot_func[key][i].parameters)

Don't forget to remove

Code quote:

                    print('plot type point ')
                    for i_var in range(self.variable_sizes[i][key]):
                        #if self.plot_func[key][i].parameters:
                        print(f' key is {key} and phase is {i}')
                        print(self.plot_func[key][i].parameters)

bioptim/gui/plot.py line 925 at r1 (raw file):

        #for i, plot in enumerate(self.plots):
          #  plot.plt.savefig("/home/mickaelbegon/Documents/Stage_Lisa/AnthropoImpactOnTech/Solutions_vrille_et_demi/,
          #           dpi=500)

Don't forget to remove

Code quote:

        #for i, plot in enumerate(self.plots):
          #  plot.plt.savefig("/home/mickaelbegon/Documents/Stage_Lisa/AnthropoImpactOnTech/Solutions_vrille_et_demi/,
          #           dpi=500)

bioptim/limits/penalty_option.py line 585 at r1 (raw file):

                    self.target_plot_name,
                    plot_function,
                    penalty = self,

Replace this for :
penalty = self if plot_type == PlotType.POINT else None
Then you can remove the outer "if"

Suggestion:

penalty = self, 

bioptim/optimization/solution.py line 1288 at r1 (raw file):

        show_now: bool = True,
        shooting_type: Shooting = Shooting.MULTIPLE,
        save_path: str = None,

save_figure_path?

Don't forget to add it in Parameters docstring

Code quote:

save_path

@lsechoir lsechoir changed the title [WIP] sol.graphs crashes if Meyer term in objective [RTR] sol.graphs crashes if Meyer term in objective Apr 18, 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 6 of 6 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lsechoir)


bioptim/gui/plot.py line 599 at r1 (raw file):

Previously, pariterre (Pariterre) wrote…

I assume this will become relevent

Please remove

@pariterre pariterre changed the title [RTR] sol.graphs crashes if Meyer term in objective [RTM] sol.graphs crashes if Meyer term in objective Apr 20, 2023
@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Patch coverage: 90.28% and project coverage change: -0.11 ⚠️

Comparison is base (ae6c337) 81.90% compared to head (1f9a849) 81.79%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #644      +/-   ##
==========================================
- Coverage   81.90%   81.79%   -0.11%     
==========================================
  Files         109      112       +3     
  Lines       12133    12558     +425     
==========================================
+ Hits         9937    10272     +335     
- Misses       2196     2286      +90     
Impacted Files Coverage Δ
...tim/examples/getting_started/example_multiphase.py 87.71% <0.00%> (-1.57%) ⬇️
...act/contact_forces_inequality_constraint_muscle.py 13.46% <0.00%> (ø)
...ith_contact/muscle_activations_contacts_tracker.py 22.44% <0.00%> (ø)
...es/muscle_driven_ocp/muscle_activations_tracker.py 76.14% <50.00%> (ø)
bioptim/limits/phase_transition.py 92.22% <50.00%> (ø)
.../torque_driven_ocp/pendulum_with_passive_torque.py 65.71% <60.00%> (ø)
...es/torque_driven_ocp/example_multi_biorbd_model.py 72.72% <72.72%> (ø)
...amples/torque_driven_ocp/ocp_mass_with_ligament.py 75.75% <75.75%> (ø)
bioptim/limits/penalty.py 89.81% <80.00%> (-1.61%) ⬇️
...ples/torque_driven_ocp/torque_activation_driven.py 81.81% <81.81%> (ø)
... and 20 more

... and 13 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

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 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lsechoir)

@pariterre pariterre merged commit cd0a1d3 into pyomeca:master Apr 21, 2023
3 of 6 checks passed
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