Main Content

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.

P2 vs P1 graph with x1, x3, and xn as feasible solutions and x2 violating 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.

Plot showing upper and lower bounds

These constraints are piecewise linear bounds. A piecewise linear bound ybnd with n edges can be represented as:

ybnd(t)={y1(t)t1tt2y2(t)t2tt3yn(t)tnttn+1,

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

c=[maxt1tt2ybndysimmaxt2tt3 ybndysimmaxtnttn+1ybndysim],

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

The signed distance for upper bounds is:

c=[maxt1tt2ysimybndmaxt2tt3ysimybndmaxtnttn+1ysimybnd].

At the command line, optimFcn 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.

P2 vs P1 graph with x1 and x3 as feasible solutions and x2 and xn violating the constraints

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=[c1;c2;;cn].

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:

yref(tref),tref{Tref0,Tref1,,TrefN}.

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

ysim(tsim),tsim{Tsim0,Tsim1,,TsimN},

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:

tnew={t:tsimtref}

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(tnew)=(ysim(tnew)yref(tnew))maxtnew|yref|.

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

f=w(t)e(t)2dt.

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=fi.

Gradient Descent Method Problem Formulations

The Gradient Descent method uses the 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:

    min[x,γ] γs.t.   C(x)γ     x¯xx¯     γ0

    γ 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:

    minx 0 s.t.  C(x)0            x¯xx¯

Tracking Problem

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

minx F(x)s.t.  x¯xx¯ 

Mixed Feasibility and Tracking Problem

The software minimizes following problem formulation:

minx  F(x)s.t.     C(x)0       x¯xx¯

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 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 x¯xx¯ 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:

minx max(C(x))

Tracking Problem

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

minx F(x)

Mixed Feasibility and Tracking Problem

The software formulates the problem in two steps:

  1. Finds a feasible solution.

    minx max(C(x))

  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.

    minx  Γ(x)whereΓ(x)={ifmax(C(x))>0F(x)otherwise.

Pattern Search Method Problem Formulations

The Pattern Search method uses the function patternsearch (Global Optimization Toolbox) 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:

minx max(C(x))s.t.     x¯xx¯

Tracking Problem

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

minx  F(x)s.t.    x¯xx¯

Mixed Feasibility and Tracking Problem

The software formulates the problem in two steps:

  1. Finds a feasible solution.

    minx max(C(x))s.t.     x¯xx¯

  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.

    minxΓ(x)s.t. x¯xx¯whereΓ(x)={ifmax(C(x))>0F(x)otherwise.

Gradient Computations

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

dx=eps3×max(|x|,110xtypical)dL=max(xdx,xmin)dR=min(x+dx,xmax)FL=opt_fcn(dL)FR=opt_fcn(dR)dFdx=(FLFR)(dLdR)

  • 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.