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] fix: parameter objective need parameters decision variables in any scenario right ? #930

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Ipuch
Copy link
Collaborator

@Ipuch Ipuch commented Feb 25, 2025

I've built an example on top of your example @EveCharbie. The Idea is to have an objective with the parameter in it to see it evolve through the iterations of IPOPT, to see if the sol output is the same as the one of IPOPT.

While I had only one objective, the objective was not taken into account. I manage to do a quick fix, with no ideas of the consequences. Some choices may have some rational and need to be discussed in the next PR Review @pariterre

@p-shg, you can build on top of this PR to see through ipopt how the scaling affect the parameter.

On top of :


This change is Reviewable

@Ipuch Ipuch added the enhancement New feature or request label Feb 25, 2025
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 77.75%. Comparing base (e7494ca) to head (55c410e).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
bioptim/optimization/parameters.py 81.25% 3 Missing ⚠️
bioptim/interfaces/interface_utils.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #930      +/-   ##
==========================================
+ Coverage   77.62%   77.75%   +0.12%     
==========================================
  Files         156      156              
  Lines       18035    18040       +5     
==========================================
+ Hits        14000    14027      +27     
+ Misses       4035     4013      -22     
Flag Coverage Δ
unittests 77.75% <76.47%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Ipuch Ipuch changed the title fix: parameter objective need need parameters decision variables in any scenario right ? fix: parameter objective need parameters decision variables in any scenario right ? Feb 25, 2025
@Ipuch Ipuch added the bug Something isn't working label Feb 25, 2025
@Ipuch Ipuch changed the title fix: parameter objective need parameters decision variables in any scenario right ? [RTR] fix: parameter objective need parameters decision variables in any scenario right ? Feb 25, 2025
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 3 of 4 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Ipuch)


bioptim/optimization/parameters.py line 304 at r2 (raw file):

    def unscaled(self):
        """
        This method allows to intercept the scaled item and return the current node_index

Add a comment:

The return parameters is actually the scaled version of it. But for internal reasons, it is expected. This can be confusing for the user who expects an unscaled version though. Therefore, .unscaled should only be call by the programmer who knows what there are doing


bioptim/examples/getting_started/example_parameter_scaling.py line 183 at r2 (raw file):

    g_scaling = VariableScaling("gravity_xyz", np.array([1, 1, 10]))  # Does not converge to the right place
    #  "Optimal parameters unscaled: {'gravity_xyz': array([ 0.        ,  5.00000002, -4.9999999 ])}"
    #  "Optimal parameters scaled: {'gravity_xyz': array([ 0.        ,  5.00000002, -0.49999999])}"

remove this


bioptim/examples/getting_started/example_parameter_scaling.py line 213 at r2 (raw file):

    dynamics = Dynamics(
        DynamicsFcn.TORQUE_DRIVEN,
        # state_continuity_weight=100,

Reinstate


bioptim/interfaces/interface_utils.py line 388 at r2 (raw file):

        p = PenaltyHelpers.parameters(
            penalty, penalty_idx, lambda p_idx, n_idx, sn_idx: _get_p(ocp, p_idx, n_idx, sn_idx, scaled)
        )

test this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants