MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define...

86
MODELING (Integer Programming Examples) 1

Transcript of MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define...

Page 1: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

MODELING(IntegerProgramming

Examples)

1

Page 2: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IE400PrinciplesofEngineeringManagement

IntegerProgramming:Set5

Page 3: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6
Page 4: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6
Page 5: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6
Page 6: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6
Page 7: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IntegerProgramming:Sofar,wehaveconsideredproblemsunderthefollowingassumptions:

i. Proportionality&Additivityii. Divisibilityiii. Certainty

Whilemanyproblemssatisfytheseassumptions,there areother

problems inwhichwewillneedtoeitherrelax these assumptions.

For example,considerthefollowingbusschedulingproblem:

Page 8: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IntegerProgramming:

BusScheduling:Periods 1 2 3 4 5 6

Hours 0-4AM 4-8 AM 8AM– 12 PM 12- 4PM 4 – 8PM 8PM-0AM

Min. #ofbusesrequired

4 8 10 7 12 4

Eachbusstartstooperateatthebeginningofaperiodandoperates

for8consecutivehoursandthenreceives16hoursoff.

Forexample,abusoperatingfrom4AMto12PMmustbeoff

between12PMand4AM.

Findtheminimum#ofbussestoprovidetherequiredservice.

Page 9: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IntegerProgramming:

BusScheduling:

Howdoyoudefineyourdecisionvariableshere?

a) xi:#ofbussesoperatinginperiodi,i=1,2,…,6

or

b)xi:#ofbussesstartingtooperateinperiodi,i=1,2,…,6

Periods 1 2 3 4 5 6

Hours 0-4AM 4-8 AM 8AM– 12 PM 12- 4PM 4 – 8PM 8PM-0AM

Min. #ofbusesrequired

4 8 10 7 12 4

Page 10: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IntegerProgramming:Thealternative“b”makesmodelingofthisproblemmucheasier.Itisnotpossibletokeeptrackofthetotalnumberofbussesunderalternative“a”.(WHY?)Themodelisasfollows:

Page 11: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IntegerProgramming:Thealternative“b”makesmodelingofthisproblemmucheasier.Itisnotpossibletokeeptrackofthetotalnumberofbussesunderalternative“a”.(WHY?)Themodelisasfollows:

, . . . i = , x x + x x + x x + x x + x x + x x + xx

+ x + x + x + xxx

ii 61 integer, 041271084

s.t. + min

65

54

43

32

21

61

654321

³³³³³³³

Page 12: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

IntegerProgramming:

Notethateachdecisionvariablerepresentsthenumberofbusses.

Clearly,itdoesnotmakesensetotalkabout3.5bussesbecause

bussesarenotdivisible.Hence,weshouldimposetheadditional

conditionthateachofx1,...,x6 canonlytakeintegervalues.

Ifsomeorallofthevariablesarerestrictedtobeintegervalued,we

callitanintegerprogram(IP).ThislastexampleishenceanIP

problem.

Page 13: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

WorkScheduling:BurgerQueenwouldliketodeterminethemin#ofkitchenemployees.Eachemployeeworkssixdaysaweekandtakestheseventhdayoff.Days Mon Tue Wed Thu Fri Sat Sun

Min. #ofworkers

8 6 7 6 9 11 9

Howdoyouformulatethisproblem?

Theobjectivefunction?

Theconstraints?

Page 14: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

WorkScheduling:BurgerQueenwouldliketodeterminethemin#ofkitchenemployees.Eachemployeeworkssixdaysaweekandtakestheseventhdayoff.Days Mon Tue Wed Thu Fri Sat Sun

Min. #ofworkers

8 6 7 6 9 11 9

xi :#ofworkerswhoarenotworking ondayi,i =1,...,7(1:Mon,7:Sun)

Page 15: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

WorkScheduling:

DecisionVariables:

IPModel:

Page 16: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheAssignmentProblem:

• Therearen peopleandnjobstocarryout.

• Eachpersonisassignedtocarryoutexactlyonejob.

• Ifpersoni isassignedtojobj,thenthecostiscij .

Findanassignmentofnpeopleton jobswithminimumtotalcost.

P1

P2

Pn

J1

J2

Jn

Page 17: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheAssignmentProblem:

P1

P2

Pn

J1

J2

Jn

njni

