# systune

Tune control system parameters in Simulink using `slTuner` interface

## Syntax

``````[st,fSoft] = systune(st0,SoftGoals)``````
``````[st,fSoft,gHard] = systune(st0,SoftGoals,HardGoals)``````
``````[st,fSoft,gHard] = systune(___,opt)``````
``````[st,fSoft,gHard,info] = systune(___)``````

## Description

`systune` tunes fixed-structure control systems subject to both soft and hard design goals. `systune` can tune multiple fixed-order, fixed-structure control elements distributed over one or more feedback loops. For an overview of the tuning workflow, see Automated Tuning Workflow.

This command tunes control systems modeled in Simulink®. For tuning control systems represented in MATLAB®, use `systune` for `genss` models.

example

``````[st,fSoft] = systune(st0,SoftGoals)``` tunes the free parameters of the control system in Simulink. The Simulink model, tuned blocks, and analysis points of interest are specified by the `slTuner` interface, `st0`. `systune` tunes the control system parameters to best meet the performance goals, `SoftGoals`. The command returns a tuned version of `st0` as `st`. The best achieved soft constraint values are returned as `fSoft`.If the `st0` contains real parameter uncertainty, `systune` automatically performs robust tuning to optimize the constraint values for worst-case parameter values. `systune` also performs robust tuning against a set of plant models obtained at different operating points or parameter values. See Input Arguments.Tuning is performed at the sample time specified by the `Ts` property of `st0`.```
``````[st,fSoft,gHard] = systune(st0,SoftGoals,HardGoals)``` tunes the control system to best meet the soft goals, subject to satisfying the hard goals. It returns the best achieved values, `fSoft` and `gHard`, for the soft and hard goals. A goal is met when its achieved value is less than 1.```
``````[st,fSoft,gHard] = systune(___,opt)``` specifies options for the optimization for any of the input argument combinations in previous syntaxes.```
``````[st,fSoft,gHard,info] = systune(___)``` also returns detailed information about each optimization run for any of the input argument combinations in previous syntaxes.```

## Examples

collapse all

Tune the control system in the `rct_airframe2` model to soft goals for tracking, roll off, stability margin, and disturbance rejection.

```mdl = 'rct_airframe2'; open_system(mdl); ```

Create and configure an `slTuner` interface to the model.

```st0 = slTuner(mdl,'MIMO Controller'); ```

`st0` is an `slTuner` interface to the `rct_aircraft2` model with the `MIMO Controller` block specified as the tunable portion of the control system.

The model already has linearization input points on the signals `az ref`, `delta fin`, `az`, `q`, and `e`. These signals are therefore available as analysis points for tuning goals and linearization.

Specify the tracking requirement, roll-off requirement, stability margins, and disturbance rejection requirement.

```req1 = TuningGoal.Tracking('az ref','az',1); req2 = TuningGoal.Gain('delta fin','delta fin',tf(25,[1 0])); req3 = TuningGoal.Margins('delta fin',7,45); max_gain = frd([2 200 200],[0.02 2 200]); req4 = TuningGoal.Gain('delta fin','az',max_gain); ```

`req1` constrains `az` to track `az ref`. The next requirement, `req2`, imposes a roll-off requirement by specifying a gain profile for the open-loop, point-to-point transfer function measured at `delta fin`. The next requirement, `req3`, imposes open-loop gain and phase margins on that same point-to-point transfer function. Finally, `req4` rejects disturbances to `az` injected at `delta fin`, by specifying a maximum gain profile between those two points.

Tune the model using these tuning goals.

```opt = systuneOptions('RandomStart',3); rng(0); [st,fSoft,~,info] = systune(st0,[req1,req2,req3,req4],opt); ```
```Final: Soft = 1.13, Hard = -Inf, Iterations = 92 Final: Soft = 1.13, Hard = -Inf, Iterations = 80 Final: Soft = 1.13, Hard = -Inf, Iterations = 72 Final: Soft = 40, Hard = -Inf, Iterations = 76 ```

`st` is a tuned version of `st0`.

The `RandomStart` option specifies that `systune` must perform three independent optimization runs that use different (random) initial values of the tunable parameters. These three runs are in addition to the default optimization run that uses the current value of the tunable parameters as the initial value. The call to `rng` seeds the random number generator to produce a repeatable sequence of numbers.

