MATLAB: Inequality constraints for optimizer

linear inequality constraintsoptimization

Hello,
I want the solution (x,y) of my optimization problem to belong to a specific region of the search-space as depicted below. This region can have an arbitrary shape.
1st case: The red region is known, by knowing the equation of each red line (segment). Is it possible to create a set of inequalities?
2nd case: The red region is known, by knowing the coordinates of all points of its perimeter. Is it possible to create a set of inequalities?
Thanks in advance.

Best Answer

Assuming the region is convex, the answer is yes in both cases. Otherwise, the answer is no - inequalitites will not be enough to specify a nonconvex polygon.