Specify Design Variables
This topic shows how to specify design variables for optimization.
Before running the optimization, you must specify the model parameters to optimize. These parameters form thedesign variables setfor optimization. By tuning these parameters,万博1manbetx®Design Optimization™software attempts to make the signals meet the requirements.Simulink Design Optimizationsoftware optimizes the response signals of the model by varying the tuned parameters so that the response signals lie within the constraint bound segments or closely match a specified reference signal. The design variables can be scalar, vector, matrix, or an expression that evaluates to one of these values.
You can also use敏感性分析for finding the parameters that most influence the optimization problem and use these as design variables. To open theSensitivity Analyzer, in theResponse Optimizationtab, clickSensitivity Analysis. In theSensitivity Analyzerapp, you can explore the response optimization design space by altering the design variables, identify the parameters that most influence the optimization problem, and compute initial values.
Add Model Parameters as Variables for Optimization
The software can only optimize variables that are in use by the Simulink model. Create variables for optimization in the MATLAB®or model workspace, and specify your model or block parameters using these variables.
In this figure, theProportional (P)andIntegral (I)gain parameters of aPID Controllerblock are specified as numerical values.
To optimize the gain parameters, specify them as variablesKp
andKi
:
Create the variables
Kp
andKi
in one of the following ways:Add the variables to the model workspace,并指定初始值。
Write initialization code in thePreloadFcncallback of the model. For more information, seeModel Callbacks.
Kp = 1; Ki = 1;
Specify the gain parameters as the variables
Kp
andKi
in thePID Controllerblock dialog box.
You can now selectKp
andKi
for optimization. See,Specify Design Variables.
Specify Design Variables
To specify the parameters to be tuned using theResponse Optimizer:
In theDesign Variables Setlist, selectNew.
A window opens where you specify design variables. All parameters in use by the model are displayed in this window.
Select one or more parameter names and click
to add the selected parameters to a design variables set.
Note
You can add the same parameter to multiple design variable sets.
(Optional) Specify design variable settings.
Setting Description Default Variable
The name of the parameter.
Not an editable field
Value
Value of the model parameter. This value is used by the optimization method as the initial value and is modified during optimization.
Current value of the parameter in the model. If you edit this column, clickUpdate model variable valuesto update the values in the model.
Minimum
The minimum value or lower bound for the parameter. You can edit this field to provide an alternate minimum value.
-Inf
Maximum
The maximum value or upper bound for the parameter. You can edit this field to provide an alternate maximum value.
Inf
Scale
During optimization, the design variables are scaled, or normalized, by dividing their current value by a scale value. You can edit this field to provide an alternate scaling factor.
Next power of 2 greater than the current value of the parameter
The check-box indicates whether the parameter is selected as a design variable in the set. Select it if you want this parameter to be tuned during the optimization. Deselect if you do not want this parameter to be tuned during the optimization but you would like to keep it on the list of tuned parameters (for a subsequent optimization).
ExpandVariable Detailto see the block in the model that contains this parameter.
ClickOKto create a design variable set.
If your model contains referenced models, you can select the referenced variables from theCreate Design Variables Setdialog box. For example, the first variable in the dialog box,Slew
, is listed assdoRateLimitedController:Slew
.sdoRateLimitedController
is the name of the referenced model with the variableSlew
. TheSlew
variable has the same value for all instances of thesdoRateLimitedController
model. In contrast, the variableKd
can have a different value for each instance of the referenced model containing it. For example, the second variable in the dialog box is listed assdoMultipleMotors/Control_1:Kd
. The upper-level modelsdoMultipleMotors
has blockControl_1
, which is a referenced model that has variableKd
. The value of this variable can be different thanKd
in blockControl_2
, which is the third variable in the dialog box. To enable instance-specific values,Kd
is specified as a model argument in the referenced model workspace.