jixij

,,2,1 ; ,,2,1

otherwise ,0

job toassigned is person ,1

!! ==

îíì

=

SuchvariablesarecalledBINARYVARIABLESandoffergreatflexibilityinmodeling.TheyareidealforYES/NOdecisions.

Sohowistheproblemformulated?

Page 18: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheAssignmentProblem:Theproblemisformulatedasfollows:

job) oneexactly toassigned is (person 1 , 1 n

1ji,...,nix

s.t.

ij ==å=

ThisisstillanexampleofanIPproblemsincexij canonlytakeoneofthetwointegervalues0and1.

min n

1i

n

1j xc ijijåå

= =

n ... 1,j ...n; 1,i {0,1}, x

person) oneexactly toassigned is (job 1 , 1

ij

n

1i

==Î

==å=

j,...,njxij

Page 19: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

The0-1KnapsackProblem

Youaregoingonatrip.YourSuitcasehasacapacityofbkg’s.• Youhaven differentitemsthatyoucanpackintoyoursuitcase1,...,n.

• Itemi hasaweightofaiandgivesyouautilityofci.

Howshouldyoupackyoursuitcasetomaximizetotalutility?

Page 20: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

The0-1KnapsackProblem

DecisionVariables:

IPModel:

Page 21: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

21

WorkforceSchedulingMonthlydemandforashoecompany

• Apairofshoesrequires4hoursoflaborand$5worthofrawmaterials

• 50pairsofshoesinstock• Monthlyinventorycostischargedforshoesinstockattheendof

eachmonthat$30/pair• Currently3workersareavailable• Salary$1500/month• Eachworkerworks160hours/month• Hiringaworkercosts$1600• Firingaworkercosts$2000

Month

1 2 3 4

Demand 300 500 100 100

Page 22: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

22

WorkforceSchedulingMonthlydemandforashoecompany

• Apairofshoesrequires4hoursoflaborand$5worthofrawmaterials

• 50pairsofshoesinstock• Monthlyinventorycostischargedforshoesinstockattheendof

eachmonthat$30/pair• Currently3workersareavailable How to meet demand with • Salary$1500/monthminimum total cost?• Eachworkerworks160hours/month• Hiringaworkercosts$1600• Firingaworkercosts$2000

Month

1 2 3 4

Demand 300 500 100 100

Page 23: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

Decision Variables:

LP Model:

23

IPModelForWorkforceScheduling

Page 24: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:Apapercompanymanufacturesandsellsrollsofpaperoffixedwidthin5standardlengths:5,8,12,15and17m.Demandforeachsizeisgivenbelow.Itproduces25mlengthrollsandcutsordersfromitsstockofthissize.Whatisthemin#ofrollstobeusedtomeetthetotaldemand?

Length(meters)

5 8 12 15 17

Demand 40 35 30 25 20

Page 25: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:

First,identifythecuttingpatterns:

17 8

15 8

17 5

15 5 5

12 12

12 8 5

12 55

8 88

8 58

8 55 5

5 5 5 5 5

1

2

3

4

5

6

7

8

9

10

11

Page 26: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:Thenhowdoyoudefinethedecisionvariable?

xj :#ofrollscutaccordingtopatternj.

Page 27: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:Thenhowdoyoudefinethedecisionvariable?

xj :#ofrollscutaccordingtopatternj.

Whatabouttheconstraints?i.e.Howdoyouwritetheconstraintforthedemandof12mrollsofpaper?

Welookatthepatternsthatcontain12mpieces,andthenwritetheconstraintbasedonxj.

Length(meters)

5 8 12 15 17

Demand 40 35 30 25 20

Page 28: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:

Thecuttingpatterns:

17 8

15 8

17 5

15 5 5

12 12

12 8 5

12 55

8 88

8 58

8 55 5

5 5 5 5 5

1

2

3

4

5

6

7

8

9

10

11

Page 29: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:

Thecuttingpatterns:

17 8

15 8

17 5

15 5 5

12 12

12 8 5

12 55

8 88

8 58

8 55 5

5 5 5 5 5

1

2

3

4

5

6

7

8

9

10

11

5 6 72 30x x x+ + ³Whydowehave“≥”sign?

Page 30: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:Thenhowdoyoudefinethedecisionvariable?

xj :#ofrollscutaccordingtopatternj.

Whatabouttheconstraints?i.e.Whataboutdemandfor5m?

Length(meters)

5 8 12 15 17

Demand 40 35 30 25 20

Page 31: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:

Thecuttingpatterns:

17 8

15 8

17 5

15 5 5

12 12

12 8 5

12 55

8 88

8 58

8 55 5

5 5 5 5 5

1

2

3

4

5

6

7

8

9

10

11

Page 32: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:

Thecuttingpatterns:

17 8

15 8

17 5

15 5 5

12 12

12 8 5

12 55

8 88

8 58

8 55 5

5 5 5 5 5

1

2

3

4

5

6

7

8

9

10

11

2 4 6 7 9 10 112 2 3 5 40x x x x x x x+ + + + + + ³

Page 33: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheCuttingStockProblem:

Theproblemisformulatedasfollows:

11

1

2 4 6 7 9 10 11

1 3 6 8 9 10

5 6 7

3 4

1 2

min

2 2 3 5 40 + 3 2 35

2 30 25

20 0 1 ...,11, integer.

jj

j j

x

s.t. x x x x x x x x x + x + x + x + x x + x + x x x

x + x x , j = , x

=

+ + + + + + ³

³

³

+ ³

³³

å

Page 34: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Amanagershouldchoosefromamong10differentprojects:

pj :profitifweinvestinprojectj,j=1,...,10cj :costofprojectj,j=1,...,10q:totalbudgetavailable

Therearealsosomeadditionalrequirements:i. Projects3and4cannotbechosentogetherii. Exactly3projectsaretobeselectediii. Ifproject2isselected,thensoisproject1iv. Ifproject1isselected,thenproject3shouldnotbeselectedv. Eitherproject1orproject2ischosen,butnotbothvi. Eitherbothprojects1and5arechosenorneitherarechosenvii. Atleasttwoandatmostfourprojectsshouldbechosenfromtheset{1,2,7,8,

9,10}viii. Neitherproject5nor6canbechosenunlesseither3or4ischosenix. Atleasttwooftheinvestments1,2,3arechosen,oratmostthreeofthe

investments4,5,6,7,8arechosen.x. Ifboth1and2arechosen,thenatleastoneof9and10shouldalsobechosen.

Page 35: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Undertheserequirements,theobjectiveistomaximizetheProfit.

DecisionVariables

10 ,...,1

otherwise ,0

chosen is project if ,1

=îíì

=

j

jx j

Page 36: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Objectivefunctionis:

å=

10

1jp max jj x

Page 37: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Objectivefunctionis:

Firstthebudgetconstraint:

å=

10

1jp max jj x

Page 38: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Objectivefunctionis:

Firstthebudgetconstraint:

å=

10

1jp max jj x

qc 10

1j£å

=jj x

Page 39: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Objectivefunctionis:

Firstthebudgetconstraint:

å=

10

1jp max jj x

qc 10

1j£å

=jj x

i.Projects3and4cannotbechosentogether:

Page 40: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Objectivefunctionis:

Firstthebudgetconstraint:

å=

10

1jp max jj x

qc 10

1j£å

=jj x

i.Projects3and4cannotbechosentogether:

143 £+ xx

Page 41: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

iiExactly3projectsaretobechosen:

310987654321 =+++++++++ xxxxxxxxxx

iii.Ifproject2ischosenthensoisproject1:

12 xx £

Page 42: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

ivIfproject1isselected,thenproject3shouldnotbeselected

v.Eitherproject1orproject2ischosen,butnotboth

31 1 xx -£

121 =+ xx

Page 43: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

vi.Eitherbothprojects1and5arechosenorneitherarechosen

0or 5151 =-= xxxx

vii.Atleasttwoandatmostfourprojectsshouldbechosenfromtheset{1,2,7,8,9,10}:

4

2

1098721

1098721

£+++++

³+++++

xxxxxx

xxxxxx

Page 44: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

viii.Neitherproject5nor6canbechosenunlesseither3or4ischosen:

Equivalently, 0 then 0 If 6543 ===+ xxxx

436

435

xxxxxx

+£+£

Anotherpossibility,

)(2 4365 xxxx +£+

Page 45: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

ix.Atleasttwooftheinvestments1,2,3arechosen,oratmostthreeoftheinvestments4,5,6,7,8arechosen:

Itismoredifficulttoexpressthisrequirementinmathematicaltermsdueto“or”!

( ) ( )II I 3or 2 87654321 £++++³++ xxxxxxxx

Sowewanttoensurethatatleastoneof(I)and(II)issatisfied.

Page 46: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

Thefollowingsituationcommonlyoccursinmathematicalprogrammingproblems.Wearegiventwoconstraintsoftheform,

( ) ( )( ) ( )

1 2

1 2

, ,.... 0 I

, ,.... 0 IIn

n

f x x x

g x x x

£

£

Either-OrConstraints

Page 47: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

Thefollowingsituationcommonlyoccursinmathematicalprogrammingproblems.Wearegiventwoconstraintsoftheform,

( ) ( )( ) ( )

1 2

1 2

, ,.... 0 I

, ,.... 0 IIn

n

f x x x

g x x x

£

£

Either-OrConstraints

Wewanttomakesurethatatleastoneof(I)and(II)issatisfied.Theseareoftencalledeither-orconstraints.

Page 48: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

Thefollowingsituationcommonlyoccursinmathematicalprogrammingproblems.Wearegiventwoconstraintsoftheform,

( ) ( )( ) ( )

1 2

1 2

, ,.... 0 I

, ,.... 0 IIn

n

f x x x

g x x x

£

£

Either-OrConstraints

Wewanttomakesurethatatleastoneof(I)and(II)issatisfied.Theseareoftencalledeither-orconstraints.Addingtwonewconstraintsasbelowtotheformulationwillensurethatatleastoneof(I)or(II)issatisfied,

( ) ( )( ) ( ) ( )

{ }

1 2

1 2

, ,.... I

, ,.... 1 II

where 0,1 .

n

n

f x x x My

g x x x M y

y

¢£

¢£ -

Î

Page 49: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

M isanumberchosenlargeenoughtoensurethatf(x1,x2,...,xn)≤Mandg(x1,x2,...,xn)≤Maresatisfiedforallvaluesofx1,x2,...,xn thatsatisfytheotherconstraintsintheproblem.

Either-OrConstraints

Page 50: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

( ) ( )( ) ( ) ( )

{ }

1 2

1 2

, ,.... I

, ,.... 1 II

where 0,1 .

n

n

f x x x My

g x x x M y

y

¢£

¢£ -

Î

Either-OrConstraints

Page 51: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

( ) ( )( ) ( ) ( )

{ }

1 2

1 2

, ,.... I

, ,.... 1 II

where 0,1 .

n

n

f x x x My

g x x x M y

y

¢£

¢£ -

Î

a) Ify=0,then(I’)and(II’)becomes:f(x1,x2,...,xn)≤0,

