+ All Categories
Home > Documents > Michal Koháni Departement of Transportation Networks Faculty of Management Science and Informatics...

Michal Koháni Departement of Transportation Networks Faculty of Management Science and Informatics...

Date post: 03-Jan-2016
Category:
Upload: steven-robbins
View: 213 times
Download: 0 times
Share this document with a friend
Popular Tags:
50
Michal Koháni Departement of Transportation Networks Faculty of Management Science and Informatics University of Zilina, Slovakia Høgskolen i Molde, September 17 - 21, 2012
Transcript

Michal KohániDepartement of Transportation Networks

Faculty of Management Science and InformaticsUniversity of Zilina, Slovakia

Høgskolen i Molde, September 17 - 21, 2012

Exam on Friday afternoon – at 1 PM in A076

Solving of simple service system problem ◦ Analyze the problem◦ Construction of mathematical model of the problem◦ Solve the model using IP solver Xpress

Final grade is PASS or FAIL

Consultation before the exam on Friday morning at 10 AM in A076

2

Universal tool for solving various MP problems◦ Linear programming◦ Integer programming◦ Quadratic programming◦ Heuristics

Uses the high-level language MOSEL Libraries for embedding

◦ Mosel libraries – solving procedures, …◦ Connection between XPRESS Ive and other programming

