lecture 2: transport networks design and evaluation xpress ...martinez/pdf/fico/regions... ·...
TRANSCRIPT
1
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
Instituto Superior Técnico
REGIÕES E REDES(REGIONS AND NETWORKS)
Lecture 2: Transport networks design and evaluation
Xpress presentation - Laboratory work
Eng. Luis Martínez
2
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
OUTLINE Xpress presentation
Xpress structure Create input files for Xpress Xpress-IVE overview Xpress-IVE key features Mosel programming language key words Declare and initialize variables in Mosel Declare an objective function and constraints in Mosel Declare and run the optimization in Mosel Output the results (library “mmive”)
Xpress Laboratory work with two network design examples A minimum spanning tree problem example A Min-cost-flow problem example
3
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - XPRESS STRUCTURE
Xpress-MP is a suite of mathematical modeling and optimization tools used to solve linear, integer, quadratic, non-linear, and stochastic programming problems.
Solver engines: Xpress-Optimizer (LP, MIP, QP, MIQP, QCQP, NLP) Xpress-SLP (NLP, MINLP) Xpress-SP is a Stochastic Programming tool for solving optimization problems
involving uncertainty Xpress-Kalis is Constraint Programming software (discrete combinatorial problems)
Model building and development tools: Xpress-Mosel programming language Xpress-BCL is an object-oriented library Xpress-IVE is a complete visual development environment for Xpress-Mosel under
Windows Xpress-Application Developer (XAD) extends Xpress-Mosel with an API for
graphical user interface development
4
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - CREATE INPUT FILES FOR XPRESS
The input files are created in .dat files format These files should contain the vectors and matrices with the input
variables identified for reading from the Xpress engine.
Arcs: [(1 1) "Lisboa" "Odivelas"(2 1) "Lisboa" "Loures"(3 1) "Lisboa" "Amadora"(4 1) "Lisboa" "Oeiras"(5 1) "Lisboa" "Sintra"(6 1) "Lisboa" "Cascais"(7 1) "Lisboa" "Mafra"(8 1) "Lisboa" "Vila Franca de Xira“]
x: [("Lisboa")111461 ("Odivelas") 108843 ("Loures") 110098 ("Amadora") 105211]
flow: [0 15900 26500 26500 2385015900 0 9540 13780 1590026500 9540 0 14840 1908026500 13780 14840 0 4240023850 15900 19080 42400 0]
5
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - XPRESS-IVE OVERVIEW
Optimization processOptimization resultsMosel editor
Variables and constraints activity and output
Run and debug control
6
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - XPRESS-IVE KEY FEATURES
The code file should have the following structure: model – model name uses – libraries to be used ("mmxprs","mmive“) parameters – define parameters of the model – filename of the input data file
(DATAFILE= ……dat) end-parameters declarations – declare variables and ranges of variables of the input file end-declarations initializations from DATAFILE – initialize variables from file (insert variables
names) end-initializations declarations – declare decision variables end-declarations end-model
7
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - MOSEL PROGRAMMING LANGUAGE KEY WORDS
Key words: Variables types
string – text integer – integer number real – real number mpvar – decision variable array(range) of type of variable
forall(range) – iterator forall(range) do end-do – cycle with actions if end-if – conditional action sum – somation := – assign value; =, >=,<= – equality and inequality operators
8
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - DECLARE AND INITIALIZE VARIABLES IN MOSEL
Variables declaration and initialization: declarations
NODES: set of stringx: array(NODES) of realy: array(NODES) of realA: array(ARCS:set of integer,1..2) of stringDIST: array (ARCS) of realdemand:array(NODES,NODES) of integer
end-declarations initializations from DATAFILE
A x y demandend-initializations
Declare range
Declare input variables (range size defined by the input data file)
Variables read in the file
9
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - DECLARE AN OBJECTIVE FUNCTION AND CONSTRAINTS
Objective function declaration Cost:=sum(i in ARCS)(a*flow(i) + b*Exist(i))*DIST(i)
Constraints declaration forall(a in NODES)
Total(a):= sum(i in ARCS|A(i,1)=a) flow(i)>= sum(b in NODES) demand(a,b)
FlowT:=sum(c in ARCS) flow(c) = sum(i,j in NODES) demand(i,j) forall(c in ARCS) flow(c) is_integer forall(c in ARCS) Exist(c) is_binary
Decision variablesConstraint variable (linctr)
10
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - DECLARE AND RUN THE OPTIMIZATION IN MOSEL
After the declaration of the objective function and all the constraints we need to define the optimization method that will apply (minimization, maximization) minimize (Cost) maximize (utility)
After the definition of the optimization method (if we don’t define any output results – text or graphical), we need to close the model with the key word end-model
Having all the complete code needed we can now run the model in the Run button.
Optimize the identified constraint variable
11
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS PRESENTATION - OUTPUT THE RESULTS
Write output results in text: getsol(mpvar) – get the solution values of the variable getobjval – get final value of the objective function writeln(string) – write in a string line write(string) – write a string strfmt(number) – write as string
Draw graphs: CnctGraph:= IVEaddplot("Road", IVE_YELLOW) TermGraph:= IVEaddplot("Cities", IVE_GREEN) IVEdrawpoint(TermGraph, x(i), y(i)) IVEdrawline(CnctGraph, x(A(i)), y(A(i)), x(A(j)), y(A(j))) IVEdrawlabel(CnctGraph, (x(A(i))+x(A(j)))/2, (y(A(i))+y(A(j)))/2,
string(getsol(flow(a,j))))
12
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS LABORATORY - A MINIMUM SPANNING TREE PROBLEM EXAMPLE (I)
Goal: Design a network that connects all the nodes of the graph at minimum cost Decision Variables:X: array (NODES, NODES) – binaryLevel: array (NODES) - integer
Objective function: Constraints:Number of connections:
Avoid Subcycle:
Direct all connections towards the root:
∑=
⋅Nodes
jiijLength
1,α
1/
1,−=∑
<>
=
NxjiNodes
jiij
ijijji xNNlevellevel ×+−+≥∀ 1,
11/
1=∀ ∑
<>
=
jN
iijj x
Road length: 2333.06Connections: A Coruña-Pontevedra Lugo-A Coruña Asturias-Lugo Cantabria-León Vizcaya-Cantabria Guipúzcoa-Vizcaya León-Asturias Burgos-Vizcaya Navarra-Guipúzcoa Madrid-Salamanca Barcelona-Zaragoza Valencia-Zaragoza Sevilla-Badajoz Salamanca-León Zaragoza-Navarra Badajoz-Salamanca
Spain Network Example
13
REG
ION
S AN
D N
ETW
OR
KS
Tran
spor
t net
wor
ks d
esig
n an
d ev
alua
tion
Instituto Superior Técnico / MPOT and MUOT – Regions and Networks 2011/2012
XPRESS LABORATORY - A MIN-COST-FLOW MULTI-TERMINAL PROBLEM EXAMPLE (I)
Goal: Assign demand flow the an existing network from a several sources to a several sink nodes at minimum cost considering capacity constraints on the links of the graph
Decision Variables:Flow: array (ARCS,ODpairs) – integer
Objective function:
Constraints:Total source flow:
Node equilibrium:
Capacity constraint:
Positive flow:
ioMaximumRatCapacityFlow a
ODPairs
iaiarcs ⋅≤∀ ∑
=1
0, ≥∀ ajjODPairsarcs Flow
∑=
=
≥∀ji OOArcs
ijijODPairsj DemandFlow
/
1,
∑∑=
=
=
=
=∀nOArcs
kjk
nDArcs
iijjODPairsnodes
ki
FlowFlow/
1,
/
1,
i
ODPairsArcs
jiij LengthFlow ⋅⋅∑
==
,
1,1α
Spain Network Example