Response optimization (Defining independent parameters)

2 次查看(过去 30 天)
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 http://www.mathworks.com/help/toolbox/sldo/ug/brzompd_1.html ).
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?
Regards,
Ismail

回答(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 个评论
Ismail Delice
Ismail Delice 2012-1-11
Thank a lot for your comment. I did the similar trick that you advised so that I could add x and y as tunable parameters. But still mdl file is not running due to "attempt to modify read only model workspace". x = wks.evalin('x') in StartFnc* is trying to modify the x variable, which is my aim, but I think it is impossible (check http://www.mathworks.com/help/toolbox/simulink/rn/bsjn1am-1.html: Model Workspace Is Read-Only During Compilation During the compilation of a model, Simulink enforces that the model workspace is read-only, by issuing an error if there is an attempt to change a model workspace variable during compilation. This enforcement of a read-only workspace prevents the simulation from failing or producing incorrect results due to changes to the model workspace.). I also tried wks.assignin('x', wks.data.Value), which results the same problem.
Is it possible to optimize independent variables with the available Simulink design optimization toolbox?
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
Hi,
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!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Parameter Estimation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by