You are on page 1of 3

LinearProgrammingonTI89:ATutorialforsimplex()

YanchaoLiu
DepartmentofIndustrialandSystemEngineering
UniversityofWisconsinMadison
yliu67@wisc.edu

Studentsofindustrialengineering(IE)mightencountersuchmomentsfromtimetotimewhenasmall
scalelinearprogramming(LP)modelneedstobesolved.Somemayreachforacomputer.Butwhatif
thecomputerortherightsoftwareisnotavailableatthatparticularmoment?Evenifacomputer
equippedwiththemostadvancedLPsolverisatonesdisposal,typingupthemodelcorrectlyinthe
requiredformatwouldtypicallycostmoretimethantheimportanceofthemodeldeserves.Annoyedby
thisveryfactasanIEstudentmyself,IwroteupasmallLPsolverthatimplementsthetwophase
revisedsimplexalgorithmandrunsonaTI89calculator.IfyouhaveaTI89(orhigher)calculatoras
manyotherengineeringstudentsdo,takeafewminutestoreadthistutorial,andahandyLPsolverwill
beatyourfiguretips.
ThesolveriswritteninClanguageandtheexecutablefileissimplex.89z.Simplytransferthisfiletoyour
TI89calculatorandtheprogramwillbeinstalledandreadytouse.Onthecalculator,itwillbedisplayed
asanAMSprogramnamedsimplex.Thefilesizeis9831bytes.Forgeneralinformationaboutinstalling
programsonaTI89calculator,consultthecalculatormanualortheTIwebsite.

Step1:WriteYourLPModelinStandardForm
HereisthedefinitionofLPstandardform:

Linear programs in standard form (1) have only equality main constraints; (2) have only nonnegative
variables, and (3) have objective function and main constraints simplified so that variables appear at
most once, on the left-hand side, and any constant term (possibly zero) appears on the right-hand
side. [1]

Andthetipsforconvertinginequalities:

Main inequality constraints of a given linear program can be converted into nonnegativities by adding
distinct, nonnegative, zero-cost slack variables in every such inequality and subtracting such slack
variables in every main . [1]

IMPORTANT:Thesolveralwaysattemptstomaximizetheobjectivefunction,thusifyourmodelhasa
minimizationobjectivefunction,youneedtoconvertittoamaximizationonebynegatingallthecost
coefficientsintheobjectivefunction.Seetheexampleinthefiguresbelow.
ThesolveriscompatiblewithanyTIdevicethatrunstheAdvancedMathematicsSoftware(AMS),ofwhichTI89istheoneIown.

12

12

. .


2
4
, 0

1000
1500
1750
4800

Figure1OriginalModel

. .


2
4
, , , ,

1000
1500
1750
4800
0

Figure2StandardformModel

Step2:EnterDatainthesldatFile
CreateatextfileusingtheTextEditorprogramonyourTI89.Nameitsldatandplaceitinthesame
folderassimplexisin.Seefiguresbelow.

Supposethatinyourstandardformmodeltherearenvariables(includingtheslackvariables)andm
equalityconstraints,thenumberofpiecesofdatumyouneedtoenteris2
,andthey
mustbeenteredfollowingthissequence:n,m,A,b,c,whereA,bandcarethecoefficientmatrixand
vectorsintheLPcanonicalform:
max
. .

TakethemodelinFigure2forexample.Thereare6variablesand4constraints,and
1 0 1 0 0
0 1 0 1 0
1 1 0 0 1
4 2 0 0 0
sequenceshouldbe:

0
0
,
0
1

1000150017504800 ,

1290000 ,sotheinput

6410100001010011001042000110001500175048001290000
nm

Aslongasthesequentialorderisobserved,youhaveallthefreedomtoalignthedataentries(using
[SPACE]or[ENTER]keyonyourTI89).Forexample,anyofthefollowingfashionsofsldatfortheabove
modelisacceptable.


However,youstillneedtobeverycautiousaboutwhatyoutypeinthesldatfile.Thesolverwilldosome
datavalidation,butoftentimesitjustrunsoffwithwhateveritisprovidedandmayreportunreliable
results.Garbagein,garbageout!Hereareafewtipsabouthowtomakeavalidsldatfile.

Neverusenonnumericsymbolsexceptforthenegativesign()andthedecimalpoint(.).
Onthecalculator,thenegativesignandtheminussignaredifferent.Becareful!
Donotomitzeros(0)intheendofavector,suchasinthecvector.

Step3:Runsimplex()andBrowsetheResults
FindsimplexintheVARLINKlistorjusttypeinsimplex()onthehomescreen,thenpress[ENTER]torun.
Theresultswillbedisplayedonthescreen.Iftheoptimalsolution(otherthaninfeasibleorunbounded)
isfound,theresultswillalsobesavedinthetextfilenamedslout,whichcanbebrowsedbytheText
Editoraftertheprogramhasended.Beawarethatthesavedresultswillbeupdated(overwritten)by
newoptimalresultsoflaterruns.

Regardlessofthenotationsinyourmodel,thesolverassumesthevariablenamexandtheindexset{1,
2,}intheresultdisplay.Thus,x1correspondstothefirstvariableintheinputmodel,x2thesecond,
andsoforth.Ofanoptimumsolution,onlythebasicvariablevalueswillbedisplayedandallthenon
basicvariablestakethevalue0.
NOTE:DuetothememoryrestrictionsonTI89,thesolveracceptsupto50variablesand49constraints.
FINALWORDS:IhavetestedtheprogramtothebestthatIcantoensureitsrobustness:nomemory
leak,nosystemcollapse,etc.Nevertheless,assemblyprogramsmaycauseseriousproblemstothe
devicethatrunsthem.Iamnotresponsibleforanyconsequenceofusingthesimplex()solver.
Feedbacksandcritiquesarewelcome.

Reference
[1]RonaldL.Rardin,OptimizationinOperationsResearch,PrenticeHall,1997.

You might also like