# evallmi

Given particular instance of decision variables, evaluate all variable terms in system of LMIs

## Syntax

```evalsys = evallmi(lmisys,decvars)
```

## Description

`evallmi` evaluates all LMI constraints for a particular instance `decvars` of the vector of decision variables. Recall that `decvars` fully determines the values of the matrix variables X1, . . ., XK. The "evaluation" consists of replacing all terms involving X1, . . ., XK by their matrix value. The output `evalsys` is an LMI system containing only constant terms.

The function `evallmi` is useful for validation of the LMI solvers' output. The vector returned by these solvers can be fed directly to `evallmi` to evaluate all variable terms. The matrix values of the left and right sides of each LMI are then returned by `showlmi`.

## Observation

`evallmi` is meant to operate on the output of the LMI solvers. To evaluate all LMIs for particular instances of the matrix variables X1, . . ., XK, first form the corresponding decision vector x with `mat2dec` and then call `evallmi` with x as input.

## Examples

Consider the feasibility problem of finding X > 0 such that

ATXAX + I < 0

where

$A=\left(\begin{array}{cc}0.5& -0.2\\ 0.1& -0.7\end{array}\right).$

This LMI system is defined by:

```setlmis([]) X = lmivar(1,[2 1]) % full symmetric X lmiterm([1 1 1 X],A',A) % LMI #1: A'*X*A lmiterm([1 1 1 X],-1,1) % LMI #1: -X lmiterm([1 1 1 0],1) % LMI #1: I lmiterm([-2 1 1 X],1,1) % LMI #2: X lmis = getlmis ```

To compute a solution `xfeas`, call `feasp` by

```[tmin,xfeas] = feasp(lmis) ```

The result is

```tmin = -4.7117e+00 xfeas' = 1.1029e+02 -1.1519e+01 1.1942e+02 ```

The LMI constraints are therefore feasible since `tmin` < 0. The solution X corresponding to the feasible decision vector `xfeas` would be given by `X = dec2mat(lmis,xfeas,X)`.

To check that `xfeas` is indeed feasible, evaluate all LMI constraints by typing

```evals = evallmi(lmis,xfeas) ```

The left and right sides of the first and second LMIs are then given by

```[lhs1,rhs1] = showlmi(evals,1) [lhs2,rhs2] = showlmi(evals,2) ```

and the test

```eig(lhs1-rhs1) ans = -8.2229e+01 -5.8163e+01 ```

confirms that the first LMI constraint is satisfied by `xfeas`.