Response optimization (Defining independent parameters)

2 ビュー (過去 30 日間)
Ismail Delice
Ismail Delice 2012 年 1 月 10 日
My aim is to optimize independent variables like the example depicted in user guide of the Simulink Design Optimization Toolbox ( check Specify Independent Parameters to Estimate (GUI) in ).
I tried the same example, but I could not add x and y variables as tuning parameters? What could be wrong in the example?
wks = get_param(gcs, 'ModelWorkspace')
x = wks.evalin('x')
y = wks.evalin('y')
Kint = x+y;
I think, second line of the above code is not working?

回答 (2 件)

Alec Stothert
Alec Stothert 2012 年 1 月 11 日
The tool detects tuning parameters by determining what variables are used by the model. In this case the tool cannot detetct that x and y are used by the model (they dont appear in any block masks).
The easiest fix is to add a block to the model that uses x and y, the block doesn’t need to influence the model computation it just needs to be there so that the variables are “used” by the model, for example add a constant block with a terminator.
  2 件のコメント
Alec Stothert
Alec Stothert 2012 年 1 月 12 日
Remove 'srotut1_start' from the model StartFcn and put it in the model InitFcn. The InitFcn runs before compilation has started and should avoid the error you mention.
This coupled with the earlier trick should allow you to optimize independent variables.


Ismail Delice
Ismail Delice 2012 年 1 月 14 日
Finally, I figured out to optimize independent variables (x and y in user guide) and I would like to share my findings.
First of all, add a constant block for [x y] and connect it to a display. Now, x and y variables can be added with 'add panel' in response optimization. You should not add any variables in ModelWorkspace since it is read only and 'add panel' cannot reach that area.
Secondly, define the relation (Kint = x+y in user guide) in File\Model Properties\InitialFnc* not in StartFnc* as depicted in user guide.
Thus, one can optimize x and y in order to find optimal Kint value, but you have to set Kint as x+y (run Kint = x+y) after completion of optimization.
  1 件のコメント
Marcel Clementino
Marcel Clementino 2012 年 2 月 22 日
I've tried this, but I didn't get the expected results.
When I do what you said, it shows an error message saying that my independent variable is undefined.
If I create the variable in the ModelWorkspace, I can run the simulation, but this variable doesn't change along the optimization process. I don't know what I am doing wrong. This are the steps that I followed when I could ran the simulation:
1- add a constant block;
2- write the function name (after defining it) in the Model Properties\InitialFnc*.
The function contains:
wks = get_param(gcs, 'ModelWorkspace');
Lb = wks.evalin('Lb');
3-add this variable as design variable at the Simulink Optimization Variable.
Hope you can help me!
Thanks for this post, it helped me a lot!



Find more on Parameter Estimation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by