# TuningGoal.WeightedGain class

Package: TuningGoal

Frequency-weighted gain constraint for control system tuning

## Description

Use `TuningGoal.WeightedGain` to limit the weighted gain from specified inputs to outputs. The weighted gain is the maximum across frequency of the gain from input to output, multiplied by weighting functions that you specify. You can use the `TuningGoal.WeightedGain` tuning goal for control system tuning with tuning commands such as `systune` or `looptune`.

After you create a tuning goal, you can configure it further by setting Properties of the object.

## Construction

```Req = TuningGoal.WeightedGain(inputname,outputname,WL,WR)``` creates a tuning goal that specifies that the closed-loop transfer function, H(s), from the specified input to output meets the requirement:

||WL(s)H(s)WR(s)|| < 1.

The notation ||•|| denotes the maximum gain across frequency (the H norm).

### Input Arguments

 `inputname` Input signals for the tuning goal, specified as a character vector or, for multiple-input tuning goals, a cell array of character vectors. If you are using the tuning goal to tune a Simulink® model of a control system, then `inputname` can include:Any model input.Any linear analysis point marked in the model.Any linear analysis point in an `slTuner` (Simulink Control Design) interface associated with the Simulink model. Use `addPoint` (Simulink Control Design) to add analysis points to the `slTuner` interface. Use `getPoints` (Simulink Control Design) to get the list of analysis points available in an `slTuner` interface to your model. For example, suppose that the `slTuner` interface contains analysis points `u1` and `u2`. Use `'u1'` to designate that point as an input signal when creating tuning goals. Use `{'u1','u2'}` to designate a two-channel input. If you are using the tuning goal to tune a generalized state-space (`genss`) model of a control system, then `inputname` can include: Any input of the `genss` model Any `AnalysisPoint` location in the control system modelFor example, if you are tuning a control system model, `T`, then `inputname` can be any input name in `T.InputName`. Also, if `T` contains an `AnalysisPoint` block with a location named `AP_u`, then `inputname` can include `'AP_u'`. Use `getPoints` to get a list of analysis points available in a `genss` model.If `inputname` is an `AnalysisPoint` location of a generalized model, the input signal for the tuning goal is the implied input associated with the `AnalysisPoint` block: For more information about analysis points in control system models, see Mark Signals of Interest for Control System Analysis and Design. `outputname` Output signals for the tuning goal, specified as a character vector or, for multiple-output tuning goals, a cell array of character vectors. If you are using the tuning goal to tune a Simulink model of a control system, then `outputname` can include:Any model output.Any linear analysis point marked in the model.Any linear analysis point in an `slTuner` (Simulink Control Design) interface associated with the Simulink model. Use `addPoint` (Simulink Control Design) to add analysis points to the `slTuner` interface. Use `getPoints` (Simulink Control Design) to get the list of analysis points available in an `slTuner` interface to your model. For example, suppose that the `slTuner` interface contains analysis points `y1` and `y2`. Use `'y1'` to designate that point as an output signal when creating tuning goals. Use `{'y1','y2'}` to designate a two-channel output. If you are using the tuning goal to tune a generalized state-space (`genss`) model of a control system, then `outputname` can include: Any output of the `genss` model Any `AnalysisPoint` location in the control system modelFor example, if you are tuning a control system model, `T`, then `outputname` can be any output name in `T.OutputName`. Also, if `T` contains an `AnalysisPoint` block with a location named `AP_u`, then `outputname` can include `'AP_u'`. Use `getPoints` to get a list of analysis points available in a `genss` model.If `outputname` is an `AnalysisPoint` location of a generalized model, the output signal for the tuning goal is the implied output associated with the `AnalysisPoint` block: For more information about analysis points in control system models, see Mark Signals of Interest for Control System Analysis and Design. `WL,WR` Frequency-weighting functions, specified as scalars, matrices, or SISO or MIMO numeric LTI models. The functions `WL` and `WR` provide the weights for the tuning goal. The tuning goal ensures that the gain H(s) from the specified input to output satisfies the inequality:||WL(s)H(s)WR(s)||∞ < 1.`WL` provides the weighting for the output channels of H(s), and `WR` provides the weighting for the input channels. You can specify scalar weights or frequency-dependent weighting. To specify a frequency-dependent weighting, use a numeric LTI model. For example: ```WL = tf(1,[1 0.01]); WR = 10;``` If you specify MIMO weighting functions, then `inputname` and `outputname` must be vector signals. The dimensions of the vector signals must be such that the dimensions of H(s) are commensurate with the dimensions of `WL` and `WR`. For example, if you specify `WR = diag([1 10])`, then `inputname` must include two signals. Scalar values, however, automatically expand to any input or output dimension. If you are tuning in discrete time (that is, using a `genss` model or `slTuner` interface with nonzero `Ts`), you can specify the weighting functions as discrete-time models with the same `Ts`. If you specify the weighting functions in continuous time, the tuning software discretizes them. Specifying the weighting functions in discrete time gives you more control over the weighting functions near the Nyquist frequency. A value of `WL = []` or `WR = []` is interpreted as the identity.

