Products & Services Solutions Academia Support User Community Company

Learn more about Simulink Design Optimization   

Optimizing Parameters Using the GUI

Constraining Model Signals

Simulink Design Optimization software works by adjusting parameters in a Simulink model so that chosen response signals within the system behave in a specified way. You choose the signals that you want to shape or constrain by attaching Signal Constraint blocks to them. The constraints on the behavior of the response signals and the tuned parameters are set within the Signal Constraint blocks.

The first step in the response optimization process is to choose which signals in your Simulink model you would like to constrain and to attach Signal Constraint blocks to these signals.

Once you have selected signals to constrain, you need to attach a Signal Constraint block to each of these signals. You can find the Signal Constraint block in the Simulink Design Optimization library in the Simulink Library Browser. Alternatively, you can open Simulink Design Optimization library by typing sdolib at the MATLAB prompt.

To attach a Signal Constraint block to a signal in your model, drag the block from the block library into the model and join the signal line to the inport of the Signal Constraint block. A model can include multiple Signal Constraint blocks, and you can attach the Signal Constraint block to any signal, including signals within subsystems of your model.

Double-click a Signal Constraint block to open the Signal Constraint window associated with it. Within this window you can specify the constraints imposed on the signal. For more information, see Specifying Design Requirements. You can also specify parameters to optimize and optimization settings in this block.

Although you must specify the constraints for each signal individually within each Signal Constraint block, you only need to set the remaining settings such as tuned parameters and optimization settings within one Signal Constraint window as they apply to the whole project.

Opening a Signal Constraint window, automatically creates a response optimization project. The project consists of the following information:

A response optimization project exists within a single model; there are no cross-model projects. Additionally, although you can create different sets of constraints and tuned parameters and save these as different response optimization projects, you can only associate one project with the model at any time.

The remaining steps involved in specifying the settings of a response optimization project are discussed in the following sections:

To save the project for use in a later session, see Saving and Loading Response Optimization Projects.

Specifying Design Requirements

What Are Design requirements

Design requirements include the positions of the constraint bound segments and reference signals specified in the Signal Constraint block. The constraints are used in a response optimization project to define the region in which the response signal must lie.

Enforcing Signal Bounds

You can specify the desired response of a signal by enforcing signal bounds or by tracking a reference signal. To enforce signal bounds, select this option at the bottom of the Signal Constraint window, and then position time-domain-based constraint bound segments in the Signal Constraint window. To track a reference signal, select this option at the bottom of the Signal Constraint window, and then plot the signal in the Signal Constraint window. This section provides further details on both methods as well as instructions for editing the figure axes and plotting additional responses.

To specify the desired response signal using time-domain-based constraints, first select the Enforce signal bounds option at the bottom of the Signal Constraint window. Then, constrain the response signal by positioning the constraint bound segments within the figure axes using the following techniques.

When using a Signal Constraint block to directly optimize a Simulink model, by default, the start and stop time are inherited from the Simulink model. However, you can change them with the Simulation Options dialog box. Choose a stop time that captures enough of the desired response's characteristics. When you want the response to settle to a final value, use at least 10 to 20% of the simulation time for constraining the steady-state response. This ensures the proper weighting of requirements on the final value and overall stability.

Moving Constraints

Constraint-bound segments define the time-domain constraints you would like to place on a particular signal in your model. To position these segments, which appear as a yellow shaded region bordered by a black line, use the mouse to click and drag segments within the Signal Constraint window as shown in the following figure.

To use these constraints to optimize signal responses, make sure that the Enforce signal bounds check box is selected at the bottom of the window.

Including Gridlines on the Axes

When moving constraint bound segments in the Signal Constraint window, it is sometimes helpful to display gridlines on the axes for careful alignment of the constraint bound segments. To turn the gridlines on or off, right-click within the axes of the Signal Constraint window and select Grid.

Positioning Constraints Exactly

