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:

Andthetipsforconvertinginequalities:

IMPORTANT:Thesolveralwaysattemptstomaximizetheobjectivefunction,thusifyourmodelhasa
minimizationobjectivefunction,youneedtoconvertittoamaximizationonebynegatingallthecost
coefficientsintheobjectivefunction.Seetheexampleinthefiguresbelow.
ThesolveriscompatiblewithanyTIdevicethatrunstheAdvancedMathematicsSoftware(AMS),ofwhichTI89istheoneIown.
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]

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]

Figure1OriginalModel Figure2StandardformModel
Step2:EnterDatainthesldatFile
CreateatextfileusingtheTextEditorprogramonyourTI89.Nameitsldatandplaceitinthesame
folderassimplexisin.Seefiguresbelow.

Supposethatinyourstandardformmodeltherearenvariables(includingtheslackvariables)andm
equalityconstraints,thenumberofpiecesofdatumyouneedtoenteris2 + m n + m + n,andthey
mustbeenteredfollowingthissequence:n,m,A,b,c,whereA,bandcarethecoefficientmatrixand
vectorsintheLPcanonicalform:
max c
1
x
s. t. Ax = b
TakethemodelinFigure2forexample.Thereare6variablesand4constraints,and
A = |
1 u 1 u u u
u 1 u 1 u u
1 1 u u 1 u
4 2 u u u 1
|,b = |1uuu 1Suu 17Su 48uu],c = |12 9 u u u u],sotheinput
sequenceshouldbe:

Aslongasthesequentialorderisobserved,youhaveallthefreedomtoalignthedataentries(using
[SPACE]or[ENTER]keyonyourTI89).Forexample,anyofthefollowingfashionsofsldatfortheabove
modelisacceptable.
mox 12x
1
+ 9x
2
s. t. x
1
< 1uuu
x
2
< 1Suu
x
1
+ x
2
< 17Su
4x
1
+ 2x
2
< 48uu
x
1
, x
2
~ u
mox 12x
1
+ 9x
2
s. t. x
1
+ x
3
= 1uuu
x
2
+ x
4
= 1Suu
x
1
+ x
2
+ x
5
= 17Su
4x
1
+ 2x
2
+ x
6
= 48uu
x
1
, x
2
, x
3
, x
4
, x
5
, x
6
~ u
6410100001010011001042000110001500175048001290000
nm A b c

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