## Properties

 `WL` Frequency-weighting function for the output channels of the transfer function to constrain, specified as a scalar, a matrix, or a SISO or MIMO numeric LTI model. The initial value of this property is set by the `WL` input argument when you construct the tuning goal. `WR` Frequency-weighting function for the input channels of the transfer function to constrain, specified as a scalar, a matrix, or a SISO or MIMO numeric LTI model. The initial value of this property is set by the `WR` input argument when you construct the tuning goal. `Focus` Frequency band in which tuning goal is enforced, specified as a row vector of the form `[min,max]`. Set the `Focus` property to limit enforcement of the tuning goal to a particular frequency band. Express this value in the frequency units of the control system model you are tuning (rad/`TimeUnit`). For example, suppose `Req` is a tuning goal that you want to apply only between 1 and 100 rad/s. To restrict the tuning goal to this band, use the following command:`Req.Focus = [1,100];` Default: `[0,Inf]` for continuous time; `[0,pi/Ts]` for discrete time, where `Ts` is the model sample time. `Stabilize` Stability requirement on closed-loop dynamics, specified as 1 (`true`) or 0 (`false`). By default, `TuningGoal.Gain` imposes a stability requirement on the closed-loop transfer function from the specified inputs to outputs, in addition to the gain requirement. If stability is not required or cannot be achieved, set `Stabilize` to `false` to remove the stability requirement. For example, if the gain constraint applies to an unstable open-loop transfer function, set `Stabilize` to `false`. Default: 1(`true`) `Input` Input signal names, specified as a cell array of character vectors that identify the inputs of the transfer function that the tuning goal constrains. The initial value of the `Input` property is set by the `inputname` input argument when you construct the tuning goal. `Output` Output signal names, specified as a cell array of character vectors that identify the outputs of the transfer function that the tuning goal constrains. The initial value of the `Output` property is set by the `outputname` input argument when you construct the tuning goal. `Models` Models to which the tuning goal applies, specified as a vector of indices. Use the `Models` property when tuning an array of control system models with `systune`, to enforce a tuning goal for a subset of models in the array. For example, suppose you want to apply the tuning goal, `Req`, to the second, third, and fourth models in a model array passed to `systune`. To restrict enforcement of the tuning goal, use the following command: `Req.Models = 2:4;` When `Models = NaN`, the tuning goal applies to all models. Default: `NaN` `Openings` Feedback loops to open when evaluating the tuning goal, specified as a cell array of character vectors that identify loop-opening locations. The tuning goal is evaluated against the open-loop configuration created by opening feedback loops at the locations you identify. If you are using the tuning goal to tune a Simulink model of a control system, then `Openings` can include any linear analysis point marked in the model, or any linear analysis point in an `slTuner` (Simulink Control Design) interface associated with the Simulink model. Use `addPoint` (Simulink Control Design) to add analysis points and loop openings to the `slTuner` interface. Use `getPoints` (Simulink Control Design) to get the list of analysis points available in an `slTuner` interface to your model. If you are using the tuning goal to tune a generalized state-space (`genss`) model of a control system, then `Openings` can include any `AnalysisPoint` location in the control system model. Use `getPoints` to get the list of analysis points available in the `genss` model. For example, if `Openings = {'u1','u2'}`, then the tuning goal is evaluated with loops open at analysis points `u1` and `u2`. Default: `{}` `Name` Name of the tuning goal, specified as a character vector. For example, if `Req` is a tuning goal: `Req.Name = 'LoopReq';` Default: `[]`