To position a constraint segment exactly, position the pointer over the segment you want to move and press the right mouse button. Select Edit from the menu to open the Edit Design Requirement dialog box, shown next. For information on using the Edit Design Requirement dialog box, see Edit Design Requirement Dialog Box.

Adjusting Constraint Weightings

To change the weight of a constraint segment, position the pointer over the segment you want to weight and click the right mouse button. Select Edit from the menu to open the Edit Design Requirement dialog box, shown next. For information on using the Edit Design Requirement dialog box, see Edit Design Requirement Dialog Box.

Edit Design Requirement Dialog Box

The Edit Design Requirement dialog box allows you to exactly position constraint segments and to edit other properties of these constraints. The dialog box has two main components:

The upper panel of the Edit Design Requirement dialog box resembles the image in the following figure.

In the context of the SISO Tool in Control System Toolbox™ software, Design requirement refers to both the particular editor within the SISO Tool that contains the requirement and the particular requirement within that editor. To edit other constraints within the SISO Tool, select another design requirement from the drop-down menu. In the context of the Signal Constraint block, the constraints are always time-bound constraints.

Edit Design Requirement Dialog Box Parameters.   The particular parameters shown within the lower panel of the Edit Design Requirement dialog box depend on the type of constraint/requirement. In some cases, the lower panel contains a grid with one row for each segment and one column for each constraint parameter. The following table summarizes the various constraint parameters.

Edit Design Requirement Dialog Box Parameters

ParameterFound inDescription
TimeUpper and lower time response bounds on step and impulse response plotsDefines the time range of a segment within a constraint/requirement.
AmplitudeUpper and lower time response bounds on step and impulse response plotsDefines the beginning and ending amplitude of a constraint segment.
MagnitudeSISO Tool Open-Loop Bode Editor, Prefilter Bode EditorDefines the beginning and ending amplitude of a constraint segment.
WeightUpper and lower time response bounds on step and impulse response plots, SISO Tool Open-Loop Bode Editor, Prefilter Bode Editor, Root Locus Editor, Open-Loop Nichols EditorDefines the weight of a segment within a constraint/requirement. The weight is a measure of the relative importance of this constraint segment when used in a response optimization project. Weights can vary between 0 and 1, where 0 implies that the constraint segment is disabled and does not have to be satisfied, and 1 implies that the constraint segment must be satisfied. The weight of a constraint segment is graphically represented by the thickness of the black constraint line. An invisible constraint segment represents a weight of 0, and a thick constraint segment represents a weight of 1.
FrequencySISO Tool Open-Loop Bode Editor, Prefilter Bode EditorDefines the frequency range of an edge within a constraint.
Slope (dB/decade)SISO Tool Open-Loop Bode Editor, Prefilter Bode EditorDefines the slope, in dB/decade, of a constraint segment. It is an alternative method of specifying the magnitude values. Entering a new Slope value changes any previously defined magnitude values.
Final valueStep response boundsDefines the input level after the step occurs.
Rise timeStep response boundsDefines a constraint segment for a particular rise time.
% RiseStep response boundsThe percentage of the step's range used to describe the rise time.
Settling time <SISO Tool Root Locus EditorDefines a constraint segment for a particular settling time.
Settling timeStep response bounds
% SettlingStep response boundsThe percentage of the final value that defines the settling region used to describe the settling time.
Percent overshoot <SISO Tool Root Locus EditorDefines the constraint segments for a particular percent overshoot.
% OvershootStep response bounds
% UndershootStep response boundsDefines the constraint segments for a particular percent undershoot.
Damping ratio >SISO Tool Root Locus EditorDefines the constraint segments for a particular damping ratio.
Natural frequencySISO Tool Root Locus EditorDefines a constraint segment for a particular natural frequency. To specify the constraint, choose at least or at most from the menu, and then specify the natural frequency of interest.
RealSISO Tool Root Locus EditorDefines the beginning and end of the real component of a pole-zero region constraint.
ImaginarySISO Tool Root Locus EditorDefines the beginning and end of the imaginary component of a pole-zero region constraint.
Phase margin >SISO Tool Open-Loop Nichols EditorDefines a constraint segment for a minimum phase margin. The phase margin specified should be a number greater than 0.
Located atSISO Tool Open-Loop Nichols EditorDefines the center, in degrees, of the constraint segment defining the phase margin, gain margin, or closed-loop peak gain. The location must be -180 plus a multiple of 360 degrees. If you enter an invalid location point, the closest valid location is selected.
Gain margin >SISO Tool Open-Loop Nichols EditorDefines a constraint segment for a particular gain margin.
Closed-Loop peak gain <SISO Tool Open-Loop Nichols EditorDefines a constraint segment for a particular closed-loop peak gain. The specified value can be positive or negative in dB. The constraint follows the curves of the Nichols plot grid, so we recommend that you have the grid on when using this feature.
Open loop phaseSISO Tool Open-Loop Nichols EditorDefines the beginning and end of the open loop phase component of a gain-phase constraint segment.
Open loop gainSISO Tool Open-Loop Nichols EditorDefines the beginning and end of the open loop gain component of a gain-phase constraint segment.