languages (C, C++, C#, Java, Visual Basic)

www.fico.com

3

4

Getting started with XPRESS, release 7

is an advanced modeling and solving language and environment, where optimization problems can be specified and solved with the utmost precision and clarity

enables you to gather the problem data from text files and a range of popular spreadsheets and databases, and gives you access to a variety of solvers, which can find optimal or near-optimal solutions to your model

Some features: easy syntax, supports dynamic objects, …

5

Maximum number of constraints (rows): 400 Maximum number of variables (columns): 800 Maximum number of matrix coefficients

(elements): 5000 Maximum number of binary and integer

variables, etc (global elements): 400

6

7

Start > Programs > Xpress > Xpress IVE

8

9

10

11

12

Let us consider two producers (bakery) (B1,B2 ) and four customers (C1, C2, C3, C4). Bakery B1 can produce max.800 pcs of bread per day, bakery B2 can produce max. 600 pcs of bread per day. Customers need 150, 250, 350 and 450 pcs of bread per day. Transportation costs for transport of one bread from bakery to customer are in the table. Find the cheapest delivery plan.

13

14

Decision variable: xij

How many pcs. of bread we will transport from bakery i to customer jConstraints:- Each bakery has limits for producing bread- Each customer must get enough of bread

15

4..1,2..1,

450

350

250

150

600

800

3576542min

0

2414

2313

2212

2111

24232221

14131211

2423222114131211

jiZx

xx

xx

xx

xx

xxxx

xxxx

tosubject

xxxxxxxx

ij

Name of the model & options Parameters Declarations (decision variables,

arrays, etc.) Data input Objective function Constraints Output & results

16

model ToyExampleuses "mmxprs"

… !other sections (Text in green = Comment only)

end-model

17

declarations x11,x12,x13,x14,x21,x22,x23,x24 : mpvarend-declarationsx11 is_integerx12 is_integerx13 is_integerx14 is_integerx21 is_integerx22 is_integerx23 is_integerx24 is_integer

18

! Objective function

Cost:=2*x11+4*x12+5*x13+6*x24+7*x21+5*x22+3*x23+x24

! constraints

x11+x12+x13+x14<=800

x21+x22+x23+x24<=600

x11+x21>=150

x12+x22>=250

x13+x23>=350

x14+x24>=450

minimize(Cost) !you don’t need to declare Cost

19

! Value of objective function - getobjvalwriteln(" Total cost: ", getobjval)

! Value of decision variablewriteln(" x11 = ",getsol(x11))writeln(" x12 = ",getsol(x12))writeln(" x13 = ",getsol(x13))writeln(" x14 = ",getsol(x14))writeln(" x21 = ",getsol(x21))writeln(" x22 = ",getsol(x22))writeln(" x23 = ",getsol(x23))writeln(" x24 = ",getsol(x24))

20

21

Capacity of bakery iWe will denote it as ai

Demand of customer jWe will denote it as bj

22

4..1,2..1,

4..1,

2..1,

*min

0

2

1

4

1

2

1

4

1

jiZx

jbx

iax

tosubject

xc

ij

ji

ij

ij

ij

i jijij

4..1,2..1,

450

350

250

150

600

800

3576542min

0

2414

2313

2212

2111

24232221

14131211

2423222114131211

jiZx

xx

xx

xx

xx

xxxx

xxxx

tosubject

xxxxxxxx

ij

declarations a: array (1..2) of integer b: array (1..4) of integer c: array (1..2, 1..4) of integer x: array (1..2, 1..4) of mpvarend-declarationsforall (i in 1..2) forall (j in 1..4) x(i,j) is_integera::[800, 600]b::[150, 250, 350, 450]c::[2, 4, 5, 6, 7, 5, 3, 1]

23

! Objective function

Cost:=sum (i in 1..2, j in 1..4) c(i,j)*x(i,j)

! Constraints

forall (i in 1..2) sum (j in 1..4) x(i,j) <= a(i)

forall (j in 1..4) sum (i in 1..2) x(i,j) >= b(j)

minimize(Cost) !you don’t need to declare Cost

24

4..1,

2..1,

2

1

4

1

jbx

iax

ji

ij

ij

ij

! Value of objective function - getobjvalwriteln(" Total cost: ", getobjval)

! Value of decision variableforall (i in 1..2, j in 1..4) writeln(" x (",i, ", ",j, ") = ",getsol(x(i,j)))

25

Name of the model & options Parameters Declarations (decision variables, arrays,

etc.) Data input Objective function Constraints Output & results

26

model ModelNameoptions …uses "mmxprs"

… !other sections

end-model

For comment write “!” before the commented words

27

model ModelName!parameters section firstparametersMAXTIME=300USE_LOG=false!...

end-parameters!Rest of the model (declarations, statements, etc.)end-model

28

declarations Variable : mpvar VariableArray : array() of mpvar IntegerVariable : mpvar BinaryVariable : mpvarend-declarations

IntegerVariable is_integer !when integer variableBinaryVariable is_binary !when binary variable

29

declarations UnitCost : array(1..10) of integerend-declarations

initializations from "Filename" UnitCost;end-initializations

30

Cost:=2*x1+3*x2 !...constraintsminimize(Cost) !you don’t need to declare Cost

or

Profit:=2*x1+3*x2 !...constraintsmiximize(Profit) !you don’t need to declare Profit

31

! simple constraintX1+3*X2-5*X3<=8

! multiple constraints using loopforall(i in 1..10) Z(i)=1

! sum constraintsum(i in 1..10) X(i)<=B

! multiple sum constraints using loopforall(i in 1..5) sum (j in 1..10) X(i,j)=1

32

853 321 xxx

10,..,11 iforzi

Bxi

i

10

1

5,..,1110

1

iforxj

ij

! Value of objective function - getobjvalwriteln("Objective value: ", getobjval)

! Value of decision variablewriteln("X1 = ",getsol(X1))

! Values of decision variables in array using loopforall(i in 1..M) writeln(" Y(", i, ") = ", getsol(Y(i)))

33

34

Producer P =s

Customers

1

1

1

1

11

11

The prime cost e0 is 2000 and e1 is 1000 per km.

Handling cost gi =0 and bj=1.

P1

P2

C1 C2

C3 C4

dij P P1 P2 C1 C2 C3 C4

P 0 3 4 4 4 5 5

P1 3 0 1 1 1 2 2

P2 4 1 0 2 2 1 1

jiijsiij bgdedec )( 01

Let us consider one producer P and four customers, which are supplied each day with one item of product each. Customers can be supplied only by trucks and each truck can carry exactly one item of the product at transportation cost 2000 crowns per unit distance. But, there is a railway, which starts from P and goes near to the customers through two places, where transshipment places may be constituted (each for 6000 crown per day) . This transportation means is able to transports one item at 1000 crowns per distance unit.

35

Producer P

Customers

1

1

1

1

11

11

36

Producer P =s

Customers

1

1

1

1

11

11

The prime cost e0 is 2000 and e1 is 1000 per km.

Handling cost gi =0 and bj=1.

P1

P2

C1 C2

C3 C4

dij P P1 P2 C1 C2 C3 C4

P 0 3 4 4 4 5 5

P1 3 0 1 1 1 2 2

P2 4 1 0 2 2 1 1

jiijsiij bgdedec )( 01

37

Producer P (1)

Customers

1

1

1

1

11

11

(2)

(3)

C1 C2

C3 C4

dij (1) (2) (3) C1 C2 C3 C4

(1) 0 3 4 4 4 5 5

(2) 3 0 1 1 1 2 2

(3) 4 1 0 2 2 1 1

)21( ijsiij ddc cij (1) (2) (3) C1 C2 C3 C4

(1) 8 8 10 10

(2) 5 5 7 7

(3) 8 8 6 6

38

334

112

111

342414

332313

322212

312111

342414

332313322212

31211132

:

1

1

1

1.

6710

6710858

85866

yz

yz

yz

zzz

zzz

zzz

zzzSt

zzz

zzzzzz

zzzyyMin

Producer P (1)

Customers

1

1

1

1

11

11

(2)

(3)

C1 C2

C3 C4

model ToyExampleuses "mmxprs"

… !other sections

end-model

39

declarations y1,y2,y3 : mpvar z11,z12,z13,z14,z21,z22,z23,z24 : mpvar z31,z31,z33,z34 : mpvarend-declarationsy1 is_binaryy2 is_binaryy3 is_binaryz11 is_binaryz12 is_binary…z34 is_binary

40

! Objective function

Cost:=6*y2+6*y3+8*z11+5*z21+8*z31+8*z12+5*z22+8*z32+

10*z13+7*z23+6*z33+10*z14+7*z24+6*z34

! constraints

z11+z21+z31=1

z12+z22+z32=1

z13+z23+z33=1

z14+z24+z34=1

z11<=y1

z34<=y3

minimize(Cost) !you don’t need to declare Cost

41

! Value of objective function - getobjvalwriteln("Total cost: ", getobjval)

! Value of decision variablewriteln("y1 = ",getsol(y1))writeln("y2 = ",getsol(y2))writeln("y3 = ",getsol(y3))writeln("z11 = ",getsol(z11))writeln("z21 = ",getsol(z21))writeln("z31 = ",getsol(z31))…writeln("z34 = ",getsol(z34))

42

Total cost: 30

y1= 1

y2= 1

y3= 0

z11= 0

z12= 0

z13= 0

z14= 0

z21= 1

z22= 1

z23= 1

z24= 1

z31= 0

z32= 0

z33= 0

z34= 0

43

44

4,..,1,3,..,1}1,0{

3,..,1}1,0{

4,..,1,3,..,1

4,..,111

3

1

4

1

3

1

jiforz

ifory

jiforyz

jforztoSubject

zcyfTotalCostMinimize

ij

i

iij

c

iij

i jijij

iii

m:[3]n:[4]f:[0, 6, 6]c:[8, 8,10,10, 5, 5, 7, 7, 8, 8, 6, 6]

45

declarations m, n: integerend-declarations

initializations from "ToyData.txt" m nend-initializations

46

declarations I = 1..m J = 1..n y : array (I) of mpvar z : array (I,J) of mpvar f : array (I) of integer c : array (I,J) of integerend-declarations

47

initializations from "ToyData.txt" f cend-initializations

48

! Objective function

Cost:=sum(i in 1..3) f(i)*y(i) + sum(i in 1..3,j in 1..4)

c(i,j)*z(i,j)

! Constraints

forall (j in 1..4) sum(i in 1..3) z(i,j)=1

forall (i in 1..3, j in 1..4) z(i,j)<=y(i)

minimize(Cost) !you don’t need to declare Cost

49

! Value of objective functionwriteln("Total cost: ", getobjval)

! Values of decision variableforall(i in 1..3) writeln("y(",i, ")= ",getsol(y(i)))

forall(i in 1..3, j in 1..4) writeln("z(",i, ", ",j, ")= ",getsol(z(i,j)))

50


Recommended