andg(x1,x2,...,xn)≤M.

Hence,thismeansthat(I)mustbesatisfied,andpossibly(II)issatisfied.

Either-OrConstraints

Page 52: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

( ) ( )( ) ( ) ( )

{ }

1 2

1 2

, ,.... I

, ,.... 1 II

where 0,1 .

n

n

f x x x My

g x x x M y

y

¢£

¢£ -

Î

Either-OrConstraints

Page 53: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

( ) ( )( ) ( ) ( )

{ }

1 2

1 2

, ,.... I

, ,.... 1 II

where 0,1 .

n

n

f x x x My

g x x x M y

y

¢£

¢£ -

Î

b) Ify=1,then(I’)and(II’)becomes:f(x1,x2,...,xn)≤M,

andg(x1,x2,...,xn)≤0.

Hence,thismeansthat(II)mustbesatisfied,andpossibly(I)issatisfied.

Either-OrConstraints

Page 54: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

( ) ( )( ) ( ) ( )

{ }

1 2

1 2

, ,.... I

, ,.... 1 II

where 0,1 .

n

n

f x x x My

g x x x M y

y

¢£

¢£ -

Î

. ( ) ( )( ) ( )

1 2

1 2

, ,.... 0 I

, ,.... 0 IIn

n

f x x x