Scaling Constraints

Instead of clicking and dragging the constraints to their new positions, you can scale the constraints. To scale the constraints, select Edit > Scale Constraint in the Signal Constraint window. This displays the Scale Constraint dialog box.

Enter the amount by which you want the constraints to scale and the point about which you want to scale them, and then click OK.

Splitting and Joining Constraints

To split a constraint segment, position the pointer over the segment to be split, and press the right mouse button. Select Split from the context menu. The segment splits in half. You can now manipulate each segment individually.

To join two neighboring constraint segments, position the pointer over one constraint segment, and press the right mouse button. Select Join left or Join right from the menu to join the segment to the left or right respectively.

Choosing Step Response Specifications

When you are optimizing the step response of your system, an alternative method of positioning the constraint bound segments is to specify the desired step response characteristics such as rise time, settling time, and overshoot.

To specify step response characteristics, select Goals > Desired Response in the Signal Constraint window or right-click in the white space of the figure window and select Desired Response from the context menu. This displays the Desired Response dialog box. Select Specify step response characteristics to display the step response specifications as shown in the following figure.

The top three options specify the details of the step input:

The remaining options specify the characteristics of the response signal. Each of the step response characteristics is illustrated in the following figure.

Enter values for the response specifications in the Response Specifications dialog box, based on the requirements of your model, and then click OK. The constraint segments now reflect the constraints specified.

Tracking Reference Signals

Specifying a Reference Signal.   You can specify the desired response as an ideal or reference trajectory. First, select the Track reference signal option at the bottom of the Signal Constraint window. Then, plot the reference signal within the figure axes using the following techniques. You can use this reference signal in addition to, or instead of, enforcing signal bounds.

Plotting the Reference Signal.   Plot a reference signal by selecting Goals > Desired Response in the Signal Constraint window or by right-clicking in the white space of the figure window and selecting Desired Response from the context menu. This displays the Desired Response dialog box. Select the radio button labeled Specify reference signal to display the reference signal setup as shown in the following figure.

Define the reference signal by entering vectors, or variables from the workspace, for the time and amplitude of the signal, and then clicking OK. To turn the reference signal on or off, right-click in the white space of the figure window and select Show > Reference Signal.

Specifying Parameters to Optimize

Defining Tunable Parameters

Before running the optimization, you must define which system parameters are tunable. By tuning these parameters, Simulink Design Optimization software makes the response signal meet the imposed constraints. In addition, you can define uncertain parameters to account for plant uncertainty in your response optimization project. The tunable and uncertain parameters can be scalar, vector, or matrix.

Simulink Design Optimization software optimizes the response signals of the model by varying the model's tuned parameters so that the response signals lie within the constraint bound segments or closely match a specified reference signal. You can specify these tuned parameters by selecting Optimization > Tuned Parameters in a Signal Constraint window.

