This has come about after trying to understand what was going on with this question about FindMaximum
and regions. My first thought in that scenario was to set-up EvaluationMonitor
and StepMonitor
to see which points in the region Mathematica visited as it tried to find the maximum.
$Version
(* 10.1.0 for Microsoft Windows (64-bit) (March 24, 2015) *)
(* from the linked question *)
region = Polygon[{{0, 0}, {10, 0}, {10, 5}, {5, 5}, {5, 10}, {0, 10}}];
(* build up a list of regions to test *)
regionlist = {Disk[], Triangle[], Rectangle[], Parallelogram[], region};
(* use FindMaximum *)
result =
Last@FindMaximum[{x + y, {x, y} \[Element] #}, {x, y},
EvaluationMonitor :> Print["Evaluation: ", x, ",", y],
StepMonitor :> Print["Step: ", x, ",", y]] & /@ regionlist
graphics =
MapThread[
Show[ContourPlot[x + y, {x, y} \[Element] #1],
Graphics[{Red, PointSize[Large],
Point[{x, y} /. #2]}]] &, {regionlist, result}];
GraphicsRow[graphics]
When I run this code, for Disk[]
I get a list of steps and evaluations at various values of x
and y
. But when I try using either monitor combined with a region other than Disk[]
, I get no output. Why is this?
FindMaximum::elemc: Unable to resolve the domain or region membership condition
message. $\endgroup$Disk[]
? $\endgroup$Disk[]
comes from a linear programming method, so there are no iterations to monitor. $\endgroup$