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

Custom parameter bound issue when using multiple phases #783

Open
tiagocoelhoma opened this issue Oct 24, 2023 · 3 comments
Open

Custom parameter bound issue when using multiple phases #783

tiagocoelhoma opened this issue Oct 24, 2023 · 3 comments

Comments

@tiagocoelhoma
Copy link

Hello!

I had some problems trying to implement a custom parameter while using multiphase.
In order to get help from you, I replicate the problem by modifying the custom_parameter example for multiphase.

customParam.zip

The error i get is:
TypeError: BoundsList['gravity_xyz'] is ambiguous because there are multiple phases. To access the boundaries in this case, you should write BoundsList[phase]['gravity_xyz'] instead of BoundsList['gravity_xyz']. If you didn't mean to use multiple phases, you may have specified BoundsList['gravity_xyz'] or BoundsList.add('gravity_xyz', ...) twice.

Thank you.

@pariterre
Copy link
Member

Dear @tiagocoelhoma

Based on what you sent, you are trying to redefine gravity at each phase. However, they is currently no such thing in bioptim as "phase parameter" (i.e. a parameter applied to the duration of a phase). All the parameters are "ocp parameters" (i.e. a parameter applied to the full scope of the program). There is therefore no such thing as setting bounds to a single phase as such:

parameter_bounds.add(
    "gravity_xyz",
    ...
    phase=i  # This cannot be defined
)

That said, phase parameters is precisely something I was planning to implement this week as we need it for the phase time.

Therefore, if you need phase parameters, I suggest to stay tune as it should be available soon :) If you only need paramaters that are defined ocp wide, it is already the case, just remove you for loop around the definition of the gravity_xyz parameter

Hope this helps

@tiagocoelhoma
Copy link
Author

Dear @pariterre

thank you for the answer. The example I implemented with gravity was only intended to replicate the errors I am getting in my other problem, which has to have parameters defined for each phase. I understood that I could implement it because, in the documentation, it says:

The bounds are the maximal and minimal values of the parameter. The size is the number of elements of this parameter. If an objective function is provided, the return of the objective function should match the size. The phase that the parameter applies to. Even though a parameter is time-independent, one biorbd_model is loaded per phase. Since parameters are associated to a specific bio_model, one must define a parameter per phase.

Ps: the part "The phase that the parameter applies to." I dont really get it.

So, as I understood, I should be tuned. :)

Thank you once again.

@pariterre
Copy link
Member

Since parameters are associated to a specific bio_model, one must define a parameter per phase.`

This sentence refers to the dynamic model (and not the parameter itself). That is, if your parameter is modifying your dynamic model (as gravity does), you must manually apply this parameter to all the dynamic models (i.e. the bioMod of each phase). Maybe we should have written one must apply the parameter at each phase.

The phase that the parameter applies to.

This is probably a legacy sentence haha

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

No branches or pull requests

2 participants