Application Center - Maplesoft

# Linear Programming Problems Analysis Maplet

You can switch back to the summary page by clicking here.

Linear_Programming_M.mws

Procedures and a Maplet for Analyzing Linear Programming Problems

by P.H. Stikker
(version: 07 May 2002)

 > restart: with(simplex): with(plots): with(Maplets[Elements]): counting:=0:

Warning, the protected names maximize and minimize have been redefined and unprotected

Warning, the names changecoords and display have been redefined

What's new in this version (updated May 7, 2002)?

-
Corner walk

There is now an extra button that allows the user to 'walk' around all corners of the feasible area

- Mark corners

In the 'plot options' screen is a new option 'Mark corners'. This option (when selected) shows the corners of the feasible area and marks them with a circle (also the size and color of the circle can be changed).

-
Range plot

For the range of the plot (xMin,xMax, yMin and yMax) is now a help window. In this window you can let the Maplet/Maple calculate all corners of the feasible area and use these coordinates to set the range.

-
Saving
The problem of saving the constraints (and other options) as variables is solved. All possible interesting calculations/inputs can be saved now as variables.

- Starting the maplet
Since I solved the saving problem, it is now possible to 're-run' the maplet by one single line (
LinEquations(): )

- The slider

The slider now has a range of -10000..10000 (instead of -10..10). This means the objective function can now be moved more fluent.

- Calculations

Although rounding is sometimes not preferred, I think most Maple users still prefer to see the decimal value than the fraction. Therefor there is now an option to select the amount of digits to be used at the starting screen.

-
Small changes
Some other changes have been made to improve the lay-out of the Maplet. All buttons now have a so called 'tooltip', there are a few more borders and the 'z-value' is now always shown on the right-top of the plot and doesn't show the comma anymore (i.e. [z=, 0.3] now is z=0.3) . Also the info-screen is not a seperate Maplet anymore, but has been 'integrated' in 'the main maplet'.

The new version has as a drawback that the plot in the first window becomes very small. If you are using a high-resolution screen or a big screen this shouldn't be a problem, since you can always adjust the size of the Maplet. In other cases I suggest to use the 'plot in new window' option.

Introduction

