300 likes | 493 Views
DMOR. Linear Programming. Unconstrained optimization Constrained optimization Linear programming Non-linear programming programming – arch. planning Constrained optimization elements : decision variables objective function constraints variable bounds. Bike company.
E N D
DMOR LinearProgramming
Unconstrainedoptimization • Constrainedoptimization • Linearprogramming • Non-linearprogramming programming – arch. planning Constrainedoptimizationelements: • decision variables • objective function • constraints • variable bounds
Bike company • Bike company produces: • Mountainbikes • Race bikes • Wants to maximize profit by settingquantities of eachbikeproduced • No demandrestrictions • Twoteamsproducetwokinds of bikes: • Mountainbike team canproduceup to 2 bikes per day • Race bike team canproduceup to 3 bikes per day • Equalamount of time using metal finishingmachineisneeded for bothkinds of bikes. • Up to 4 bikescan go throughthemachinedaily • Theacountantestimatesprofits for eachbike • Mountain$15 • Race$10
Solution • Intuitivesolution • We produce as many mountainbikes as possible(max 2) and what’sleftgoes for race bikes (2). • Generated Profit: $30+$20=$50. • Linearprogramming • Decisionvariables: Number of mountainx1and race x2bikes • Nonnegative: x1≥0, x2≥0 • Objectivefunction: max daily profit: max Z=15x1+10x2(in $/day) • Constraints: • Dailymountainbikeproduction limit: x1≤2(inbikes/day) • Daily race bikeproduction limit: x2≤3(inbikes/day) • Metal finishingmachine limit: x1+x2 ≤ 4 (inbikes/day)
Cornersareimportant • feasible region • Isoprofit lines areparallel • Profit increasesthe most for the gradient direction • Cornersstickoutsidethe most • Optimum is a corneror a an edgetogetherwithtwoendpoint (neighbouring) corners • Iftwocornersareoptimalthenthelinebetweenthemisalso
Linearprogrammingassumptions • Linearindecisionvariables • Additivity and proportionality • Excludescurves, step-functions, interactionfactors, e.g. 5x1x2, start-upcosts • Decisionvariablesarereal-valued • And not integer-valued • Programmingin general assumesknowledge of alltheparameters • Nevertheless we can do sensitivity analysis
An LP problem instandard form Features: • Objectiveis to maximze • Constraintsonly≤ • Non-negativeconstraints’ RHS • Decisionvariablesarenonnegative Algebraicformulation: • Objectivefunction: • mfunctionalconstraints: • Variablebounds
Definitions • solution • cornerpoint solution • feasible cornerpointsolution • adjacent cornerpointsolutions
Keyproperties • Optimalcornerpointsolutionisalways a feasiblecornerpointsolution • Ifobjectivefunctionvalue for a givenfeasiblecornerpointsolutionis not less thantheobjectivefunctionvalue for allfeasibleadjacentcornerpointsolution, thenthissolutionisoptimal • Thereisfinitenumber of feasiblecornerpointsolutions Implications • Searchthecornerpoints • Easy to saywhichcornerpointisoptimal • Algorithm will stop afterfinitenumber of iterations
Simplexmethod Twophases: • Start-up– findanyfeasiblecornerpointsolution • Standard form isgoodbecausetheorginisalways a feasiblecornerpointsolution • If not in standard form, we needadditionalprocedure (to be describedlater) • Iterations– move to adjacentfeasiblecornerpointsolutionssuchthateach time youimprovetheobjectivefunctionvalue • Stop when no improvementpossible
Algebraicmethod • Millions of decisionvariablesinrealapplications • Graphicalmethod not possible • Algebraicmethodworksfine • Inequalityconstraintschangedintoequalityconstraints • Solving a system of equationsbeing a subset of allconstraints • Subset– sincecommonly not allequalitiesmeyholdatthe same time • We need a way to rememberwhichequalitiesareinthesubset(activeconstraints) • We introduceslack variablese.g. x1 ≤ 2 changedintox1 + s1 = 2, wheres1≥ 0is a slackvariable
Bike company • Twodimensional problem becomesnowfive-dimesional • Slackvariableispositiveonlyifthecorrespondingconstraintisactive More concepts: • augmented solution: valuesgiven for allvariables, e.g. extendedoptimalcornersolution for Bike company isx1,x2,s1,s2,s3 = (2,2,0,1,0) • basic solution: extendedcornerpointsolution (feasibleorinfeasible), e.g.(2,3,0,0,-1) isbasicinfeasiblesolution • basic feasible solution:feasiblecornerpointsolutione.g.(0,3,2,0,1)
Settingvariablevalues • degrees of freedom df df =(number of variables) - (number of independent equalities) • Simplexmethodautomaticallyassigns zero value (correspondingconstraintactive) to df out of allvariables and thendeterminestheothervalues • x1=0 meansthatconstraintx1 ≥ 0 isactive • x2=0 meansthatconstraint x2 ≥ 0 isactive • s1=0 meansthatconstraint x1≤ 2 isactive • s2=0 meansthatconstraint x2 ≤ 3isactive • s3=0 meansthatconstraint x1+x2≤ 4isactive • In ourexampledf=2, hencetwovariableswill be assigneda zero value
More terminology • nonbasic variable: variablewhichcurrentlyisassigned a zero value • basic variable: variablewhichiscurrently NOT assigned a zero value • In standard form positive • Zero inspecialcases • basis: the set of currentbasicvariables MANTRA: Nonbasic, value zero, constraintactive • We canguessthebasis but we have to be careful • We cangetinfeasiblecornerpointsolution(previouspicture) • No cornerpointatall (below)
Moving to a betteradjacentfeasiblecornerpointsolution • Adjacentcornerpointsolutionisa goodchoicebecause: • In twoadjacentcornerpointsthebasic and nonbasic set areidentical but for one element • Example • PointA: nonbasic set= {s2,s3}, basic set= {x1,x2,s1} • PointB: nonbasic set= {s1,s2}, basic set= {x1,x2,s3} Thisisnecessaryyet not sufficientcondition for adjacency (vide(0,4) and(4,0))
Threeconditions for moving to a newcornerpointsolution • Have to be adjacent • Have to be feasible • Thenewsolutionhave to be betterthanthe old one • Twosteps: • Determine a nonbasicvariablewhichimprovestheobjectivefunction most. Movethisvariableintobasic set (entering basic variable) • Increasevalue of enteringbasicvariableup to the moment one of thebasicvariablesreaches zero. Movethisvariableintononbasic set (leaving basic variable) • x1improvesobjectivefunction most • Constraintx1≥ 0 ceases to be active • Onlyx1increases so we knowthemovementdirection • Theconstraintwhich will be crossedover first isx1 ≤ 2.
Algebraically • In theoriginthesituationisthefollowing: • Basic variables: s1,s2,s3 • Nonbasicvariables: x1,x2 • Basic enteringvariable: x1 • In a newcornerpointsolution, whichislocatedattheintersection of theedges of twoconstraintsx2≥ 0 and x1≤ 2 (point (2,0)), we have: • Basic variables: x1,s2,s3 • Nonbasicvariables: x2,s1 • We exchangedx1fors1
Minimumratio test • In order to findbascileavingvariable we have to findthesmallestvalue for thefollowingratio: • In ourexample, the denominator isalways 1. Generallyitdoesn’thave to be thatway. • Twospecialcases: • Enteringbasicvariablecoefficientis0 (theconstraints do not intersect) • Enteringbasicvariablecoefficientisnegative (theconstraintsintersect but theenteringbasicvariableincreasesintheoppositedirectioninrelation to theintersection point)
Finding a newbasicfeasiblesolution • We found a newbasis – whatthen? • We cansuibstitute zero intoallnonbasicvariables and solvetheresulting system of m x m equations by Gaussianelimination • More effectiveis to performonly a part of Gaussianeliminationineach step • When to stop iterating? (Jokeabout a computer scientist) • When we cannotfindbasicenteringvariable
Simplex tableau • Starting point • Tableau inproper form • One basicvariable for eachequality • Basic variablecoefficientalways+1 and coefficientsabove and beloware zero • Z istreated as a basicvariable of theobjectivefunction • Theadvantage of theproper form istaht we cannreadcurrentsolutiondirectlyfromthe tableau.
2.1 Are we done? No, we have 2 negativecoefficientsinthe first raw 2.2 Choosebasicenteringvariable Most negativecoefficientis for x1 2.3 Choosebasicleavingvariable Minimalratio test: • Ifthereis 0 ornegativenumberinthepivotcolumnwrite „no limit” • Thesmallestvalueis 2: thecorrespondingrawiscalledthepivotraw Pivot element
2.4 Updatethe tableau • In „basicvariable” columnexchangebasicleavingvariablewithbasicenteringvariable • Ifpivot element is not equal to 1, divideallpivotrawcoefficients by pivot element value • But for thepivot element, we make allthecoefficientsinthepivotcolumnequal to zero
Continued • New solution (x1,x2,s1,s2,s3)=(2,0,0,3,2), Objectivefunctionvalue Z=30 2.1 We are not optimalyet 2.2, 2.3 A newbasicentering and leavingvariable 2.4 Back to proper form
Specialcases • A drawwhenchoosingbasicenteringvariable, e.g. Z = 15x1+15x2 • A drawwhenchoosingbasicleavingvariable– choosethe one you want – thecorner will the same anyway • A variablewhich was not chosen for thebasicleavingvariable will remainbasic but will have a calculatedvalue of 0 • A variablewhich was chosen will have an assignedvalue of 0 Basic feasiblesolutioninsuchcaseiscalleddegenerateand canlead to cyclesinmorethantwodimensions (cornersA,C – B,C – A,C)
Minimalratio test gives „no limit” everywhere– unbounded problem – no solution • Usuallymeanyouforgotsomeconstraint • In theoptimalsolutioncoefficients of somenonbasicvariableshavevalue of zero intheobjectivefunctionraw • Choosingthisvariable to enter thebasishas no effect on theobjectivefunctionvalue • But itchangesbasicfeasiblesolution • Itmeans we havemultipleoptimum solutions
In practice • input formats: • Algebraicformulation • Spreadsheetformulation(columns: variables, raws: constraints) • Algebraiclanguage, compact way to writethe model (indices make itshort) – thebestinpractice • Individualformats
1963 model • Factories (Seattle i San Diego) and Markets (New York, Chicago i Topeka) • Satisfyingthesupply and demandresrtictions we strive to minimize transport costs of a homogenousgoodsbetweenfactories and markets