Adding Tuned Parameters

Within the Tuned Parameters dialog box, the tuned parameters are shown in a list on the left. To add a tuned parameter to your response optimization project, click the Add button. This action opens the Add Parameters dialog box which lists all model parameters currently available in the MATLAB workspace.

Select the parameters that you want to tune, then click OK to add them to the Tuned parameters list. To delete a parameter from the Tuned parameters list, select the parameter you want to delete and click Delete.

Changing Tuned Parameter Specifications

To display the settings for a particular tuned parameter, select it within the Tuned Parameters list. Its settings appear on the right under Optimization Settings, as listed in the following table.

SettingDescriptionDefault

Name

The name of the parameter.

Not an editable field

Value

The current value of the parameter.

Not an editable field

Initial guess

The initial value used by the optimization method. A well-chosen initial guess can speed up the optimization and help keep the solution away from undesirable local minima. You can edit this field with numbers, variables, or expressions to provide an alternate initial guess.

The current value of the parameter

Minimum

The minimum value, or lower bound, that you would like the parameter to take. You can edit this field to provide an alternate minimum value.

-Inf

Maximum

The maximum value, or upper bound, that you would like the parameter to take. You can edit this field to provide an alternate maximum value.

Inf

Typical value

The tuned parameters are scaled, or normalized, by dividing their current value by a typical value. You can edit this field to provide an alternate scaling factor.

The initial value of the parameter

Tuned

This check box indicates whether this parameter is tunable. Select it if you want this parameter to be tuned during the optimization. Unselect 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).

Selected

Referenced by

A list of all blocks this parameter appears in.

Not an editable field

After selecting the tuned parameters for the project and editing their optimization settings, click OK to save your changes and exit the Tuned Parameters dialog box.

Specifying Independent Parameters

Sometimes parameters in your model depend on independent parameters that do not appear in the model. The following steps give an overview of how to tune and include uncertainty in these independent parameters. example follows in the next section:

  1. Add the independent parameters to the model workspace (along with initial values).

  2. Define a Simulation Start function that runs before each simulation of the model. This Simulation Start function defines the relationship between the dependent parameters in the model and the independent parameters in the model workspace.

  3. The independent parameters now appear in the Add Parameters dialog box when you select Tuned parameters or Uncertain parameters. Add these parameters to the list of tuned parameters to tune them during the response optimization.

      Caution   Avoid adding independent parameters together with their corresponding dependent parameters to the lists of tuned and uncertain parameters. Otherwise, the optimization could give incorrect results. For example, when a parameter x depends on the parameters a and b, avoid adding all three parameters to the lists of tuned and uncertain parameters.

Example — Specifying Independent Parameters

Assume that the parameter Kint in the model srotut1 is related to the parameters x and y according to the relationship Kint=x+y. Also assume that the initial values of x and y are 1 and -0.7, respectively. To tune x and y instead of Kint, first define these parameters in the model workspace. To do this,

  1. Select View > Model Explorer from the srotut1 window.

  2. Select Model Workspace under the srotut1 node in the tree browser within the Model Explorer window.

  3. Select Add > MATLAB Variable within the Model Explorer to add a new variable to the model workspace. A new variable appears within the pane labeled Contents of: Model Workspace. Change the variable name to x and the initial value to 1.

  4. Repeat step 3 to add a variable y with an initial value of -0.7. The Model Explorer window should now look like the following figure.

  5. To add the Simulation Start function defining the relationship between Kint and the independent parameters x and y, select File > Model Properties in the srotut1 window, and then select Callbacks in the Model Properties dialog box.

  6. Under Simulation start function, enter the name of a new M-file, for example, srotut1_start.

  7. Create a new M-file with this name. The contents of the M-file should define the relationship between the parameters in the model and the parameters in the workspace. For this example, the M-file should look something like the following:

    wks = get_param(gcs, 'ModelWorkspace')
    x = wks.evalin('x')
    y = wks.evalin('y')
    Kint = x+y;
    

      Note   You must first use the get_param function to get the variables x and y from the model workspace before you can use them to define Kint.

  8. When you add a new tuned or uncertain parameter, x and y should now appear in the Add Parameters dialog box.

