Main Content

Inequality constraints

An `OptimizationInequality`

object contains an inequality
constraint in terms of `OptimizationVariable`

objects or `OptimizationExpression`

objects. An inequality constraint uses the comparison
operator `<=`

or `>=`

.

A single statement can represent an array of inequalities. For example, you can express
the inequalities that each row of a matrix variable `x`

sums to no more than
one in this single statement:

constrsum = sum(x,2) <= 1

Use `OptimizationInequality`

objects as constraints in an `OptimizationProblem`

.

**Tip**

For the full workflow, see Problem-Based Optimization Workflow.

Create an inequality using optimization expressions with the comparison operator
`<=`

or `>=`

.

Include inequalities in the `Constraints`

property of an optimization
problem by using dot notation.

```
prob = optimproblem;
x = optimvar('x',4,6);
SumLessThanOne = sum(x,2) <= 1;
prob.Constraints.SumLessThanOne = SumLessThanOne;
```

You can also create an empty optimization inequality by using `optimineq`

or
`optimconstr`

.
Typically, you then set the inequalities in a loop. For an example, see Create Inequalities in Loop. However, for the most
efficient problem formulation, avoid setting inequalities in loops. See Create Efficient Optimization Problems.

`infeasibility` | Constraint violation at a point |

`show` | Display information about optimization object |

`write` | Save optimization object description |

`infeasibility`

| `optimconstr`

| `optimineq`

| `OptimizationConstraint`

| `OptimizationEquality`

| `OptimizationExpression`

| `OptimizationProblem`

| `OptimizationVariable`

| `show`

| `write`