Linear Programming

Section 1.1 - Geometric Linear Programming in Two Dimensions

Example 1.1.1

LinePlots = Plot[{(3/5)x-3, -(2/3)x + 6, 7}, {x,0,20}, PlotStyle->{{Thickness[0.007], Red},{Thickness[0.007], Yellow}, {Thickness[0.007], Blue}}]

ArrowPlots = Graphics[{Arrowheads[.05], Thickness[.010], Black, Arrow[{{10,3},{8.97, 4.72}}], Black, Arrow[{{4,10/3},{5.11,5.00}}], Black, Arrow[{{7,7},{7,5}}]}];

Show[LinePlots,ArrowPlots]

Soln1 = Solve[{3x-5y==15, 2x+3y==18},{x,y}]

Point1 = {x,y}/.Flatten[Soln1]

Soln2 = Solve[{3x-5y==15,y==7},{x,y}]

Point2 = {x,y}/.Flatten[Soln2]

Point3 = {0,7}; Point4 = {0,6};

Region=Graphics[{Cyan, Polygon[{Point1, Point2, Point3, Point4}]}];

CornerPlot = ListPlot[{Point1, Point2, Point3, Point4}, PlotStyle->Directive[Black, PointSize[Large]]];

TxtPtPlot = Graphics[{Text["Pt 1", {7.2, 0.55}], Text["Pt 2", {16.8, 6.2}], Text["Pt 3", {-0.75, 7.1}], Text["Pt 4", {-0.75, 5.9}]}];

Show[Region, LinePlots, ArrowPlots, CornerPlot, TxtPtPlot, Axes->True, PlotRange->{{-3,20},{-3,10}}]

F[d_, x_] = ((d-x-5)/2);

LevelCurves = Plot[Table[F[dval, x], {dval, 5, 40, 4}], {x,-3, 20}, PlotStyle->{{Thickness[0.004], Black}}];

Show[Region, LinePlots, ArrowPlots, CornerPlot, TxtPtPlot, LevelCurves, Axes->True, PlotRange-> {{-3,20},{-3,10}}]

z = x+2y+5;

N[z/.Soln1][[1]]

N[z/.Soln2][[1]]

N[z/.{x->Point3[[1]], y->Point3[[2]]}]

N[z/.{x->Point4[[1]], y->Point4[[2]]}]

Maximize[{z,3x-5y≤15, -2x-3y≤-18, y≤7, x≥0,y≥0},{x,y}]

Minimize[{z,3x-5y≤15, -2x-3y≤-18, y≤7, x≥0,y≥0},{x,y}]

Section 1.2 - Geometric Linear Programming in Three Dimensions

PlanarPlots = Plot3D[{((-30+5x+3y)/2), ((100-7x-4y)/3), 25}, {x,0,30},{y,0,30},PlotStyle->{{Thickness[0.007], Red},{Thickness[0.007],Yellow}, {Thickness[0.007], Blue}}, Mesh->None, AspectRatio->1, Lighting->"Neutral"];

v1 = {4,15,35/2}; d1 = {5,3,-2};

v2 = {5,5,15}; d2 = {-3,-7,-4};

v3 = {6, 10, 25}; d3 = {0,0,4};

ArrowPlots = Graphics3D[{Arrowheads[.03],Thickness[.005], Black, Arrow[{v1, v1-d1/1.75}], Arrowheads[.03], Thickness[.005], Black, Arrow[{v2, v2-d2/1.75}], Arrowheads[.03], Thickness[.005], Black, Arrow[{v3, v3-d3}]}];

Show[ArrowPlots, PlanarPlots, Axes->True, PlotRange->{{0,20},{0,30},{0,30}}, Lighting->"Neutral"]

Binomial[6,3]

Planes = {-5x-3y+2z==-30,-7x-4y-3z == -100, z==25, x==0, y==0, z==0};

Soln1 = Solve[{Planes[[1]],Planes[[2]],Planes[[5]]},{x,y,z}]

