FindMaximum in region is a new function in mma10,but when I tried the following example:
region = Polygon[{{0, 0}, {10, 0}, {10, 5}, {5, 5}, {5, 10}, {0, 10}}]
FindMaximum[{x + y, {x, y} \[Element] region}, {x, y}]
Mathematica 10.1 returns
{10., {x -> 5., y -> 5.}}
We can easily know that it is wrong. What's the story?
Answer
Defining just one of the points of the region with a decimal point helps, suggesting that the method chosen by FindMaximum for integer coordinates is a perhaps a linear programming method, and gets stuck at the observed {5, 5}.
Instead one can do:
region = Polygon[{{0., 0}, {10, 0}, {10, 5}, {5, 5}, {5, 10}, {0,
10}}];
result = Last@FindMaximum[{x + y, {x, y} \[Element] region}, {x, y}]
(* {x -> 10., y -> 5.} *)
Show[ContourPlot[x + y, {x, y} \[Element] region],
Graphics[{Red, PointSize[Large], Point[{x, y} /. result]}]]

Comments
Post a Comment