## Design Optimization to Track Reference Signal (GUI)

This example shows how to optimize controller parameters to track a reference signal using the Response Optimizer. You specify the reference signal without adding any Check blocks to the model.

### Model Structure

The model `sldo_model1` includes these blocks:

• Controller block, a PID controller, controls the output of the `Plant` subsystem.

• Unit Step block applies a step input.

You can also use other types of inputs, such as ramp, to optimize the response generated by such inputs.

• Plant subsystem is a second-order system with delay. It contains Transfer Function and Transport Delay blocks.

### Design Requirements

The model output must track a reference signal $y=1-\mathrm{exp}\left(-0.1×t\right)$, where t is time.

### Specify Reference Signal

```sys = 'sldo_model1'; open_system(sys);```

2. To open the Response Optimizer, in the Simulink model window, from the Apps tab, in the gallery, under Control Systems, select Response Optimizer.

3. Select the model signal to track the reference signal.

1. In the drop-down list, select Signal to open the Create Signal Set window.

2. To display the signal in the window, click the output of the Plant block in the Simulink model window.

3. Select the signal, and click to add it to the signal set.

4. In Signal set, enter `PlantOutput` as the selected signal name.

Click to create the variable `PlantOutput`. It appears in the Data area of the Response Optimizer.

4. Specify the reference signal for the model output to track.

1. In the New drop-down list, select Signal Tracking to open a Create Requirement window.

2. In the Name edit box, enter `ref_sig`.

3. In the Time vector edit box, enter `linspace(0,50,200)`

4. In the Amplitude edit box, enter `1-exp(-0.1*linspace(0,50,200))`.

Leave the Tracking Method as `SSE` which means, at each optimization iteration, the solver attempts to reduce the sum of squared errors between the simulated output and reference signal.

5. Click .

6. In the Specify Signal to Track Reference Signal area, select the check-box corresponding to the signal you selected in the previous step, and click .

A new reference signal`ref_sig` is created and appears in the Data area. The Response Optimization window updates to plot the reference signal.

### Specify Design Variables

When you optimize the model response, the software modifies the design variable values to meet the design requirements.

In the Response Optimization tab:

1. Create a new set of design variables.

In the Design Variables Set drop-down list select New.

The Create Design Variables Set window shows model parameters that you can use as design variables and indicates their locations within the model subsystems.

2. Add parameters to the design variables set.

Select `Kd`, `Ki`, and `Kp`, and click to add the selected parameters.

The design variables list displays the following parameter settings:

• Variable — Parameter name

• Value — Current parameter value

• Minimum and Maximum — Parameter bounds

• Scale — Scaling factor for the parameter

3. Limit the parameters to positive values. To do so, enter `0` for the minimum value of each parameter in the corresponding Minimum field, and press on your keyboard.

Click . A new design variable `DesignVars` is created and appears in the Data area of the Response Optimizer.

### Optimize Model Response

1. To view the current model response, click Plot Model Response.

The plot shows that the model response does not track the reference signal.

2. Click Optimize.

At each iteration, the optimization solver `Gradient descent` (`fmincon`) modifies the controller parameters to minimize the error between the simulated response and the reference signal. To learn more, see How the Optimization Algorithm Formulates Minimization Problems.

The message `Optimization converged` in the Optimization Progress Report indicates that the optimization method found a solution that tracks the reference signal within the tolerances and parameter bounds. For more information about the outputs displayed in the Optimization Progress Report, see Iterative Display.

3. Verify that the response tracks the reference signal by observing the amplitude versus time plot.

The optimized response closely tracks the reference signal.

4. To view the optimized parameter values, click `DesignVars` in the Data area of the Response Optimizer. View the updated values in the Variable Preview area.

The optimized values of the design variables are automatically updated in the Simulink model.