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] Stochastic variables should not be inputs of OCP #765

Merged
merged 19 commits into from
Oct 23, 2023

Conversation

Ipuch
Copy link
Collaborator

@Ipuch Ipuch commented Sep 25, 2023

It always confuses me and it broke all my older ocps.

All Submissions:

  • Have you followed the guidelines in our Contributing document [docs/contribution.md]?
  • Have you checked to ensure there aren't other open [Pull Requests] for the same update/change?
  • Have you opened/linked the issue related to your pull request?
  • 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

@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Attention: 51 lines in your changes are missing coverage. Please review.

Files Coverage Δ
bioptim/dynamics/dynamics_functions.py 86.53% <ø> (ø)
...ptim/optimization/receding_horizon_optimization.py 95.98% <100.00%> (ø)
bioptim/optimization/optimal_control_program.py 85.82% <89.47%> (+0.58%) ⬆️
...optimization/stochastic_optimal_control_program.py 31.49% <27.11%> (+5.49%) ⬆️

📢 Thoughts on this report? Let us know!.

@Ipuch Ipuch changed the title Stochastic variable should not be a entry of ocp [RTR] Stochastic variable should not be an entry of ocp Sep 25, 2023
@pariterre
Copy link
Member

pariterre commented Sep 28, 2023

  • Add a method dynamic_eval in ocp so we can have a signature for the custom dynamic function that changes depending on the type of ocp (for instance including (or not) stochatic_variable for problem where it makes sense to have them)
  • Add a super.init() in StochasticOCP to ensure a sane ocp
  • Factor common methods of StochasticsOCP and OCP and intercept what should not be performed in SOCP by an empty method

@pariterre pariterre changed the title [RTR] Stochastic variable should not be an entry of ocp Stochastic variable should not be an entry of ocp Oct 10, 2023
@Ipuch Ipuch changed the title Stochastic variable should not be an entry of ocp [RTR] Stochastic variables should not be inputs of OCP Oct 16, 2023
@Ipuch
Copy link
Collaborator Author

Ipuch commented Oct 16, 2023

  • Add a method dynamic_eval in ocp so we can have a signature for the custom dynamic function that changes depending on the type of ocp (for instance including (or not) stochatic_variable for problem where it makes sense to have them)
  • Add a super.init() in StochasticOCP to ensure a sane ocp
  • Factor common methods of StochasticsOCP and OCP and intercept what should not be performed in SOCP by an empty method

I propose to let the first bullet point for another PR to not grow this PR.

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


bioptim/optimization/optimal_control_program.py line 318 at r3 (raw file):

            s_init,
            s_scaling,
        )

self._prepare_all_decision_variables should prepare them, but I don't see the point returning them (I know that you did not introduce that, but since we are refactoring...). If we don't return them, it allows an overriden method to actually prepare what they want (and need) without worrying of the return signature of the method.

And if an inherited class need to change the behavior of a particular value, they can call super on this and change the specific one they need

Copy link
Collaborator Author

@Ipuch Ipuch 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: all files reviewed, 1 unresolved discussion (waiting on @pariterre)


bioptim/optimization/optimal_control_program.py line 318 at r3 (raw file):

Previously, pariterre (Pariterre) wrote…

self._prepare_all_decision_variables should prepare them, but I don't see the point returning them (I know that you did not introduce that, but since we are refactoring...). If we don't return them, it allows an overriden method to actually prepare what they want (and need) without worrying of the return signature of the method.

And if an inherited class need to change the behavior of a particular value, they can call super on this and change the specific one they need

I need a small talk. I took the easiest path, but maybe i can do better.

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:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Ipuch)

@pariterre pariterre merged commit 2918a29 into pyomeca:master Oct 23, 2023
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.

2 participants