# OptimizationConstraint

Optimization constraints

## Description

An `OptimizationConstraint`

object contains constraints in
terms of `OptimizationVariable`

objects or `OptimizationExpression`

objects. Each constraint uses one of these
comparison operators: `==`

, `<=`

, or
`>=`

.

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

sums to one, as
shown in Create Simple Constraints in Loop.

**Tip**

For the full workflow, see Problem-Based Optimization Workflow or Problem-Based Workflow for Solving Equations.

## Creation

Create an empty constraint object using `optimconstr`

. Typically, you use a loop to fill the expressions in the
object.

If you create an optimization expressions from optimization variables using a
comparison operators `==`

, `<=`

, or
`>=`

, then the resulting object is either an `OptimizationEquality`

or an `OptimizationInequality`

. See Compatibility Considerations.

Include constraints in the `Constraints`

property of an optimization
problem by using dot notation.

prob = optimproblem; x = optimvar('x',5,3); rowsum = optimconstr(5); for i = 1:5 rowsum(i) = sum(x(i,:)) == i; end prob.Constraints.rowsum = rowsum;

## Properties

## Object Functions

`infeasibility` | Constraint violation at a point |

`show` | Display information about optimization object |

`write` | Save optimization object description |

## Examples

## Version History

**Introduced in R2017b**