`systune` displays the final result for each run. The displayed value, `Soft`, is the maximum of the values achieved for each of the four performance goals. The software chooses the best run overall, which is the run yielding the lowest value of `Soft`. The last run fails to achieve closed-loop stability, which corresponds to `Soft = Inf`.

Examine the best achieved values of the soft constraints.

```fSoft ```
```fSoft = 1.1327 1.1327 0.5140 1.1327 ```

Only `req3`, the stability margin requirement, is met for all frequencies. The other values are close to, but exceed, 1, indicating violations of the goals for at least some frequencies.

Use `viewGoal` to visualize the tuned control system performance against the goals and to determine whether the violations are acceptable. To evaluate specific open-loop or closed-loop transfer functions for the tuned parameter values, you can use linearization commands such as `getIOTransfer` and `getLoopTransfer`. After validating the tuned parameter values, if you want to apply these values to the Simulink® model, you can use `writeBlockValue`.

## Input Arguments

collapse all

Interface for tuning control systems modeled in Simulink, specified as an `slTuner` interface.

If you specify parameter variation or linearization at multiple operating points when you create `st0`, then `systune` performs robust tuning against all the plant models. If you specify an uncertain (`uss` (Robust Control Toolbox)) model as a block substitution when you create `st0`, then `systune` performs robust tuning, optimizing the parameters against the worst-case parameter values. For more information about robust tuning approaches, see Robust Tuning Approaches (Robust Control Toolbox). (Using uncertain models requires a Robust Control Toolbox™ license.)

Soft goals (objectives) for tuning the control system described by `st0`, specified as a vector of `TuningGoal` objects. For a complete list, see Tuning Goals.

`systune` tunes the tunable parameters of the control system to minimize the maximum value of the soft tuning goals, subject to satisfying the hard tuning goals (if any).

Hard goals (constraints) for tuning the control system described by `st0`, specified as a vector of `TuningGoal` objects. For a complete list, see Tuning Goals.

A hard goal is satisfied when its value is less than 1. `systune` tunes the tunable parameters of the control system to minimize the maximum value of the soft tuning goals, subject to satisfying all the hard tuning goals.

Tuning algorithm options, specified as an options set created using `systuneOptions`.

Available options include:

• Number of additional optimizations to run starting from random initial values of the free parameters

• Tolerance for terminating the optimization

• Flag for using parallel processing

See the `systuneOptions` reference page for more details about all available options.

## Output Arguments

collapse all

Tuned interface, returned as an `slTuner` interface.

Best achieved values of soft goals, returned as a vector.

Each tuning goal evaluates to a scalar value, and `systune` minimizes the maximum value of the soft goals, subject to satisfying all the hard goals.

`fSoft` contains the value of each soft goal for the best overall run. The best overall run is the run that achieved the smallest value for `max(fSoft)`, subject to `max(gHard)<1`.

Achieved values of hard goals, returned as a vector.

