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 the *design
variables set* for optimization. By tuning these parameters, Simulink^{®} Design Optimization™ software
attempts to make the signals meet the requirements.

Simulink Design Optimization software 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.

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, the **Proportional (P)** and **Integral
(I)** gain parameters of a PID Controller block
are specified as numerical values.

To optimize the gain parameters, specify them as variables `Kp`

and `Ki`

:

Create the variables

`Kp`

and`Ki`

in one of the following ways:Add the variables to the model workspace, and specify initial values.

Write initialization code in the

**PreloadFcn**callback of the model. For more information, see Model Callbacks.Kp = 1; Ki = 1;

Specify the gain parameters as the variables

`Kp`

and`Ki`

in the PID Controller block dialog box.

You can now select `Kp`

and `Ki`

for
optimization. See, Specify Design Variables.

To specify the parameters to be tuned using the Response Optimization tool:

In the

**Design Variables Set**list, select**New**.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, click

**Update model variable values**to 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 an 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).

Expand

**Variable Detail**to see the block in the model that contains this parameter.Click

**OK**to create a design variable set.

Was this topic helpful?