Graphical Linear Programming for Three Variables

Manipulate[
If[planes,If[obj,
Show[region1,region2,region3,options], Show[region1,region2,region3 , Plot3D[z[objfunvalue],{x,0,100},{y,0,100}, Mesh->None, PlotStyle->Green, ClippingStyle->None,PerformanceGoal->"Quality"],options]],If[obj,Show[feasibleregion, options], Show[feasibleregion, Plot3D[z[objfunvalue],{x,0,100},{y,0,100}, Mesh->None, PlotStyle->Green,ClippingStyle->None],options]  ]], 
{{planes,True,"show planes"},{True,False}}, {{obj,False,"hide objective function plane"},{True, False}},{{objfunvalue,200,"objective function value"},80,240,10,Appearance->"Labeled"},Initialization:>(
options={AxesLabel->{Style["x",Italic], Style["y",Italic], Style["z",Italic]}, BoxRatios->Automatic,SphericalRegion->True, ViewPoint->{-0.9, -1.1, 0}, PlotRange->{{0,100},{0,100},{0,100}},ImageSize->{450,400},PlotRangePadding->Scaled[0.02]};region1 = Plot3D[500/9 - x/3 -5y/9, {x,0,100}, {y,0,100}, PlotStyle->LightBlue, Lighting->"Neutral", ClippingStyle->None,Evaluate@options];region2 = Plot3D[70 - 4x/5 , {x,0,100}, {y,0,100}, PlotStyle->Orange, Lighting->"Neutral", ClippingStyle->None,Evaluate@options];region3 = Plot3D[50 -2y/3, {x,0,100}, {y,0,100},PlotStyle->Purple, Lighting->"Neutral", ClippingStyle->None,Evaluate@options];
z[t_] := t/3 - 2x/3 - y/2;feasibleregion = RegionPlot3D[3x + 5y + 9z≤ 500 && 4x + 5z ≤ 350 && 2y + 3z ≤ 150, {x,0,100},{y,0,100}, {z, 0, 100}, Mesh->None,PlotStyle->Directive[Opacity[0.5],Red], Evaluate@options];
)]

This Demonstration shows the graphical solution to the linear programming problem: maximize 4x+3y+6z subject to 3x+5y+9z≤500, 4x+5z≤350, 2y+3z≤150, x≥0, y≥0, z≥0. (The half-planes corresponding to the constraints are colored light blue, orange, and purple, respectively.) The image is oriented so that the feasible region is in front of the planes. When the "show planes" checkbox is not checked, the feasible region appears as a translucent red solid. The bright green plane is the level plane generated by setting the objective function equal to the value indicated by the slider.

Contributed by: Olivia M. Carducci (East Stroudsburg University)