infeasibility - Constraint violation at a point - MATLAB (original) (raw)
Main Content
Constraint violation at a point
Syntax
Description
Use infeasibility
to find the numeric value of a constraint violation at a point.
[infeas](#d126e118879) = infeasibility([constr](#mw%5Fb9d6993a-9a16-4573-bd90-c6365799d260%5Fsep%5Fshared-constr),[pt](#d126e118847))
returns the amount of violation of the constraint constr
at the point pt
.
Examples
Check whether a point satisfies a constraint.
Set up optimization variables and two constraints.
x = optimvar('x'); y = optimvar('y'); cons = x + y <= 2; cons2 = x + y/4 <= 1;
Check whether the point x = 0
, y = 4
satisfies the constraint named cons
. A point is feasible when its infeasibility is zero.
pt.x = 0; pt.y = 4; infeas = infeasibility(cons,pt)
The point is not feasible with respect to this constraint.
Check the feasibility with respect to the other constraint.
infeas = infeasibility(cons2,pt)
The point is feasible with respect to this constraint.
Check whether a point satisfies a constraint that has multiple conditions.
Set up an optimization variable and a vector of constraints.
x = optimvar('x',3,2); cons = sum(x,2) <= [1;3;2];
Check whether the point pt.x = [1,-1;2,3;3,-1]
satisfies these constraints.
pt.x = [1,-1;2,3;3,-1]; infeas = infeasibility(cons,pt)
The point is not feasible with respect to the second constraint.
Input Arguments
Point to evaluate, specified as a structure with field names that match the optimization variable names, for optimization variables in the constraint. The size of each field in pt
must match the size of the corresponding optimization variable.
Example: pt.x = 5*eye(3)
Data Types: struct
Output Arguments
Infeasibility of constraint, returned as a real array. Each zero entry represents a feasible constraint, and each positive entry represents an infeasible constraint. The size of infeas
is the same as the size of the constraint constr
. For an example of nonscalar infeas
, see Compute Multiple Constraint Violations.
Warning
The problem-based approach does not support complex values in the following: an objective function, nonlinear equalities, and nonlinear inequalities. If a function calculation has a complex value, even as an intermediate value, the final result might be incorrect.
Version History
Introduced in R2017b