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] Mayer on first node with acados #501

Merged
merged 18 commits into from
Aug 8, 2022

Conversation

aceglia
Copy link
Contributor

@aceglia aceglia commented Jul 21, 2022

All Submissions:

  • [ x] 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?
  • Have you opened/linked the issue related to your pull request?
  • [ x] 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?
  • [x ] Have you written new tests for your core changes, as applicable?

This change is Reviewable

@aceglia aceglia changed the title [WIP] Mayer on first node with acados [RTR] Mayer on first node with acados Aug 4, 2022
@codecov
Copy link

codecov bot commented Aug 4, 2022

Codecov Report

Merging #501 (8d41519) into master (b360f0b) will increase coverage by 0.10%.
The diff coverage is 97.67%.

@@            Coverage Diff             @@
##           master     #501      +/-   ##
==========================================
+ Coverage   80.39%   80.49%   +0.10%     
==========================================
  Files          86       86              
  Lines        9482     9537      +55     
==========================================
+ Hits         7623     7677      +54     
- Misses       1859     1860       +1     
Impacted Files Coverage Δ
bioptim/interfaces/acados_interface.py 94.08% <97.67%> (+0.64%) ⬆️

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

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 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @aceglia)


bioptim/interfaces/acados_interface.py line 399 at r1 (raw file):

                )

        def add_linear_ls_mayer(acados, objectives, node=None):

I don't understand why (and how) you need node as it is


bioptim/interfaces/acados_interface.py line 402 at r1 (raw file):

            def add_objective(n_variables, is_state):
                v_var = np.zeros(n_variables)
                var_type = acados.ocp.nlp[0].states if is_state else acados.ocp.nlp[0].controls

Put this in a embedded function

Code quote:

                v_var = np.zeros(n_variables)
                var_type = acados.ocp.nlp[0].states if is_state else acados.ocp.nlp[0].controls
                rows = objectives.rows + var_type[objectives.params["key"]].index[0]
                v_var[rows] = 1.0

bioptim/interfaces/acados_interface.py line 406 at r1 (raw file):

                v_var[rows] = 1.0

                if objectives.node[0] == Node.START or node == "start":

Move the call down here as such
if objectives.node[0] == Node.START or objectives.node[0] == Node.ALL:

Code quote:

node == "start"

@pariterre pariterre changed the title [RTR] Mayer on first node with acados Mayer on first node with acados Aug 4, 2022
Copy link
Contributor Author

@aceglia aceglia 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 2 files reviewed, 3 unresolved discussions (waiting on @pariterre)


bioptim/interfaces/acados_interface.py line 399 at r1 (raw file):

Previously, pariterre (Pariterre) wrote…

I don't understand why (and how) you need node as it is

Done.


bioptim/interfaces/acados_interface.py line 402 at r1 (raw file):

Previously, pariterre (Pariterre) wrote…

Put this in a embedded function

Done.


bioptim/interfaces/acados_interface.py line 406 at r1 (raw file):

Previously, pariterre (Pariterre) wrote…

Move the call down here as such
if objectives.node[0] == Node.START or objectives.node[0] == Node.ALL:

Done.

@aceglia aceglia changed the title Mayer on first node with acados [RTR] Mayer on first node with acados Aug 4, 2022
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.

I much prefer this :)

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @aceglia)

@pariterre pariterre changed the title [RTR] Mayer on first node with acados [RTM] Mayer on first node with acados Aug 4, 2022
@pariterre pariterre merged commit b92f9cc into pyomeca:master Aug 8, 2022
@aceglia aceglia deleted the Acados_interface branch August 9, 2022 13:34
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

2 participants