g x x x

£

£

Thereforewhethery=0ory=1,(I’)and(II’)ensurethatatleastoneof(I)and(II)issatisfied.

Either-OrConstraints

Page 55: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Now,letusreturntoourproblem:

ix.Atleasttwooftheinvestments1,2,3arechosen,oratmostthreeoftheinvestments4,5,6,7,8arechosen:

( ) ( )II I 3or 2 87654321 £++++³++ xxxxxxxx

Thisisanexampleofeither-orconstraint.Hencebydefiningthef(.)andg(.)functions,(I)and(II)becomes:

( )1 2 3 2- 0 x x x+ + £

03 87654 £+++++- xxxxx f(.)

g(.)

Page 56: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Now,letusreturntoourproblem:

ix.Atleasttwooftheinvestments1,2,3arechosen,oratmostthreeoftheinvestments4,5,6,7,8arechosen:

( ) ( )II I 3or 2 87654321 £++++³++ xxxxxxxx

Hencebydefiningabinaryvariabley,theformulationbecomes:

{0,1}y)1(3-

y )(2

87654

321

Î-£+++++

£++-yMxxxxx

MxxxWehavetofindMlargeenoughtoensurethatf(.)≤Mandg(.)≤Mforallvaluesofx1,…,xn.M=2works!

Page 57: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Now,letusreturntoourproblem:

ix.Atleasttwooftheinvestments1,2,3arechosen,oratmostthreeoftheinvestments4,5,6,7,8arechosen:

( ) ( )II I 3or 2 87654321 £++++³++ xxxxxxxx

PuttingM=2andrearrangingtheterms,wehave:

{0,1}y25

y)1(2

87654

321

Î-£++++

-³++yxxxxx

xxx

Page 58: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

x.Ifboth1and2arechosen,thenatleastoneof9and10shouldalsobechosen.

Bothprojects1and2arechosenifx1 +x2 =2.

Atleastoneofprojects9and10ischosenifx9 +x10 ≥1

12 have weHence, 10921 ³+Þ=+ xxxx

So,howtoexpressthisasalinearconstraint?

Page 59: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

Thefollowingsituationcommonlyoccursinmathematicalprogrammingproblems.Wewanttoensurethat:

Ifaconstraintf(x1,…,xn)>0issatisfied,then g(x1,…,xn)≤0mustbesatisfied;

whileifaconstraintf(x1,…,xn)>0isnotsatisfied,then g(x1,…,xn)≤0mayormaynotbesatisfied.

If-ThenConstraints

Page 60: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

Inotherwords,wewanttoensurethatf(x1,…,xn)>0implies g(x1,…,xn)≤0.

Logically,thisisequivalentto:

If-ThenConstraints

( )

( )

II 0),...,,(or

I 0),...,,(

21

21

£

£

n

n

xxxg

xxxf

Page 61: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

WhereasbeforeMisalargeenoughnumbersuchthatf(.)≤Mandg(.)≤Mholdsforallvaluesx1,…,xn.

If-ThenConstraints( )

( )

II 0),...,,(or

I 0),...,,(

21

21

£

£

n

n

xxxg

xxxf

}1,0{ where

)1(),...,,( ),...,,(

21

21

Î-£

£

zzMxxxg

Mzxxxf

n

n

Now,theseareeither-ortypeconstraintsandwecanhandlethemasbeforebydefiningabinaryvariable,sayz:

Page 62: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Now,letusreturntoourproblem:

x.Ifboth1and2arechosen,thenatleastoneof9and10shouldalsobechosen.

12 10921 ³+Þ=+ xxxx

Weneedtodefinef(.)>0andg(.)≤0 constraints:

f(.) g(.)

1 1 10921 ³+Þ>+ xxxx

0)(1 01 10921 £+-Þ>-+ xxxxlyequivalent

Page 63: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

x.Ifboth1and2arechosen,thenatleastoneof9and10shouldalsobechosen.

12 10921 ³+Þ=+ xxxx

0)(1 01 10921 £+-Þ>-+ xxxxf(.) g(.)

Nowconvertingtoeither-or,wehave:

(II) 0)(1r

(I) 01

109

21

£+-

£-+

xxo

xx

Page 64: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

Tolinearizetheaboveconstraints,defineabinaryvariable,sayzandalargeenoughvalueM:

(II) 0)(1r

(I) 01

109

21

£+-

£-+

xxo

xx

M=1worksandafterrearrangingwehave: }1,0{

)1(M)(1 1

109

21

Î-£+-

£-+

zzxx

Mzxx

}1,0{

1

109

21

γ++£+

zzxxzxx

Page 65: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelection

x.Ifboth1and2arechosen,thenatleastoneof9and10shouldalsobechosen.

}1,0{

1

109

21

γ++£+

zzxxzxx

Page 66: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelectionFinallyourintegerprogrammingmodelwithlinear

constraintsbecomes:

å=

10

1jp max jj x

qc 10

1j£å

=jj x

(i) 143 £+ xx(ii) 310987654321 =+++++++++ xxxxxxxxxx

(iii) 12 xx £

(iv) 1 31 xx -£

(vi) 021 =- xx

(v) 121 =+ xx

Page 67: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ProjectSelectionModelcont.

(vii) 4

2

1098721

1098721

þýü

£+++++³+++++

xxxxxxxxxxxx

(viii) 436

435

þýü

+£+£xxxxxx

(ix) 25

y)1(2

87654

321

þýü

-£++++-³++

yxxxxxxxx

(x)

1

109

21

þýü

³++£+zxxzxx

{0,1}zy, {0,1},...,, 1021

ÎÎxxx

Page 68: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ModelingFixedCosts• Asetofpotential warehouses:1,...,m• Asetofclients:1,...,n

• Ifwarehousei isused,thenthereisafixedcostoffi,i =1,…,m

• cij :unitcostoftransportationfromwarehousei toclientj,

i =1,...,m;j =1,...,n

• ai :capacityofwarehousei intermsof#ofunits,i =1,…,m

• dj :#ofunitsdemandedbyclientj,j=1,…,n

Note:Morethanonewarehousecansupplytheclient.

Page 69: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ModelingFixedCostsHowtoformulatethemathematicalmodelinordertominimizetotalfixedcostsandtransportationcostswhilemeetingthedemandandcapacityconstraints?DecisionVariables:

IPModel:

Page 70: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheSetCoveringProblemYouwishtodecidewheretolocatehospitalsinacity.Supposethatthereare5differenttownsinthecity.

Town

PotentialLocation

1 2 3 4 5

1 10 15 20 10 16

2 15 10 8 14 12

3 8 6 12 15 10

4 12 17 7 9 10

TravelTime

Traveltimebetweeneachtownandthenearesthospitalshouldnotbemorethan10minutes.Whatistheminimumnumberofhospitals?

Page 71: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TheSetCoveringProblem

DecisionVariables:

IPModel:

Page 72: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

LocationProblems(Cover,Center,Median)Ankaramunicipalityisprovidingserviceto6regions.Thetraveltimes(inminutes)betweentheseregions,saytij valuesare:

R1 R2 R3 R4 R5 R6

R1 0 10 20 30 30 20

R2 10 0 25 35 20 10

R3 20 25 0 15 30 20

R4 30 35 15 0 15 25

R5 30 20 30 15 0 14

R6 20 10 20 25 14 0

Page 73: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

LocationProblems(Cover,Center,Median)a) Cover:Themunicipalitywantstobuildfirestationsinsomeoftheseregions.Findtheminimumnumberoffirestationsrequiredifthemunicipalitywantstoensurethatthereisafirestationwithin15minutedrivetimefromeachregion.(Similarto??)

