# Making a plot to visualize an optimization problem [duplicate]

The feasible region is the rectangle defined by

40,000 <= x <= 80,000
30,000 <= y <= 50,000


intersected with the half-plane x + y <= 110,000.

The optimum is on the upper left hand corner where the lines y = 50,000 and x = 40,000 intersect.

How can I make a plot to visualize this problem?

• What is the formula you are optimising? – Edmund Sep 23 '17 at 19:48
• the formula is '19125. - 0.590625 x + 1.1875 y' – soso Sep 23 '17 at 21:22

You may use RegionPlot and ImplicitRegion to visualise the region. The Optimization guide will be useful to verify your results with functions like Maximize.

I have taken the problem as $\text{Max}(y-x)$ since none was provided.

With[{reg = ImplicitRegion[x + y <= 110000, {{x, 40000, 80000}, {y, 30000, 50000}}]},
RegionPlot[
reg,
Epilog -> {Red, PointSize[Scaled[.04]],
Point[{x, y}] /. Last@Maximize[-x + y, {x, y} ∈ reg]}
]
] Hope this helps.

## Update for ContourPlot

ContourPlot[
-x + y, {x, 40000, 80000}, {y, 30000, 50000},
RegionFunction -> Function[{x, y, z}, x + y <= 110000],
Epilog -> {Red, PointSize[Scaled[.04]],
Point[{x, y}] /.
Last@Maximize[-x + y, {x, y} ∈
ImplicitRegion[x + y <= 110000, {{x, 40000, 80000}, {y, 30000, 50000}}]]},
PlotPoints -> 25,
PlotLegends -> Automatic
] • Thank you so much. but how can I plot the lines on the same graph? – soso Sep 23 '17 at 20:34
• @soso By lines are you referring to contours? If so then see ContourPlot and its the RegionFunction option. – Edmund Sep 23 '17 at 20:58
• How can I do it? – soso Sep 23 '17 at 21:07
• @soso This is kind of awkward because you have accepted someone else's answer but it appears that you need my answer and also would like me to put in more work to refine my answer. I see you are new here so I will hook you up this time. However, in future keep it mind that it is a bit rude to rude accept another answer then ask another poster to refine their answer because that is the one you really want. You are messing with people's imaginary Interweb points. You'll quickly make a bad name for yourself. – Edmund Sep 23 '17 at 21:13
• I'm so sorry. I'm new here. I was not know that I have just to press the answer that I accept. I'm really sorry about that – soso Sep 23 '17 at 21:19

The feasible region is given by

plot3d = Plot3D[
x + y,
{x, 4, 8},
{y, 3, 5},
RegionFunction -> Function[{x, y}, x + y <= 11],
MeshStyle -> None,
ColorFunction -> "SolarColors"
]


This point is used to visualy locate the optimum

point3d = Graphics3D[{
Blend[{Blue, White}],
PointSize[Scaled[0.025]],
Point[{4, 5, 9}]
}
]


Combining the two

Show[
plot3d,
point3d
] 