4
$\begingroup$

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]

enter image description here

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?

$\endgroup$
3
  • 1
    $\begingroup$ Possibly related: when I try discretizing the regions, I get a FindMaximum::elemc: Unable to resolve the domain or region membership condition message. $\endgroup$ Apr 28, 2015 at 18:11
  • $\begingroup$ @2012rcampion is that for all regions, including Disk[]? $\endgroup$ Apr 29, 2015 at 6:48
  • 3
    $\begingroup$ Since the objective function is linear, probably the solution for all these regions except Disk[] comes from a linear programming method, so there are no iterations to monitor. $\endgroup$
    – ilian
    May 7, 2015 at 12:12

1 Answer 1

3
$\begingroup$

Thanks to a comment from @ilian, I came back to the question:

Since the objective function is linear, probably the solution for all these regions except Disk[] comes from a linear programming method, so there are no iterations to monitor

And indeed, that's we see. Change the function to e.g. $x^{2}+y^{2}$ and EvaluationMonitor/StepMonitor works a treat.

Alternatively, defining the region with machine-precision numbers also works, i.e.

region = Polygon[{{0., 0.}, {10., 0.}, {10., 5.}, {5., 5.}, {5., 10.}, {0., 10.}}]

and indeed doing this seems to solve the problem in the related question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.