DecisionVariables:

IPModel:

Page 74: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

LocationProblems(Cover,Center,Median)b)Median:Themunicipalitynowwantstobuild2postoffices.Thereisgoingtobeabackandforthtripeachdayfromeachpostofficetoeachoneoftheregionsassignedtothispostoffice.Formulateamodelwhichwillminimizethetotaltriptime.DecisionVariables:

IPModel:

Page 75: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

LocationProblems(Cover,Center,Median)c)Whatifadditionaltopart(b),youhavetherestrictionthatapostofficecannotprovideservicetomorethan4regionsincludingitself?Addthefollowingconstrainttoabovemodel:

Page 76: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

LocationProblems(Cover,Center,Median)d)Center:Themunicipalitywantstobuild2firestationssothatthetimetoreachthefarthestregioniskeptatminimum.DecisionVariables:

IPModel:

Page 77: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

LocationProblems(Cover,Center,Median)e)Considerthemedianprobleminpart(b).Assumethatinadditiontothebackandforthtripsbetweenthepostofficesandtheassignedregions,therewillbeatripbetweenthetwopostoffices.Themunicipalitywantstolocatetheofficesinsuchawaythatthetotaltriptimeisminimized.DecisionVariables:

IPModel:

Page 78: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TravelingSalesmanProblem(TSP):Asalespersonlivesincity1.Hehastovisiteachofthecities2,…,nexactlyonceandreturnhome.