## Examples

collapse all

Create a tuning goal requirement that constrains the gain of a closed-loop SISO system from its input, r, to its output, y. Weight the gain at its input by a factor of 10 and at its output by the frequency-dependent weight $1/\left(s+0.01\right)$.

```WL = tf(1,[1 0.01]); WR = 10; Req = TuningGoal.WeightedGain('r','y',WL,WR);```

You can use the requirement `Req` with `systune` to tune the free parameters of any control system model that has an input signal named `'r'` and an output signal named `'y'`.

You can then use `viewGoal` to validate the tuned control system against the requirement.

Create a requirement that constrains the gain of the outer loop of the following control system, evaluated with the inner loop open.

Create a model of the system. To do so, specify and connect the numeric plant models, `G1` and `G2`, the tunable controllers `C1` and `C2`. Also, create and connect the `AnalysisPoint` blocks that mark points of interest for analysis or tuning, `AP1` and `AP2`.

```G1 = tf(10,[1 10]); G2 = tf([1 2],[1 0.2 10]); C1 = tunablePID('C','pi'); C2 = tunableGain('G',1); AP1 = AnalysisPoint('AP1'); AP2 = AnalysisPoint('AP2'); T = feedback(G1*feedback(G2*C2,AP2)*C1,AP1); T.InputName = 'r'; T.OutputName = 'y';```

Create a tuning requirement that constrains the gain of this system from r to y. Weight the gain at the output by $s/\left(s+0.5\right)$.

```WL = tf([1 0],[1 0.5]); Req = TuningGoal.WeightedGain('r','y',WL,[]);```

This requirement is equivalent to `Req = TuningGoal.Gain('r','y',1/WL)`. However, for MIMO systems, you can use `TuningGoal.WeightedGain` to create channel-specific weightings that cannot be expressed as `TuningGoal.Gain` requirements.

Specify that the transfer function from r to y be evaluated with the outer loop open for the purpose of tuning to this constraint.

`Req.Openings = 'AP1';`

By default, tuning using `TuningGoal.WeightedGain` imposes a stability requirement as well as the gain requirement. Practically, in some control systems it is not possible to achieve a stable inner loop. When this occurs, remove the stability requirement for the inner loop by setting the `Stabilize` property to `false`.

`Req.Stabilize = false;`

The tuning algorithm still imposes a stability requirement on the overall tuned control system, but not on the inner loop alone.

Use `systune` to tune the free parameters of `T` to meet the tuning requirement specified by `Req`. You can then validate the tuned control system against the requirement using the command `viewGoal(Req,T)`.

## Tips

• This tuning goal imposes an implicit stability constraint on the weighted closed-loop transfer function from `Input` to `Output`, evaluated with loops opened at the points identified in `Openings`. The dynamics affected by this implicit constraint are the stabilized dynamics for this tuning goal. The `MinDecay` and `MaxRadius` options of `systuneOptions` control the bounds on these implicitly constrained dynamics. If the optimization fails to meet the default bounds, or if the default bounds conflict with other requirements, use `systuneOptions` to change these defaults.

## Algorithms

When you tune a control system using a `TuningGoal`, the software converts the tuning goal into a normalized scalar value f(x). x is the vector of free (tunable) parameters in the control system. The software then adjusts the parameter values to minimize f(x) or to drive f(x) below 1 if the tuning goal is a hard constraint.

For `TuningGoal.WeightedGain`, f(x) is given by:

`$f\left(x\right)={‖{W}_{L}T\left(s,x\right){W}_{R}‖}_{\infty }.$`

T(s,x) is the closed-loop transfer function from `Input` to `Output`. ${‖\text{\hspace{0.17em}}\cdot \text{\hspace{0.17em}}‖}_{\infty }$ denotes the H norm (see `getPeakGain`).

## Version History

Introduced in R2016a

expand all