500 likes | 516 Views
Service System Design in Uncertain Environment Computer Seminaries, part 1. Michal Kohá ni Departement of Transportation Networks Faculty of Management Science and Informatics University of Zilina, Slovakia. Høgskolen i Molde, September 1 7 - 21, 2012. Exam & Grading.
E N D
Service System Design in Uncertain EnvironmentComputer Seminaries, part 1 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
Exam & Grading • ExamonFridayafternoon – at 1 PM in A076 • Solvingof simple service system problem • Analyzethe problem • Construction ofmathematicalmodelofthe problem • Solvethemodelusing IP solverXpress • Final grade is PASS or FAIL • Consultation before the exam on Friday morning at 10 AM in A076
Xpress IVE (basic features) • 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
Xpress IVE (basic features) Getting started with XPRESS, release 7
MOSELLanguage(basic features) • 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, …
Xpress-IVE (student restricted version) • 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
FICO Xpress-IVE Start > Programs > Xpress > Xpress IVE
Transportation ProblemToy example 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.
Transportation ProblemMathematical model Decision variable: xij How many pcs. of bread we will transport from bakery i to customer j Constraints: - Each bakery has limits for producing bread - Each customer must get enough of bread
How to write a model in Mosel Xpress-IVE • Name of the model & options • Parameters • Declarations (decision variables, arrays, etc.) • Data input • Objective function • Constraints • Output & results
Writing a model in Mosel Name of the model & options modelToyExample uses"mmxprs" … !other sections (Text in green = Comment only) end-model
Writing a model in Mosel Declarations of decision variables declarations x11,x12,x13,x14,x21,x22,x23,x24: mpvar end-declarations x11 is_integer x12 is_integer x13 is_integer x14 is_integer x21 is_integer x22 is_integer x23 is_integer x24 is_integer
Writing a model in Mosel Objective function & constraints ! 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
Writing a model in Mosel Output & results ! Value of objective function - getobjval writeln(" Total cost: ",getobjval) ! Value of decision variable writeln(" 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))
Transportation ProblemMathematical model Capacity of bakery i We will denote it as ai Demand of customer j We will denote it as bj
Writing a model in Mosel Declarations of decision variables 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 mpvar end-declarations forall (i in 1..2) forall (j in 1..4) x(i,j) is_integer a::[800, 600] b::[150, 250, 350, 450] c::[2, 4, 5, 6, 7, 5, 3, 1]
Writing a model in Mosel Objective function & constraints ! 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
Writing a model in Mosel Output & results ! Value of objective function - getobjval writeln(" Total cost: ",getobjval) ! Value of decision variable forall (i in 1..2, j in 1..4) writeln(" x (",i, ", ",j, ") = ",getsol(x(i,j)))
How to write a model in Mosel Xpress-IVE • Name of the model & options • Parameters • Declarations (decision variables, arrays, etc.) • Data input • Objective function • Constraints • Output & results
How to write a model (1) Name of the model & options modelModelName options … uses"mmxprs" … !other sections end-model For comment write “!”before the commented words
How to write a model (2) Parameters – optional section model ModelName !parameters section first parameters MAXTIME=300 USE_LOG=false !... end-parameters !Rest of the model (declarations, statements, etc.) end-model
How to write a model (3) Declarations (variables, arrays, etc.) declarations Variable :mpvar VariableArray: array() of mpvar IntegerVariable : mpvar BinaryVariable : mpvar end-declarations IntegerVariableis_integer !when integer variable BinaryVariableis_binary !when binary variable
How to write a model (4) Data input – optional section declarations UnitCost : array(1..10) of integer end-declarations initializations from "Filename" UnitCost; end-initializations
How to write a model (5) Objective function Cost:=2*x1+3*x2 !...constraints minimize(Cost) !you don’t need to declare Cost or Profit:=2*x1+3*x2 !...constraints miximize(Profit) !you don’t need to declare Profit
How to write a model (6) Constraints ! simple constraint X1+3*X2-5*X3<=8 ! multiple constraints using loop forall(iin 1..10) Z(i)=1 ! sum constraint sum(iin 1..10) X(i)<=B ! multiple sum constraints using loop forall(iin 1..5)sum (j in 1..10) X(i,j)=1
How to write a model (7) Output & results ! Value of objective function - getobjval writeln("Objective value: ",getobjval) ! Value of decision variable writeln("X1 = ",getsol(X1)) ! Values of decision variables in array using loop forall(iin 1..M) writeln(" Y(",i, ") = ",getsol(Y(i)))
Producer P =s Uncapacited Facility Location Problem Toy example • The prime cost e0is 2000 and e1 is 1000 per km. • Handling costgi=0andbj=1. 1 1 1 C1 C2 1 1 P1 1 Customers 1 1 P2 C3 C4
Producer P Uncapacited Facility Location ProblemToy example 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. 1 1 1 1 1 1 Customers 1 1
Producer P =s Uncapacited Facility Location Problem Toy example • The prime cost e0is 2000 and e1 is 1000 per km. • Handling costgi=0andbj=1. 1 1 1 C1 C2 1 1 P1 1 Customers 1 1 P2 C3 C4
Producer P (1) Uncapacited Facility Location Problem Toy example 1 1 1 C1 C2 1 1 (2) 1 Customers 1 1 C3 C4 (3)
Producer P (1) Uncapacited Facility Location Problem Toy example 1 1 1 C1 C2 1 1 (2) 1 Customers 1 1 C3 C4 (3)
Writing a model in Mosel Name of the model & options modelToyExample uses"mmxprs" … !other sections end-model
Writing a model in Mosel Declarations of decision variables declarations y1,y2,y3 :mpvar z11,z12,z13,z14,z21,z22,z23,z24: mpvar z31,z31,z33,z34 : mpvar end-declarations y1 is_binary y2is_binary y3 is_binary z11 is_binary z12 is_binary … z34 is_binary
Writing a model in Mosel Objective function & constraints ! 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
Writing a model in Mosel Output & results ! Value of objective function - getobjval writeln("Total cost: ",getobjval) ! Value of decision variable writeln("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))
Writing a model in Mosel Results 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
Writing a model in Mosel Structure of the input file “ToyData.txt”: m:[3] n:[4] f:[0, 6, 6] c:[8, 8,10,10, 5, 5, 7, 7, 8, 8, 6, 6]
Writing a model in Mosel Declarations of variables using arrays & loops declarations m, n: integer end-declarations initializations from "ToyData.txt" m n end-initializations
Writing a model in Mosel Declarations of variables using arrays & loops declarations I = 1..m J = 1..n y :array (I) ofmpvar z : array (I,J) of mpvar f :array (I) ofinteger c : array (I,J) of integer end-declarations
Writing a model in Mosel Data input initializations from "ToyData.txt" f c end-initializations
Writing a model in Mosel Objective function & constraints ! 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
Writing a model in Mosel Output & results ! Value of objective function writeln("Total cost: ",getobjval) ! Values of decision variable forall(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)))