Letcij bethetraveltimefromcityi tocityj ,i =1,...,n;j=1,...,n.

Whatistheorderinwhichsheshouldmakehertourtofinishasquicklyaspossible?Whatshouldbethedecisionvariableshere?

Page 79: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TravelingSalesmanProblem(TSP):Asalespersonlivesincity1.Hehastovisiteachofthecities2,…,nexactlyonceandreturnhome.

Letcij bethetraveltimefromcityi tocityj ,i =1,...,n;j=1,...,n.

Whatistheorderinwhichsheshouldmakehertourtofinishasquicklyaspossible?Whatshouldbethedecisionvariableshere?

1, if he goes directly from city to city 0, otherwise

1,2, , ; 1,2, ,

ij

i jx

i n j n

ì= íî= =K K

Page 80: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TravelingSalesmanProblem(TSP):

{ }

1 1

1

1

min

. .

1, 1,...,

1, 1,...,

0, 1,..., 0,1 , , 1,...,

n n

ij iji j

n

ijj

n

iji

ii

ij

c x

s t

x i n

x j n

x i nx i j n

= =

=

=

= =

= =

= =

Î " =

åå

å

å

Sinceeachcityhastobevisitedonlyonce,theformulationis:

Page 81: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TravelingSalesmanProblem(TSP):

