Documentation

## How the Optimization Algorithm Formulates Minimization Problems

When you optimize parameters of a Simulink® model to meet design requirements, Simulink Design Optimization™ software automatically converts the requirements into a constrained optimization problem and then solves the problem using optimization techniques. The constrained optimization problem iteratively simulates the Simulink model, compares the results of the simulations with the constraint objectives, and uses optimization methods to adjust tuned parameters to better meet the objectives.

This topic describes how the software formulates the constrained optimization problem used by the optimization algorithms. For each optimization algorithm, the software formulates one of the following types of minimization problems:

For more information on how each optimization algorithm formulates these problems, see:

### Feasibility Problem and Constraint Formulation

Feasibility means that the optimization algorithm finds parameter values that satisfy all constraints to within specified tolerances but does not minimize any objective or cost function in doing so.

In the following figure, x1, x3, and xn represent a combination of parameter values P1 and P2 and are feasible solutions because they do not violate the lower bound constraint. In a Simulink model, you constrain a signal by specifying lower and upper bounds in a Check block (Check Step Response Characteristics, ...) or a requirement object (`sdo.requirements.StepResponseEnvelope`, ...), as shown in the following figure. These constraints are piecewise linear bounds. A piecewise linear bound ybnd with n edges can be represented as:

`${y}_{bnd}\left(t\right)=\left\{\begin{array}{cc}{y}_{1}\left(t\right)& {t}_{1}\le t\le {t}_{2}\\ {y}_{2}\left(t\right)& {t}_{2}\le t\le {t}_{3}\\ ⋮& ⋮\\ {y}_{n}\left(t\right)& {t}_{n}\le t\le {t}_{n+1}\end{array},$`

The software computes the signed distance between the simulated response and the edge. The signed distance for lower bounds is:

where ysim is the simulated response and is a function of the parameters being optimized.

The signed distance for upper bounds is:

`$c=\left[\begin{array}{c}\underset{{t}_{1}\le t\le {t}_{2}}{\mathrm{max}}{y}_{sim}-{y}_{bnd}\\ \underset{{t}_{2}\le t\le {t}_{3}}{\mathrm{max}}{y}_{sim}-{y}_{bnd}\\ \underset{{t}_{n}\le t\le {t}_{n+1}}{\mathrm{max}}{y}_{sim}-{y}_{bnd}\end{array}\right].$`

At the command line, `opt_fcn` supplies `c` directly from the `Cleq` field of `vals`.

If all the constraints are met (c ≤ 0) for some combination of parameter values, then that solution is said to be feasible. In the following figure, x1 and x3 are feasible solutions. When your model has multiple requirements or vector signals feeding a requirement, the constraint vector is extended with the constraint violations for each signal and bound:

`$C=\left[{c}_{1};{c}_{2};\cdots ;{c}_{n}\right].$`

### Tracking Problem

In addition to lower and upper bounds, you can specify a reference signal in a Check Against Reference block or `sdo.requirements.SignalTracking` object, which the Simulink model output can track. The tracking objective is a sum-squared-error tracking objective.

You specify the reference signal as a sequence of time-amplitude pairs:

`${y}_{ref}\left({t}_{ref}\right),{t}_{ref}\in \left\{{T}_{ref0},{T}_{ref1},\cdots ,{T}_{refN}\right\}.$`

The software computes the simulated response as a sequence of time-amplitude pairs:

`${y}_{sim}\left({t}_{sim}\right),{t}_{sim}\in \left\{{T}_{sim0},{T}_{sim1},\cdots ,{T}_{simN}\right\},$`

where some values of tsim may match the values of tref.

A new time base, tnew, is formed from the union of the elements of tref and tsim. Elements that are not within the minimum-maximum range of both tref and tsim are omitted:

`${t}_{new}=\left\{t:{t}_{sim}\cup {t}_{ref}\right\}$`

Using linear interpolation, the software computes the values of yref and ysim at the time points in tnew and then computes the scaled error:

`$e\left({t}_{new}\right)=\frac{\left({y}_{sim}\left({t}_{new}\right)-{y}_{ref}\left({t}_{new}\right)\right)}{\underset{{t}_{new}}{\mathrm{max}}|{y}_{ref}|}.$`

Finally, the software computes the weighted, integral square error:

`$f=\int w\left(t\right)e{\left(t\right)}^{2}dt.$`

### Note

The weight w(t) is 1 by default. You can specify a different value of weight only at the command line.

When your model has requirements or vector signals feeding a requirement, the tracking objective equals the sum of the individual tracking integral errors for each signal:

`$F=\sum {f}_{i}.$`

### Gradient Descent Method Problem Formulations

The Gradient Descent method uses the Optimization Toolbox™ function `fmincon` to optimize model parameters to meet design requirements.

Problem TypeProblem Formulation
Feasibility Problem

The software formulates the constraint C(x) as described in Feasibility Problem and Constraint Formulation.

• If you select the maximally feasible solution option (i.e., the optimization continues after an initial feasible solution is found), the software uses the following problem formulation:

γ is a slack variable that permits a feasible solution with C(x) ≤ γ rather than C(x) ≤ 0.

• If you do not select the maximally feasible solution option (i.e., the optimization terminates as soon as a feasible solution is found), the software uses the following problem formulation:

Tracking Problem

The software formulates the tracking objective F(x) as described in Tracking Problem and minimizes the tracking objective:

Mixed Feasibility and Tracking Problem

The software minimizes following problem formulation:

### Note

When tracking a reference signal, the software ignores the maximally feasible solution option.

### Simplex Search Method Problem Formulations

The Simplex Search method uses the Optimization Toolbox function `fminsearch` and `fminbnd` to optimize model parameters to meet design requirements. `fminbnd` is used if one scalar parameter is being optimized, otherwise `fminsearch` is used. You cannot use parameter bounds $\underset{¯}{x}\le x\le \overline{x}$ with `fminsearch`.

Problem TypeProblem Formulation
Feasibility Problem

The software formulates the constraint C(x) as described in Feasibility Problem and Constraint Formulation and then minimizes the maximum constraint violation:

Tracking Problem

The software formulates the tracking objective F(x) as described in Tracking Problem and then minimizes the tracking objective:

Mixed Feasibility and Tracking Problem

The software formulates the problem in two steps:

1. Finds a feasible solution.

2. Minimizes the tracking objective. The software uses the results from step 1 as initial guesses and maintains feasibility by introducing a discontinuous barrier in the optimization objective.

### Pattern Search Method Problem Formulations

The Pattern Search method uses the Global Optimization Toolbox function `patternsearch` to optimize model parameters to meet design requirements.

Problem TypeProblem Formulation
Feasibility Problem

The software formulates the constraint C(x) as described in Feasibility Problem and Constraint Formulation and then minimizes the maximum constraint violation:

Tracking Problem

The software formulates the tracking objective F(x) as described in Tracking Problem and then minimizes the tracking objective:

Mixed Feasibility and Tracking Problem

The software formulates the problem in two steps:

1. Finds a feasible solution.

2. Minimizes the tracking objective. The software uses the results from step 1 as initial guesses and maintains feasibility by introducing a discontinuous barrier in the optimization objective.

For the `Gradient descent` (`fmincon`) optimization solver, the gradients are computed using numerical perturbation:

`$\begin{array}{l}dx=\sqrt{eps}×\mathrm{max}\left(|x|,\frac{1}{10}{x}_{typical}\right)\\ dL=\mathrm{max}\left(x-dx,{x}_{\mathrm{min}}\right)\\ dR=\mathrm{min}\left(x+dx,{x}_{\mathrm{max}}\right)\\ {F}_{L}=opt_fcn\left(dL\right)\\ {F}_{R}=opt_fcn\left(dR\right)\\ \frac{dF}{dx}=\frac{\left({F}_{L}-{F}_{R}\right)}{\left(dL-dR\right)}\\ \end{array}$`
• x is a scalar design variable.

• xmin is the lower bound of x.

• xmax is the upper bound of x.

• xtypical is the scaled value of x.

• opt_fcn is the objective function.

dx is relatively large to accommodate simulation solver tolerances.

If you want to compute the gradients in any other way, you can do so in the cost function you write for performing design optimization programmatically. See `sdo.optimize` and `GradFcn` of `sdo.OptimizeOptions` for more information. 