Specifying Optimization Options

Accessing Optimization Options

Several options can be set to tune the results of optimization. These options include the optimization methods and the tolerances the methods use.

To set options for optimization, select Optimization > Optimization Options in the Signal Constraint window. This opens the Options dialog box.

Selecting Optimization Methods

Both the Method and Algorithm options define the optimization method. Use the Optimization method area of the Options dialog box to set the optimization method and its algorithm.

For the Method option, the three choices are:

The following table summarizes the Algorithm options for Gradient descent:

Algorithm OptionLearn More
Active-Set (default)fmincon Active Set Algorithm in the Optimization Toolbox documentation.
Interior-Pointfmincon Interior Point Algorithm in the Optimization Toolbox documentation.
Trust-Region-Reflectivefmincon Trust Region Reflective Algorithm in the Optimization Toolbox documentation.

Selecting Optimization Termination Options

Use the Optimization options panel to specify when you want the optimization to terminate.

By varying these parameters you can force the optimization to continue searching for a solution or to continue searching for a more accurate solution.

Selecting Additional Optimization Options

At the bottom of the Optimization Options panel is a group of additional optimization options.

Display Level.   The Display level option specifies the form of the output that appears in the Optimization Progress window. The options are Iterations, which displays information after each iteration, None, which turns off all output, Notify, which displays output only if the function does not converge, and Termination, which only displays the final output.

For more information on the type of iterative output that appears for the method you selected using the Method option, see the discussion of output for the corresponding function.

MethodFunctionOutput Information
Gradient descentfminconfmincon section of Function-Specific Output Headings in the Optimization Toolbox documentation
Simplex searchfminsearchfminsearch section of Function-Specific Output Headings in the Optimization Toolbox documentation
Pattern searchpatternsearchDisplay to Command Window Options in the Genetic Algorithm and Direct Search Toolbox documentation

Restarts.   In some optimizations the Hessian may become ill conditioned and the optimization does not converge. In these cases it is sometimes useful to restart the optimization after it stops, using the endpoint of the previous optimization as the starting point for the next one. To automatically restart the optimization, indicate the number of times you want to restart in this field.

Gradient Type.   When using Gradient descent as the optimization method, Simulink Design Optimization software calculates gradients based on finite difference methods. The default method for computing the gradients is Basic. The Refined method offers a more robust and less noisy gradient calculation method than Basic, although it is sometimes more expensive and does not work with certain models such as SimPowerSystems models. If the optimization fails, a good first work-around, before changing solvers or adding parameter bounds, is to change Gradient type to Refined.

Specifying the Simulation Options

Accessing Simulation Options

To optimize the response signals of a model, Simulink Design Optimization software runs simulations of the model.

You can set options for these simulations by selecting Optimization > Simulation Options in the Signal Constraint window. This opens the Options dialog box.

Selecting Simulation Time

By default, the Start time and Stop time are automatically set to the model's start and stop times. To specify alternative start and stop times for the response optimization project, enter them under Simulation time.

Selecting Solvers

When running the simulation, Simulink software solves the dynamic system using one of several solvers. You can specify several solver options under Solver options in the Options dialog box.

The type of solver can be variable-step or fixed step. Variable step solvers keep the error within specified tolerances by adjusting the step size the solver uses. Fixed-step solvers use a constant step-size. When your model's state's are likely to vary rapidly, a variable-step solver is often faster.

Variable-Step Solvers.   When you select Variable-step as the solver Type, you can choose any of the following as the Solver:

See the Simulink documentation for information on these solvers.

Variable-Step Solver Options.   When you select Variable-step as the Simulink solver Type, you can also set several other parameters that affect the step size of the simulation:

By default, the values for these options are automatically chosen. To choose your own values, enter them in the appropriate fields. For more information on these options, and the circumstances in which to use them, see the Simulink documentation.

Fixed-Step Solvers.   When you select Fixed-step as the solver Type, you can choose any of the following as the Solver:

See the Simulink documentation for information on these solvers.

When you select Fixed-step as the solver Type, you can also set Fixed step size, which determines the step size the solver uses during the simulation. By default, Simulink automatically chooses a value for this option.

Plotting Responses in the Signal Constraint Window

Types of Response Plots

You can choose to plot several different signals in the Signal Constraint window, including reference signals, initial response signals, and response signals generated during the optimization.

Reference Signals

To plot a reference signal, use the methods in Plotting the Reference Signal.

Current Response

To display the current response signal, based on the current parameter values, right-click within the white space of the Signal Constraint window and select Plot Current Response. The current response appears as a thick white line.

Initial Response

To turn the display of the initial response signal on or off, right-click within the white space of the Signal Constraint window and select Show > Initial Response. The initial response is the response of the signal based on parameter values in place before the optimization is run. The initial response appears as a blue line.

Intermediate Steps

To turn on, or off, the display of the response signal at intermediate steps during the optimization, right-click within the white space of the Signal Constraint window and select Show > Intermediate Steps. The response signal at an intermediate step is based on parameter values at an intermediate point in the optimization.

Response Plots Property Editor

Modifying Properties of Response Plots.   This section discusses how you can change the properties of response plots. Select Edit > Axes Properties in the Block Parameters: Signal Constraint window and select Labels to open the Property Editor dialog box.

This figure shows the Property Editor dialog box for a step response.

In general, you can change the following properties of response plots.

As you make changes in the Property Editor, they display immediately in the response plot. Conversely, if you make changes in a plot using right-click menus, the Property Editor for that plot automatically updates. The Property Editor and its associated plot are dynamically linked.

Labels Pane.  

To specify new text for plot titles and axis labels, type the new string in the field next to the label you want to change. The label changes immediately as you type, so you can see how the new text looks as you are typing.

Limits Pane.  

Default values for the axes limits make sure that the maximum and minimum x and y values are displayed. If you want to override the default settings, change the values in the Limits pane fields. The Auto-Scale check box automatically clears if you click a different field. The new limits appear immediately in the response plot.

To reestablish the default values, select the Auto-Scale check box again.

Running the Optimization

After you have specified constraints and the parameters to optimize, as described in Specifying Design Requirements and Specifying Parameters to Optimize respectively, you can run the optimization.

Run the optimization by selecting Optimization > Start in the Signal Constraint window, or click the Start button, which is the small triangle located on the control panel below the menus.

Simulink Design Optimization software uses optimization methods to find parameter values that allow a feasible solution, or best fit in the case of reference tracking, to the given constraints. Once the appropriate signals have been constrained with signal bounds or by tracking a reference signal, the tuned parameters set, and (optionally) any uncertain parameters and optimization settings specified, you are ready to run the optimization.

Simulink Design Optimization software begins by plotting the initial response in blue in the Signal Constraint window. During the optimization, intermediate responses are also plotted in various colors. The final response is plotted in black. If uncertainty is included in the optimization, the uncertain response signals are plotted as dashed lines, along with the nominal response as a solid line.

Simulink Design Optimization software changes the values of the tuned parameters within the MATLAB workspace and displays the final value in the Optimization Progress window. Alternatively, you can enter a parameter name at the MATLAB prompt to see its final value.

The Optimization Progress window displays numerical output. The form of this output depends on the optimization method being used. To learn more, see Selecting Optimization Methods and the discussion of Display level in Selecting Additional Optimization Options.

If the optimization does not converge the first time, it often converges after adjusting the constraints or tuned parameter characteristics, or choosing different options. For more information, see Troubleshooting Optimization Results.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS