## Task-Based Model Order Reduction Workflow

To perform model order reduction of dense and sparse linear time-invariant (LTI) models using custom reduction criteria, follow these steps:

### Create Specification

Create a model order reduction specification object using the `reducespec` function. The specification object type depends on the model type and the selected algorithm. Currently, the software supports model order reduction for LTI (see Numeric Linear Time Invariant (LTI) Models) and sparse LTI (see `sparss` and `mechss`) models.

This table shows the objects you can create.

AlgorithmSupported ModelsObjectsObject Functions
Balanced truncationNonsparse and sparse LTI models
Balanced truncation of normalized coprime factors (NCF)Nonsparse LTI models`NCFBalancedTruncation`
Modal truncationNonsparse and sparse LTI models
Proper orthogonal decomposition (since R2024b)Nonsparse and sparse LTI models`ProperOrthogonalDecomposition`

• Each object has its own set of properties and an `Options` property.

• All properties of `R` except `Options` are read only (derived data). Use dot notation to configure options for `R`.

```R = reducespec(sys,"balanced"); R.Options.Algorithm = "relative";```
• The `reducespec` function creates only the model order reduction specification object and does not perform any computation. Therefore, all the derived properties are set to `[]` in this step.

This step allows you to properly configure options before you perform the next steps, which can be computationally expensive, especially in the case of sparse models.

### Run Model Reduction Algorithm

Run the model order reduction algorithm using the `process` function.

This step analyzes the model and computes the derived information you require to generate reduced-order models (ROM), such as the Hankel singular values (balanced truncation) or modal components (modal truncation). Use the following syntax for this function.

`R = process(R)`

This command populates the properties of the specification object `R` created in the previous step.

Using this function is optional in the workflow, and is only necessary when you want to:

• Compute or update the derived data in `R` to see the values.

• Avoid recomputing the data multiple times. This is critical for sparse models because the algorithm can be computationally expensive. For example, if your application calls `view` once and `getrom` twice, then the computation happens three times in the workflow. To avoid this, use `process` to compute the data once, and then call `view` and `getrom`.

### Visualize Contributions

To help you decide the order of the reduced model, plot the graphical information using the `view` function.

For example, you can:

• View the Hankel singular value plot and discard the states with negligible contributions (balanced truncation).

• Discard the modes based on their locations or DC contributions (modal truncation).

This table lists all the plot types you can visualize based on the model order reduction task.

MOR AlgorithmPlot Types (`type`)Plot Description
• Balanced truncation

• Balanced truncation of normalized coprime factors

• Proper orthogonal decomposition

`"sigma"` (default)Bar chart of Hankel singular values and associated error bound
`"energy"`Bar chart of normalized energies
`"loss"`Bar chart of neglected fraction of total energy
Modal truncation`"mode"` (default)Mode locations
`"damp"`Mode damping and natural frequencies
`"contrib"`Bar chart of normalized DC contributions

Additionally, you can use the command `view(R,'-help')` to show the help specific to the model order specification object `R` at the command line. The returned help shows plot types and syntaxes applicable to `R`.

### Obtain Reduced-Order Model

Obtain the reduced-order model using the `getrom` function. This is based on either an explicit order selection or a combination of criteria you have identified based on the visual analysis in the previous step.

• For balanced truncation methods, you can specify custom criteria as one of these.

• Explicitly specify model order using the `Order` input argument. For example, this command returns a model of order 10.

`rsys = getrom(R,Order=10);`
• Retain states based on maximum error or minimum energy using `MaxError` and `MinEnergy` input arguments.

```rsys1 = getrom(R,MaxError=0.5); rsys2 = getrom(R,MinEnergy=0.1);```

The first command returns the lowest-order model `rsys1` for which the approximation error does not exceed 0.5. The second command discards all states with normalized energy below 0.1. You can also choose between the two state reduction methods.

• For modal truncation methods, you can specify custom criteria as one of these.

• Select the desired modes using a logical or index vector. The function selects the modes corresponding to logical ones or indices from the mode vector `R.Mode`.

`rsys = getrom(R,Selection=[1 5 8 10 20 31]);`
• Use one or more mode selection criteria based on frequency range, damping range, or minimum DC contribution of the modes.

```rsys = getrom(R,Damping=[0 0.5]); rsys = getrom(R,Frequency=[0 10],MinDC=0.1);```

For example, the last command includes all modal components with natural frequencies in [0,10] rad/s and a DC contribution of at least 10%.

You can also choose between the two state reduction methods.

• The `"matchDC"` method preserves the DC gain (steady-state value of step response) and tends to match the time response better.

• The `"truncate"` method tends to match the frequency response better. Use this method when you want to control the relative error.

`rsys = getrom(R,MaxError=0.5,Method="truncate");`

Additionally, you can use the command `getrom(R,'-help')` to show the help specific to the model order specification object `R` at the command line. The returned help shows the name-value arguments and syntaxes applicable to `R`.