Hi Thomas,
I am currently using SconePy to run a large number of optimizations. For each optimization, I need to modify specific controller parameters within MuscleReflex (e.g., KL, L0, KF, C0) in the following hierarchy:
GaitStateController --> ConditionalControllers --> ConditionalController --> ReflexController --> MuscleReflex
My question is: is there a way to directly access and modify these parameters using SconePy?
I have tried using the scenario.set() function as demonstrated in the Batch Optimization Tutorial. However, instead of modifying the existing MuscleReflex parameters, it adds a new ConditionalController at the end of the script.
Is there a recommended way to achieve this?
Thank you in advance for your help!
Best regards,
Mustafa
Modifying MuscleReflex Parameters with SconePy
- Mustafa Kamal
- Posts: 4
- Joined: Tue Apr 30, 2024 3:51 am
- Thomas Geijtenbeek
- Posts: 473
- Joined: Wed Mar 12, 2014 8:08 am
Re: Modifying MuscleReflex Parameters with SconePy
In cases where multiple child elements have the same name, you can use the "#n" notation to get the n-th child element.
For example, after loading the "Gait2D - GeyerHerr2010" example, you can use the following code to change the second ConditionalController:
This will set the KF of the first ReflexController in the second ConditionalController.
IMPORTANT: the element you are setting must already exist in the .scone file.
Let me know if this helps!
For example, after loading the "Gait2D - GeyerHerr2010" example, you can use the following code to change the second ConditionalController:
Code: Select all
scenario.set("CmaOptimizer.SimulationObjective.GaitStateController.ConditionalControllers.#2.ReflexController.#1.KF", str(value))
IMPORTANT: the element you are setting must already exist in the .scone file.
Let me know if this helps!
- Mustafa Kamal
- Posts: 4
- Joined: Tue Apr 30, 2024 3:51 am
Re: Modifying MuscleReflex Parameters with SconePy
Hi Thomas,
Yes, it worked perfectly, thank you for the clarification!
I was also wondering: is there a way to read or get the parameters using a function in SconePy, similar to how we use scenario.set() to modify them?
I also noticed this functionality is not mentioned in the SconePy documentation. Is there a reason for this, or is it planned to be included in future updates?
Thank you again for your help!
Best regards,
Mustafa
Yes, it worked perfectly, thank you for the clarification!
I was also wondering: is there a way to read or get the parameters using a function in SconePy, similar to how we use scenario.set() to modify them?
I also noticed this functionality is not mentioned in the SconePy documentation. Is there a reason for this, or is it planned to be included in future updates?
Thank you again for your help!
Best regards,
Mustafa
- Thomas Geijtenbeek
- Posts: 473
- Joined: Wed Mar 12, 2014 8:08 am
Re: Modifying MuscleReflex Parameters with SconePy
The SconePy documentation indeed isn't up-to-date yet, unfortunately. Until then, the best way to see all functionality is via the Python "help" function.
It indeed makes sense to also have a scenario.get() function, so I added it Thanks for the suggestion!
It will be available in SCONE 2.4.1, but you can contact me via email if you would like a preview release with this functionality included.
If you have any other suggestions for the SconePy API, please let me know!
It indeed makes sense to also have a scenario.get() function, so I added it Thanks for the suggestion!
It will be available in SCONE 2.4.1, but you can contact me via email if you would like a preview release with this functionality included.
If you have any other suggestions for the SconePy API, please let me know!