`gHard` contains the value of each hard goal for the best overall run (the run that achieved the smallest value for `max(fSoft)`, subject to `max(gHard)<1`. All entries of `gHard` are less than 1 when all hard goals are satisfied. Entries greater than 1 indicate that `systune` could not satisfy one or more design constraints.

Detailed information about each optimization run, returned as a data structure. The fields of `info` are summarized in the following table.

FieldValue
`Run`

Run number, returned as a scalar. If you use the `RandomStart` option of `systuneOptions` to perform multiple optimization runs, `info` is a struct array, and `info.Run` is the index.

`Iterations`

Total number of iterations performed during the run, returned as a scalar. If you use `RandomStart`, `info.Iterations(j)` is the number of iterations performed in the jth run before termination.

`f`

Best overall soft constraint value, returned as a scalar. `systune` converts the soft tuning goals to a function of the free parameters of the control system. The command then tunes the parameters to minimize that function subject to the hard goals. (See Algorithms.) `info.f` is the maximum soft goal value at the final iteration. This value is meaningful only when the hard goals are satisfied. If the value is less than 1, then the soft goals are also attained.

`g`

Best overall hard constraint value, returned as a scalar. `systune` converts the hard tuning goals to a function of the free parameters of the control system. The command then tunes the parameters to drive those values below 1. (See Algorithms.) `info.g` is the largest hard goal value at the final iteration. If this value is less than 1, then the hard goals are satisfied.

`x`

Tuned parameter values, returned as a vector. This vector contains the values of the tunable parameters at the end of the run. `info.x` can also include the values of additional variables such as loop scalings, if `systune` uses them (see `info.LoopScaling`).

`MinDecay`

Minimum decay rate of tuned system dynamics, returned as a two-element row vector.

`info.MinDecay(1)` is the minimum decay rate of the closed-loop poles.

`info.MinDecay(2)` is the minimum decay rate of the dynamics of tuned blocks with stability constraints. For more information about stabilized dynamics and decay rates, see the `MinDecay` option of `systuneOptions`.

`fSoft`

Individual soft constraint values, returned as a vector. `systune` converts each soft tuning goal to a normalized value that is a function of the free parameters of the control system. The command then tunes the parameters to minimize that value subject to the hard goals. (See Algorithms.) `info.fSoft` contains the individual values of the soft goals at the end of each run. These values appear in `fSoft` in the same order in which you specify goals in the `SoftReqs` input argument to `systune`.

`gHard`

Individual hard constraint values, returned as a vector. `systune` converts each hard tuning goal to a normalized value that is a function of the free parameters of the control system. The command then tunes the parameters to minimize those values. A hard goal is satisfied if its value is less than 1. (See Algorithms.) `info.gHard` contains the individual values of the hard goals at the end of each run. These values appear in `gHard` in the same order in which you specify goals in the `HardReqs` input argument to `systune`.

`Blocks`

Tuned values of tunable blocks and parameters in the tuned control system, returned as a structure whose fields are the names of tunable elements and whose values are the corresponding tuned values.

When you perform multiple runs by setting the `RandomStart` option to a positive value, you can use this field to examine control system performance with the results from other runs. For instance, use the following code to apply the tuned values from the jth run.

`stj = setBlockValue(st0,info(j).Blocks)`

`LoopScaling`

Optimal diagonal scaling for evaluating MIMO tuning requirements, returned as a state-space model.

When applied to multiloop control systems, tuning goals that involve an open-loop response can be sensitive to the scaling of the loop transfer functions to which they apply. This sensitivity can lead to poor optimization results. `systune` automatically corrects scaling issues and returns the optimal diagonal scaling matrix `D` as a state-space model in `info.LoopScaling`.

The loop channels associated with each diagonal entry of `D` are listed in `info.LoopScaling.InputName`. The scaled loop transfer is `D\L*D`, where `L` is the open-loop transfer measured at the locations `info.LoopScaling.InputName`.

Tuning goals affected by such loop scaling include:

• `TuningGoal.LoopShape`

• `TuningGoal.MinLoopGain` and `TuningGoal.MaxLoopGain`

• `TuningGoal.Sensitivity`

• `TuningGoal.Rejection`

• `TuningGoal.Margins`

`info` also contains the following fields, whose entries are meaningful when you use `systune` for robust tuning of control systems with uncertainty.

FieldValue
`wcPert`

Worst combinations of uncertain parameters, returned as a structure array. Each structure contains one set of uncertain parameter values. The perturbations with the worst performance are listed first.

`wcf`

Worst soft-goal value, returned as a scalar. This value is the largest soft goal value (`f`) over the uncertainty range when using the tuned controller.

`wcg`

Worst hard-goal value, returned as a scalar. This value is the largest hard goal value (`g`) over the uncertainty range when using the tuned controller.

`wcDecay`

Smallest closed-loop decay rate over the uncertainty range when using the tuned controller, returned as a scalar. A positive value indicates robust stability. For more information about stabilized dynamics and decay rates, see the `MinDecay` option of `systuneOptions`.

collapse all

### Tuned Blocks

Tuned blocks, used by the `slTuner` interface, identify blocks in a Simulink model whose parameters are to be tuned to satisfy tuning goals. You can tune most Simulink blocks that represent linear elements such as gains, transfer functions, or state-space models. (For the complete list of blocks that support tuning, see How Tuned Simulink Blocks Are Parameterized). You can also tune more complex blocks such as SubSystem or S-Function blocks by specifying an equivalent tunable linear model.

Use tuning commands such as `systune` to tune the parameters of tuned blocks.

You must specify tuned blocks (for example, `C1` and `C2`) when you create an `slTuner` interface.

`st = slTuner('scdcascade',{'C1','C2'})`

You can modify the list of tuned blocks using `addBlock` and `removeBlock`.

To interact with the tuned blocks use:

### Analysis Points

Analysis points, used by the `slLinearizer` and `slTuner` interfaces, identify locations within a model that are relevant for linear analysis and control system tuning. You use analysis points as inputs to the linearization commands, such as `getIOTransfer`, `getLoopTransfer`, `getSensitivity`, and `getCompSensitivity`. As inputs to the linearization commands, analysis points can specify any open-loop or closed-loop transfer function in a model. You can also use analysis points to specify design requirements when tuning control systems using commands such as `systune`.

Location refers to a specific block output port within a model or to a bus element in such an output port. For convenience, you can use the name of the signal that originates from this port to refer to an analysis point.

You can add analysis points to an `slLinearizer` or `slTuner` interface, `s`, when you create the interface. For example:

`s = slLinearizer('scdcascade',{'u1','y1'});`

Alternatively, you can use the `addPoint` command.

To view all the analysis points of `s`, type `s` at the command prompt to display the interface contents. For each analysis point of `s`, the display includes the block name and port number and the name of the signal that originates at this point. You can also programmatically obtain a list of all the analysis points using `getPoints`.

For more information about how you can use analysis points, see Mark Signals of Interest for Control System Analysis and Design and Mark Signals of Interest for Batch Linearization.

## Algorithms

x is the vector of tunable parameters in the control system to tune. `systune` converts each soft and hard tuning requirement `SoftReqs(i)` and `HardReqs(j)` into normalized values fi(x) and gj(x), respectively. `systune` then solves the constrained minimization problem:

Minimize $\underset{i}{\mathrm{max}}{f}_{i}\left(x\right)$ subject to $\underset{j}{\mathrm{max}}{g}_{j}\left(x\right)<1$, for ${x}_{\mathrm{min}}.

xmin and xmax are the minimum and maximum values of the free parameters of the control system.

When you use both soft and hard tuning goals, the software approaches this optimization problem by solving a sequence of unconstrained subproblems of the form:

`$\underset{x}{\mathrm{min}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathrm{max}\left(\alpha f\left(x\right),g\left(x\right)\right).$`

The software adjusts the multiplier α so that the solution of the subproblems converges to the solution of the original constrained optimization problem.

`systune` returns the `slTuner` interface with parameters tuned to the values that best solve the minimization problem. `systune` also returns the best achieved values of fi(x) and gj(x), as `fSoft` and `gHard` respectively.

For information about the functions fi(x) and gj(x) for each type of constraint, see the reference pages for each `TuningGoal` requirement object.

`systune` uses the nonsmooth optimization algorithms described in [1],[2],[3],[4]

`systune` computes the H norm using the algorithm of [5] and structure-preserving eigensolvers from the SLICOT library. For information about the SLICOT library, see http://slicot.org.

## Alternative Functionality

Tune interactively using Control System Tuner.

## References

[1] P. Apkarian and D. Noll, "Nonsmooth H-infinity Synthesis," IEEE Transactions on Automatic Control, Vol. 51, Number 1, 2006, pp. 71–86.

[2] Apkarian, P. and D. Noll, "Nonsmooth Optimization for Multiband Frequency-Domain Control Design," Automatica, 43 (2007), pp. 724–731.

[3] Apkarian, P., P. Gahinet, and C. Buhr, "Multi-model, multi-objective tuning of fixed-structure controllers," Proceedings ECC (2014), pp. 856–861.

[4] Apkarian, P., M.-N. Dao, and D. Noll, "Parametric Robust Structured Control Design," IEEE Transactions on Automatic Control, 2015.

[5] Bruisma, N.A. and M. Steinbuch, "A Fast Algorithm to Compute the H-Norm of a Transfer Function Matrix," System Control Letters, 14 (1990), pp. 287-293.