12 23 31

45 54

1, 1.x x xx x= = =

= =

Withthisformulation,afeasiblesolutionis:

Butthisisa“subtour”!Howcanweeliminate“subtours”?

Weneedtoimposetheconstraints:

1 S N, Siji S j S

xÎ Ï

³ " Í ¹Æåå

Page 82: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

TravelingSalesmanProblem(TSP):

14 15 24 25 34 35 1x x x x x x+ + + + + ³

Forexample,forn=5andS={1,2,3}thisconstraintimplies:

Thedifficultyisthatthereareatotalof2n −1suchconstraints.Andthatisalot!• Forn=100,2n −1≈1.27x1030.

Howaboutthetotalnumberofvalidtours?Thatis(n−1)!

• Forn=100,(n−1)!≈ 9.33x10155.TSPisoneofthehardestproblems.Butseveralefficientalgorithmsexistthatcanfind“good”solutions.

Page 83: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ClassExercises(Blendingproblemrevisitedwithbinaryvariables):

Acompanyproducesanimalfeedmixture.Themixcontains2activeingredientsandafillermaterial.1kgoffeedmixmustcontainaminimumquantityofeachofthefollowing4nutrients:

Theingredientshavethefollowingnutrientvaluesandcosts:

Nutrients A B C D

Requiredamount(ingrams)in1kgofmix

90 50 20 2

A B C D Cost/kg

Ingredient1(gram/kg) 100 80 40 10 $40

Ingredient2 (gram/kg) 200 150 20 N/A $60

Page 84: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ClassExercises(Blendingproblemrevisitedwithbinaryvariables):

a) Whatshouldbetheamountofactiveingredientsandfillermaterialin1kgoffeedmixinordertosatisfythenutrientrequirementsatminimumtotalcost?

DecisionVariables:

Model(LPorIP?)

Page 85: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

ClassExercises(Blendingproblemrevisitedwithbinaryvariables):b)Supposenowthatwehavethefollowingadditionallimitations

i. Ifweuseanyofingredient2,weincurafixedcostof$15(inadditiontothe$60unitcost).

ii. Itisenoughtoonlysatisfy3ofthenutritionrequirementsratherthan4.

DecisionVariables(AdditionaltothoseforParta):

Model:(LPorIP?)

Page 86: MODELING (Integer Programming Examples) · Integer Programming : Bus Scheduling: How do you define your decision variables here? a) x i: # of busses operating in period i, i=1,2,…,6

SomeCommentsonIntegerProgramming:

§ Thereareoftenmultiplewaysofmodelingthesameintegerprogram.

§ Solversforintegerprogramsareextremelysensitivetotheformulation(nottrueforLPs).

§ Notaseasytomodel.

§ Notaseasytosolve.