Gregory A. Moore wrote a worksheet to solve linear inequalities in 2 dimensions and solve linear programming problems of optimizing a function over these planar regions ( http://www.mapleapps.com/powertools/postsecondary/html/0301.html). In this worksheet I will show a couple of procedures that can solve these type of problems, along with a maplet .
The Maplet is written by using Dutch names for the variables, but the maplet shows everything in English.  If you have any suggestions please contact me at
p.stikker@hsholland.nl

 >

Procedures

In the following procedures in below, we will create a complete procedure showing all information possible from linear inequalities

Procedure 1

The region that we are interested in can also be shown each time by use of the following procedure:  a, b, c and d are the desired x- and y-ranges over which to show the region.

 > solutionproc:=proc(a,b,c,d) local solution,value:   solution:=maximize(Objective,Constraints):   value:=subs(solution,Objective):   print(`The region is:`);   print(inequal(Constraints, x=a..b,y=c..d,optionsfeasible=(color=red),         optionsexcluded=(color=white),optionsclosed=(color=coral),thickness=2));   print(`The optimal point is`);   print(solution);   print(`The objective function then has a value of`);   print(value); end:

 > Constraints:={x+y<=20,x>=0,x<=12,y>=0,y<=14};

 > Objective:=2*x+10*y+11;

 >

 > solutionproc(-2,20,-2,25);

Procedure 2

In the previous worksheet ( http://www.mapleapps.com/powertools/postsecondary/html/0301.html) the simplex method was used to calculate the answer. There are other ways to come to the answer. The first one is called the  "Corner walk method". The idea is to substitute the coordinates of each corner of the region into the objective function. The highest value is then the answer.  The problem with this approach is that the number of corners of the region grows exponentially with the number of inequality constraints.

A graphical approach is also possible. You draw a line along which the objective function is constant.  Then translate this line parallel until it is just about to leave the feasible region.  At this point, the line will intersect a corner.  This corner will be either a max or a min of the objective function over the region.

The following procedure uses the graphical approach with an animation.  Click on the graph below and press the "Play" button in the animation tool bar above.

 > GraphicAppMax:=proc(a,b,c,d) local solution,value,anim,thearea:   solution:=maximize(Objective,Constraints):   value:=   subs(solution,Objective):   anim:=    animate(solve(Objective=u,y),x=a..b,u=0..subs(solution,Objective),color=black):   thearea:= inequal(Constraints, x=a..b,y=c..d,optionsfeasible=(color=blue),             optionsexcluded=(color=white),optionsclosed=(color=coral),thickness=2):   print(`The region and the objective function`);   print(display(anim,thearea));   print(`The optimal point is`);   print(solution);   print(`The objective function than has a value of`);   print(value); end:

 > GraphicAppMax(-2,20,-2,25);

 >

Procedure 3

What if we don't want to optimise but minimise the whole situation. A small change makes this possible:

 > GraphicAppMin:=proc(a,b,c,d) local solution,value,anim,thearea:   solution:=minimize(Objective,Constraints):   value:=subs(solution,Objective):   anim:=animate(solve(Objective=u,y),x=a..b,u=subs(solution,Objective)..200,color=black):   thearea:=inequal(Constraints, x=a..b,y=c..d,optionsfeasible=(color=blue),            optionsexcluded=(color=white),optionsclosed=(color=coral),thickness=2):   print(`The region and the objective function`);   print(display(anim,thearea));   print(`The minimal point is`);   print(solution);   print(`The objective function then has a value of`);   print(value); end:

 > Constraints:={x+y<=20,x>=0,x<=12,y>=0,y<=14};

 > Objective:=2*x+10*y+11;

 > GraphicAppMin(-1,18,-1,20);

 >

Two extra's

Often a system of constraints represents the capacity of machines or departments. If someone outside the company would then like to rent this capacity he/she will have to offer a reasonable price. He/she wouldn't like to pay too much, but for the person who rents the capacity the price should still be good enough. This problem is called the dual problem and can be represented by Maple:

 > dual(Objective,Constraints, z );

 >

A second thing is the way we enter the constraints. Often the constraints look like: ax + by <= c, this is often called the standard form. Not always the constraints are written down in this way (i.e. ax + c <= -y or ax + by = c).
Maple can show the standard form:

 > standardize( {3*x-4 <= 4*y, 4*x+3*y = 5} );

 >

These two points we can easily add to our procedure:

 > GraphicSol:=proc(a,b,c,d) local solutionMax,solutionMin,valueMax,valueMin,anim,thearea,duaal:   solutionMax:=maximize(Objective,Constraints):   solutionMin:=minimize(Objective,Constraints):   valueMax:=subs(solutionMax,Objective):   valueMin:=subs(solutionMin,Objective):   anim:=animate(solve(Objective=u,y),x=a..b,                 u=subs(solutionMin,Objective)..subs(solutionMax,Objective),color=black):   thearea:=inequal(Constraints, x=a..b,y=c..d,optionsfeasible=(color=blue),                    optionsexcluded=(color=white),optionsclosed=(color=coral),thickness=2):   print(`The region and the objective function`);   print(display(anim,thearea));   print(`The maximum optimal point is`);   print(solutionMax);   print(`The objective function then has a value of`);   print(valueMax);   print(``);   print(`The minimum optimal point is`);   print(solutionMin);   print(`The objective function then has a value of`);   print(valueMin);   print(`The dual problem is:`);   print(dual(Objective,Constraints,z));   print(``);   print(`The standard form of these constraints is:`);   print(standardize(Constraints)); end:

 > GraphicSol(-2,18,-2,20);

 >

Final procedure

The last procedure already looks pretty good, but there is small catch. If there is no maximum or minimum, the procedure won't work:

 > Constraints:={x+y<=20,x>=0,x<=12,y<=14};

 > Objective:=2*x+10*y+11;

For this linear program, there is no minimum solution because the feasible region is unbounded in the direction , which has negative dot-product with the objective vector .  See the region below.

 > GraphicSol(-2,18,-2,20);

Error, (in animate) Third argument must be a range in this case

 > inequal(Constraints, x=-2..15, y=-5..15, optionsfeasible=(color=blue),        optionsexcluded=(color=white), optionsclosed=(color=coral), thickness=2);

By using some if-statements, we can get around this problem.

 > GraphicSol:=proc(a,b,c,d) local solutionMax,solutionMin,valueMax,valueMin,anim,thearea,duaal:   solutionMax:=maximize(Objective,Constraints):   solutionMin:=minimize(Objective,Constraints):   valueMax:=subs(solutionMax,Objective):   valueMin:=subs(solutionMin,Objective):   thearea:=inequal(Constraints, x=a..b,y=c..d,optionsfeasible=(color=blue),                    optionsexcluded=(color=white),optionsclosed=(color=coral),thickness=2):   if solutionMin<>NULL then      if solutionMax<>NULL then         anim:=animate(solve(Objective=u,y),x=a..b,                       u=subs(solutionMin,Objective)..subs(solutionMax,Objective),color=black                      ):      else         anim:=animate(solve(Objective=u,y),x=a..b,                       u=subs(solutionMin,Objective)..subs({x=b,y=d},Objective),color=black                      ):      end if:   else     if solutionMax<>NULL then         anim:=animate(solve(Objective=u,y),x=a..b,                       u=subs({x=a,y=c},Objective)..subs(solutionMax,Objective),color=black                      ):     else         anim:=animate(solve(Objective=u,y),x=a..b,                       u=subs({x=a,y=c},Objective)..subs({x=b,y=d},Objective),color=black                      ):     end if:   end if:   print(`The region and the objective function`);   print(display(anim,thearea));   print(`The maximum optimal point is`);   print(solutionMax);   print(`The objective function then has a value of`);   print(valueMax);   print(``);   print(`The minimum optimal point is`);   print(solutionMin);   print(`The objective function then has a value of`);   print(valueMin);   print(`The dual problem looks as following:`);   print(dual(Objective,Constraints,z));   print(``);   print(`The standard form of these constraints looks like:`);   print(standardize(Constraints)); end:

 >

Now let's see if this does work:

 > Constraints:={x+y<=20,x>=0,x<=12,y<=14};

 > Objective:=2*x+10*y+11;

 > GraphicSol(-2,18,-5,20);

 >

The Maplet

I initialy wrote this Maplet using Dutch words. I only changed the names in the Maplet itself not the variables. It will therefore be hard to understand the programing but the Maplet itself shouldn't be any problem cause I changed everything into English.

Help procedures

GraphicSolMaplet

 > GraphicSolMaplet:=proc(Objective,p,q,r,s,t,u,v,w,n,z,a,b,c,d,e,zw,colr,colo,colex,colin,axe,THC,THO,CC,PP,POCL,TPO,EVO) local helpx,helpy,helpz,objPlot,Constraints,anim,feasarea,zvaluemax,zvaluemin,      i,h,tp1,tp2,tp3,tp4,tp5,tp6,tp7,tp8,tp9,tp10,zpt,zText,zwg,i2,j2,hulp,coordinates,listcoord,ph,regcorners,k2,r2,helpcorn,showpoints,l2,Points2,counting2: global counting: if p<>0 then      Constraints:={p}:      i:=solve(lhs(p)=rhs(p),y):      h:=subs(x=a,i):     if i<>NULL then        if h>d then          tp1:=textplot([solve(d=i,x),d,"Cons.1"],                        color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else           tp1:=textplot([a,h,"Cons.1"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):        fi:     else        h:=solve(lhs(p)=rhs(p),x);        tp1:=textplot([h,c,"Cons.1"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else     tp1:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if: if q<>0 then      Constraints:=Constraints union {q}:   i:=solve(lhs(q)=rhs(q),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp2:=textplot([solve(d=i,x),d,"Cons.2"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp2:=textplot([a,h,"Cons.2"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(q)=rhs(q),x);        tp2:=textplot([h,c,"Cons.2"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp2:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if r<>0 then      Constraints:=Constraints union {r}:   i:=solve(lhs(r)=rhs(r),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp3:=textplot([solve(d=i,x),d,"Cons.3"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp3:=textplot([a,h,"Cons.3"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(r)=rhs(r),x);        tp3:=textplot([h,c,"Cons.3"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp3:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if s<>0 then      Constraints:=Constraints union {s}:   i:=solve(lhs(s)=rhs(s),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp4:=textplot([solve(d=i,x),d,"Cons.4"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp4:=textplot([a,h,"Cons.4"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(s)=rhs(s),x);        tp4:=textplot([h,c,"Cons.4"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp4:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if t<>0 then      Constraints:=Constraints union {t}:   i:=solve(lhs(t)=rhs(t),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp5:=textplot([solve(d=i,x),d,"Cons.5"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp5:=textplot([a,h,"Cons.5"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(t)=rhs(t),x);        tp5:=textplot([h,c,"Cons.5"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp5:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if u<>0 then      Constraints:=Constraints union {u}:   i:=solve(lhs(u)=rhs(u),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp6:=textplot([solve(d=i,x),d,"Cons.6"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp6:=textplot([a,h,"Cons.6"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(u)=rhs(u),x);        tp6:=textplot([h,c,"Cons.6"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp6:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if v<>0 then      Constraints:=Constraints union {v}:   i:=solve(lhs(v)=rhs(v),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp7:=textplot([solve(d=i,x),d,"Cons.7"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp7:=textplot([a,h,"Cons.7"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(v)=rhs(v),x);        tp7:=textplot([h,c,"Cons.7"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp7:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if w<>0 then      Constraints:=Constraints union {w}:   i:=solve(lhs(w)=rhs(w),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp8:=textplot([solve(d=i,x),d,"Cons.8"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp8:=textplot([a,h,"Cons.8"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(w)=rhs(w),x);        tp8:=textplot([h,c,"Cons.8"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp8:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if n<>0 then      Constraints:=Constraints union {n}:   i:=solve(lhs(n)=rhs(n),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp9:=textplot([solve(d=i,x),d,"Cons.9"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp9:=textplot([a,h,"Cons.9"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(n)=rhs(n),x);        tp9:=textplot([h,c,"Cons.9"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp9:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if:   if z<>0 then      Constraints:=Constraints union {z}:   i:=solve(lhs(z)=rhs(z),y):   h:=subs(x=a,i):     if i<>NULL then         if h>d then           tp10:=textplot([solve(d=i,x),d,c,"Cons.10"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]);        else                   tp10:=textplot([a,h,"Cons.10"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):         fi:     else        h:=solve(lhs(z)=rhs(z),x);        tp10:=textplot([h,c,"Cons.10"],color=colr,align=RIGHT,font=[TIMES,BOLD,13]):     fi:  else   tp10:=textplot([0,0,``],font=[TIMES,BOLD,13]):   end if: if CC=1 then    counting:=counting+1: fi: if CC=0 then    counting:=0: fi: if CC=1 then    counting:=counting+1; fi: if CC=0 then    counting:=0: fi: regcorners:={}: listcoord:=NULL: for j2 from 1 to nops(Constraints) do     for i2 from j2 to nops(Constraints)-1 do     hulp[i2]:=convert({Constraints[j2],Constraints[i2+1]},equality):     coordinates:=solve(hulp[i2]):     if coordinates<>NULL then     listcoord:=listcoord,coordinates:     fi:         od: od: listcoord:={listcoord}: for k2 from 1 to nops(listcoord) do ph:=subs(listcoord[k2],Constraints): helpcorn:=0;     for r2 from 1 to nops(ph) do                  if evalb(ph[r2])=true then         helpcorn:=helpcorn+1:         fi:     od:     if helpcorn=nops(ph) then     regcorners:=regcorners union {listcoord[k2]}:     fi:   od: zvaluemax:=subs({x=b,y=d},Objective): zvaluemin:=subs({x=a,y=c},Objective): helpx:=(a+b)/2: helpy:=(c+d)/2: helpz:=(abs(zvaluemax)+abs(zvaluemin))/20001*e+subs({x=helpx,y=helpy},Objective): if CC=0 then if zw=`Type in a value` then objPlot:=solve(Objective=helpz,y): zText:=cat(`z=`,convert(evalf(helpz,EVO),string)): else objPlot:=solve(Objective=zw,y): zText:=cat(`z=`,convert(evalf(zw,EVO),string)): hulpvoorslider=zw: fi: else    counting2:= 1+(counting mod nops(regcorners)):    zText:=[regcorners[counting2],cat(`z= `,convert(evalf(subs(regcorners[counting2],Objective),EVO),string))]:    objPlot:=solve(Objective=subs(regcorners[counting2],Objective),y): fi: if PP=true then Points2:=NULL:  for l2 from 1 to nops(regcorners) do      if lhs(regcorners[l2,1])=x then         Points2:=Points2,[rhs(regcorners[l2,1]),rhs(regcorners[l2,2])];      else         Points2:=Points2,[rhs(regcorners[l2,2]),rhs(regcorners[l2,1])];      fi:  od:  showpoints:=pointplot({Points2},symbolsize=TPO,symbol=CIRCLE,color=POCL): else  showpoints:=pointplot({[0,0]},symbol=POINT,symbolsize=1): fi: zpt:=textplot([b-1,d,zText],align=LEFT,color=colo,font=[TIMES,BOLD,13]): anim:=plot(objPlot,x=a..b,y=c..d,color=colo,thickness=THO,font=[TIMES,BOLD,13]): feasarea:=inequal(Constraints, x=a..b,y=c..d,optionsfeasible=(color=colin),       optionsexcluded=(color=colex),optionsclosed=(color=colr),thickness=THC):       display(showpoints,anim,feasarea,tp1,tp2,tp3,tp4,tp5,tp6,tp7,tp8,tp9,tp10,zpt,axes=axe,font=[TIMES,BOLD,13]); end:

 >

maximum

 > maximum:=proc(a,b,c,d,t,u,v,w,y,z,e,EVO) local Constraints:   if a<>0 then      Constraints:={a}   end if:   if b<>0 then      Constraints:=Constraints union {b}   end if:   if c<>0 then      Constraints:=Constraints union {c}   end if:   if d<>0 then      Constraints:=Constraints union {d}   end if:   if t<>0 then      Constraints:=Constraints union {t}   end if:   if u<>0 then      Constraints:=Constraints union {u}   end if:   if v<>0 then      Constraints:=Constraints union {v}   end if:   if w<>0 then      Constraints:=Constraints union {w}   end if:   if y<>0 then      Constraints:=Constraints union {y}   end if:   if z<>0 then      Constraints:=Constraints union {z}   end if:  evalf(maximize(e,Constraints),EVO); end:

 >

minimum

 > minimum:=proc(a,b,c,d,t,u,v,w,y,z,e,EVO) local Constraints:   if a<>0 then      Constraints:={a}   end if:   if b<>0 then      Constraints:=Constraints union {b}   end if:   if c<>0 then      Constraints:=Constraints union {c}   end if:   if d<>0 then      Constraints:=Constraints union {d}   end if:   if t<>0 then      Constraints:=Constraints union {t}   end if:   if u<>0 then      Constraints:=Constraints union {u}   end if:   if v<>0 then      Constraints:=Constraints union {v}   end if:   if w<>0 then      Constraints:=Constraints union {w}   end if:   if y<>0 then      Constraints:=Constraints union {y}   end if:   if z<>0 then      Constraints:=Constraints union {z}   end if:  evalf(minimize(e,Constraints),EVO); end:

 >

objfuncvalue

 > objfuncvalue:=proc(a,b,c,d,t,u,v,w,y,z,e,EVO) local Constraints,h:   if a<>0 then      Constraints:={a}   end if:   if b<>0 then      Constraints:=Constraints union {b}   end if:   if c<>0 then      Constraints:=Constraints union {c}   end if:   if d<>0 then      Constraints:=Constraints union {d}   end if:   if t<>0 then      Constraints:=Constraints union {t}   end if:   if u<>0 then      Constraints:=Constraints union {u}   end if:   if v<>0 then      Constraints:=Constraints union {v}   end if:   if w<>0 then      Constraints:=Constraints union {w}   end if:   if y<>0 then      Constraints:=Constraints union {y}   end if:   if z<>0 then      Constraints:=Constraints union {z}   end if: h:=maximize(e,Constraints): evalf(subs(h,e),EVO); end:

 >

objfuncvalue2

 > objfuncvalue2:=proc(a,b,c,d,t,u,v,w,y,z,e,EVO) local Constraints,h:   if a<>0 then      Constraints:={a}   end if:   if b<>0 then      Constraints:=Constraints union {b}   end if:   if c<>0 then      Constraints:=Constraints union {c}   end if:   if d<>0 then      Constraints:=Constraints union {d}   end if:   if t<>0 then      Constraints:=Constraints union {t}   end if:   if u<>0 then      Constraints:=Constraints union {u}   end if:   if v<>0 then      Constraints:=Constraints union {v}   end if:   if w<>0 then      Constraints:=Constraints union {w}   end if:   if y<>0 then      Constraints:=Constraints union {y}   end if:   if z<>0 then      Constraints:=Constraints union {z}   end if: h:=minimize(e,Constraints): evalf(subs(h,e),EVO); end:

 >

dualproc

 > dualproc:=proc(a,b,c,d,e,f,g,h,i,j,k) local dulijst:   if a<>0 then      dulijst:={a}   end if:   if b<>0 then      dulijst:=dulijst union {b}   end if:   if c<>0 then      dulijst:=dulijst union {c}   end if:   if d<>0 then      dulijst:=dulijst union {d}   end if:   if e<>0 then      dulijst:=dulijst union {e}   end if:   if f<>0 then      dulijst:=dulijst union {f}   end if:   if g<>0 then      dulijst:=dulijst union {g}   end if:   if h<>0 then      dulijst:=dulijst union {h}   end if:   if i<>0 then      dulijst:=dulijst union {i}   end if:   if j<>0 then      dulijst:=dulijst union {j}   end if: dual(k,dulijst,z); end:

 >

output

 > output:=proc(R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,t,xMin,xMax,yMin,yMax) global gC1,gC2,gC3,gC4,gC5,gC6,gC7,gC8,gC9,gC10,gObj,gDual,gConst,gMax,gMin,gzMax,gzMin,gxMin,gxMax,gyMin,gyMax: gObj:=t:   if R1<>0 then      gConst:={R1}:      gC1:=R1:   end if:   if R2<>0 then      gConst:=gConst union {R2}:      gC2:=R2:   end if:   if R3<>0 then      gConst:=gConst union {R3}:      gC3:=R3:   end if:   if R4<>0 then      gConst:=gConst union {R4}:      gC4:=R4:   end if:   if R5<>0 then      gConst:=gConst union {R5}:      gC5:=R5:   end if:   if R6<>0 then      gConst:=gConst union {R6}:      gC6:=R6:   end if:   if R7<>0 then      gConst:=gConst union {R7}:      gC7:=R7:   end if:   if R8<>0 then      gConst:=gConst union {R8}:      gC8:=R8:   end if:   if R9<>0 then      gConst:=gConst union {R9}:      gC9:=R9:   end if:   if R10<>0 then      gConst:=gConst union {R10}:      gC10:=R10:   end if: gMax:=maximize(gObj,gConst): gMin:=minimize(gObj,gConst): gzMax:=subs(gMax,gObj): gzMin:=subs(gMin,gObj): gDual:=dual(gObj,gConst,z): gxMin:=xMin: gxMax:=xMax: gyMin:=yMin: gyMax:=yMax end:

 >

helpPlotRange

 > helpPlotRange:=proc(a,b,c,d,t,u,v,w,y,z,wh) local regcorners,listcoord,j2,i2,k2,r2,hulp,ph,coordinates,helpcorn,l2,xPoints2,yPoints2,Constraints:   if a<>0 then      Constraints:={a}   end if:   if b<>0 then      Constraints:=Constraints union {b}   end if:   if c<>0 then      Constraints:=Constraints union {c}   end if:   if d<>0 then      Constraints:=Constraints union {d}   end if:   if t<>0 then      Constraints:=Constraints union {t}   end if:   if u<>0 then      Constraints:=Constraints union {u}   end if:   if v<>0 then      Constraints:=Constraints union {v}   end if:   if w<>0 then      Constraints:=Constraints union {w}   end if:   if y<>0 then      Constraints:=Constraints union {y}   end if:   if z<>0 then      Constraints:=Constraints union {z}   end if: regcorners:={}: listcoord:=NULL: for j2 from 1 to nops(Constraints) do     for i2 from j2 to nops(Constraints)-1 do     hulp[i2]:=convert({Constraints[j2],Constraints[i2+1]},equality):     coordinates:=solve(hulp[i2]):     if coordinates<>NULL then     listcoord:=listcoord,coordinates:     fi:         od: od: listcoord:={listcoord}: for k2 from 1 to nops(listcoord) do ph:=subs(listcoord[k2],Constraints): helpcorn:=0;     for r2 from 1 to nops(ph) do                  if evalb(ph[r2])=true then         helpcorn:=helpcorn+1:         fi:     od:     if helpcorn=nops(ph) then     regcorners:=regcorners union {listcoord[k2]}:     fi:   od: xPoints2:=NULL: yPoints2:=NULL:  for l2 from 1 to nops(regcorners) do      if lhs(regcorners[l2,1])=x then         xPoints2:=xPoints2 union {rhs(regcorners[l2,1])}:         yPoints2:=yPoints2 union {rhs(regcorners[l2,2])}:      else         xPoints2:=xPoints2 union {rhs(regcorners[l2,2])}:         yPoints2:=yPoints2 union {rhs(regcorners[l2,1])}:      fi:  od: if wh=x1 then    xPoints2[1]-1; elif wh=xL then    xPoints2[nops(xPoints2)]+1; elif wh=y1 then    yPoints2[1]-1; elif wh=yL then    yPoints2[nops(yPoints2)]+1; fi:     end:

 >

LinEquations

 > LinEquations:=proc() global counting: counting:=0: useold(gC1,gC2,gC3,gC4,gC5,gC6,gC7,gC8,gC9,gC10): end:

 >

 >

The Maplet itself

The main Maplet:

 >

Let's go...

Before you can use the Maplet, we need to enter some initial values.

 > gC1:=x+y<=10: gC2:=x>=0: gC3:=y>=0: gC4:=y<=6: gC5:=0: gC6:=0: gC7:=0: gC8:=0: gC9:=0: gC10:=0: gObj:=2*x+y: gxMin:=-1: gxMax:=11: gyMin:=-1: gyMax:=11:

 >

Let's go:

 > LinEquations():

Initializing Java runtime environment.

 >

If you have chosen the 'save' option you can recall all your variables by typing in the given names (the list is in the 'More info' screen):

 > gConst;

 >

Some final info

Use the procedures

The final procedure was: GraphicSol(a,b,c,d) . Hereby is 'a' the minimum x-value of the plot, 'b' the maximum y-value of the plot, 'c' the minimum y-value of the plot and 'd' the maximum y-value of the plot.

The procedure can only work if you enter the restrictions first by putting them into a list called '
Constraints ' and the objective function as a variable called: ' Objective '.

In below a final example:

 > Constraints:={2*x+3*y<=10,y>=0,x>=0,y<=6}:

 > Objective:=2*x+4*y:

 > GraphicSol(-10,10,-20,20);

Use the Maplet

The Maplet can be run by activating the line in below:

 > LinEquations():

If you would like to use this Maplet more often you could try to create a package from it, or copy paste all the procedures into one big maple line.

As it said on the saving-screen, if you clicked on the option
save , you can re-run the Maplet and it will start with your previous entered conditions and objective function. Also the conditions and objective function are saved (as a string) and can be reviewed by using:

 > gC1; gC2; gC3; gC4; gC5; gC6; gC7; gC8; gC9; gC10; gObj; gDual; gConst; gxMax; gxMin; gyMax; gyMin;

 >

 >

After writing all procedures I started working on the Maplet. I came across some problems during the programming, and solved most of them.
Of course some programming could have been done in a simpler way looking at it afterwards, but it does works. Since I started with the procedures, the plot of the conditions is different in the Maplet.

Problems/Future Ideas

Problem 1
By email I was given a small problem I was unable to solve. The problem was to make the following text appear on the info screen:

Point 1    You can only use x  and y  as variables
Point 2    The objective function should have a*x+b*y+c  as structure
etc...

Problem 2
I would like to solve is the label of the constraints in the plot. At this moment these are sometimes hard to read. Although the axes option helps often...

Problem 3
I couldn't find a way to show an animation in the Maplet. Only by use of the slider I tried to get the closest to this. Unfortunately this means that sometimes the objective function cannot be shown exactly on the maximum or minimum point.

Problem 4

Sometimes you have to click twice now, I don't know why this is and would like to solve the problem. Also the corner walk method sometimes skips a corner.

Idea 1

At this moment the Maplet only shows planar problems. Perhaps an option to calculate optimal points with more variables can be nice.

Idea 2
Creating a package that can run everything in one time..

At this time I think the Maplet and the procedures are useable enough. If you have any comment or usefull information for the problems and ideas please email me (
p.stikker@hsholland.nl). Hope you enjoyed the show,