Point1 = ({x,y,z}/.Soln1)[[1]]

Soln2 = Solve[{Planes[[1]],Planes[[2]],Planes[[4]]},{x,y,z}]

Point2 = ({x,y,z}/.Soln2)[[1]]

Soln3 = Solve[{Planes[[1]],Planes[[3]],Planes[[4]]},{x,y,z}]

Point3 = ({x,y,z}/.Soln3)[[1]]

Soln4 = Solve[{Planes[[1]],Planes[[3]],Planes[[5]]},{x,y,z}]

Point4 = ({x,y,z}/.Soln4)[[1]]

Soln5 = Solve[{Planes[[2]],Planes[[3]],Planes[[4]]},{x,y,z}]

Point5 = ({x,y,z}/.Soln5)[[1]]

Soln6 = Solve[{Planes[[2]],Planes[[3]],Planes[[5]]},{x,y,z}]

Point6 = ({x,y,z}/.Soln6)[[1]]

TxtPtPlot = Graphics3D[{Text["Pt 1", Point1], Text["Pt 2", Point2], Text["Pt 3", Point3], Text["Pt 4", Point4], Text["Pt 5", Point5], Text["Pt 6", Point6]}];

Show[ArrowPlots, PlanarPlots, TxtPtPlot, Axes->True, PlotRange->{{0,20},{0,30},{0,30}}, Lighting->"Neutral"]

G[x_,y_,z_] = 9x+2y+5z+13;

LevelCurves = ContourPlot3D[Evaluate[Table[G[x,y,z]==d,{d,50,250,50}]],{x,0,30},{y,0,20},{z,0,30}, Mesh->None, ContourStyle->{{Opacity[0.5],Gray}}, AspectRatio->1/2];

Show[ArrowPlots, PlanarPlots, LevelCurves, Axes->True, PlotRange->{{0,20},{0,30},{0,30}}, Lighting->"Neutral"]

Region1 = Graphics3D[{Cyan,Polygon[{Point1,Point4,Point6}]}];

Region2 = Graphics3D[{Cyan,Polygon[{Point3,Point5,Point2}]}];

Region3 = Graphics3D[{Cyan,Polygon[{Point5,Point6,Point1, Point2}]}];

Region4 = Graphics3D[{Cyan,Polygon[{Point3,Point4,Point6, Point5}]}];

Region5 = Graphics3D[{Cyan,Polygon[{Point1,Point2,Point3, Point4}]}];

Show[PlanarPlots, TxtPtPlot, Region1, Region2, Region3, Region4, Region5, PlotRange->{{0,20},{0,30},{0,30}}, Lighting->"Neutral"]

N[Flatten[{G[x,y,z]/.Soln1, G[x,y,z]/.Soln2, G[x,y,z]/.Soln3, G[x,y,z]/.Soln4,G[x,y,z]/.Soln5, G[x,y,z]/.Soln6}]]

Maximize[{G[x,y,z],5x+3y-2z≤30, -7x-4y-3z≤-100,z≤25,x≥0,y≥0,z≥0},{x,y,z}]

Minimize[{G[x,y,z],5x+3y-2z≤30, -7x-4y-3z≤-100,z≤25,x≥0,y≥0,z≥0},{x,y,z}]

Section 1.3 - The Simplex Algorithm

P = 7250 r + 8875 c + 9250 t + 7950 b;

N[Maximize[{P, 65 r + 95 c + 80 t + 92 b ≤ 2500, 185 r + 235 c + 255 t + 215 b ≤ 6400, 84 r + 175 c + 145 t + 95 b ≤ 3250, 155 r + 70 c + 75 t + 106 b ≤ 3600, r≥0, c≥0, t≥0, b≥0},{r,c,t,b}]]

Section 1.4 - Concluding Remarks

LinearProgramming[{9,2,5},{{5,3,-2},{-7,-4,-3}},{{30,-1},{-100,-1}},{{0, Infinity},{0,Infinity},{0,25}}]