OptimizationEquality
Equalities and equality constraints
Description
An OptimizationEquality
object contains equalities and equality
constraints in terms of OptimizationVariable
objects or OptimizationExpression
objects. Each equality uses the comparison operator
==
.
A single statement can represent an array of equalities. For example, you can express the
equalities that each row of a matrix variable x
sums to one in this single
statement:
constrsum = sum(x,2) == 1
Use OptimizationEquality
objects as constraints in an OptimizationProblem
,
or as equations in an EquationProblem
.
Tip
For the full workflow, see Problem-Based Optimization Workflow or Problem-Based Workflow for Solving Equations.
Creation
Create equalities using optimization expressions with the comparison operator
==
.
Include equalities in the Constraints
property of an optimization
problem, or the Equations
property of an equation problem, by using dot
notation.
prob = optimproblem; x = optimvar('x',4,6); SumToOne = sum(x,2) == 1; prob.Constraints.SumToOne = SumToOne; % Or for an equation problem: eqprob = eqnproblem; eqprob.Equations.SumToOne = SumToOne;
You can also create an empty optimization equality by using optimeq
or
optimconstr
.
Typically, you then set the equalities in a loop. For an example, see Create Equalities in Loop. However, for the most
efficient problem formulation, avoid setting equalities in loops. See Create Efficient Optimization Problems.
Properties
Object Functions
evaluate | Evaluate optimization expression or objectives and constraints in problem |
infeasibility | Constraint violation at a point |
issatisfied | Constraint satisfaction of an optimization problem at a set of points |
show | Display information about optimization object |
write | Save optimization object description |