Parameter values for variant subsystem

2 views (last 30 days)
Markus
Markus on 5 Jun 2020
Commented: Fangjun Jiang on 8 Jun 2020
The demo in sldemo_variant_subsystems contains a variant subsystem with a linear and a nonlinear controller. The controller variant is set by the base workspace variable VSS_MODE.
If we assume the linear controller has parameter values for a P, I and D term and there are different tuning variants, e.g. 'aggressive' and 'soft'. What would be a good way to set these parameter values? Please also consider, for the nonlinear controller it would not be necessary to set these parameter values.
Here is my best solution I can think of:
  • Have another base workspace variable for the tuning
  • Set the model workspace source to 'Matlab File'
  • In the Matlab file set the P, I and D values dependent on the tuning base workspace variable
  • Use the reload function for the model workspace when the tuning is changed
Would this work? Any better solution?
Thanks!

Answers (1)

Fangjun Jiang
Fangjun Jiang on 5 Jun 2020
All the parameters for the linear controller and non-linear controller need to be provided (could be in base workspce, or model workspace, or data dictionary). Although only one variant could be active at any time, certain model operations are conducted on "all variants", thus all parameters are needed.
Tuning parameters is a different aspect than variants. You can use whatever methods (a differet set of M-file, mat file or command line) to switch a differnet set of PID parameters. But since you only have one variant for linear controller, the PID parameters can only have one set of values at any time. If you want to have a way to switch between "aggressive" or "soft" PID controller, then you will need to have three variants, "aggressive linear", "soft linear" and "non-linear".
  2 Comments
Markus
Markus on 8 Jun 2020
Thanks for the reply!
Just to clarify, I don't need to change tunign during simulation, just in between simulations.
Is there a recommended way to handle tuning variants when these parameters are kept in the model workspace? Have a script for each tuning variant to set them?
I am looking for a recommendation to keep my tunign variants and subsystem variants organized.
Fangjun Jiang
Fangjun Jiang on 8 Jun 2020
If you implemented it through variants, then between simulations, you could switch from "aggressive" to "soft" linear controller. All the parameters (beyond the PID gains, everything incide the controller, or you could use P_Gain_Soft for one, P_Gain_Aggr for another, but share common D_Gain_Comm) are instantly switched.
If you don't have variants, then you could load or change any parameter values in any workspace in between simulations. But all the parameter names are the same, you just change the parameter values. There is no easy way to indicate which values are changed. There is no guarantee there won't be anything mixed up. Simply put, there is no systematic way to manage tuning a set of parameters.
I would say the recommendation to handle tuning parameters is to use variants.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!