Introduction to BCP MCF Example Laszlo Ladanyi 1 cois Margot 2 Fran - - PowerPoint PPT Presentation

introduction to bcp mcf example
SMART_READER_LITE
LIVE PREVIEW

Introduction to BCP MCF Example Laszlo Ladanyi 1 cois Margot 2 Fran - - PowerPoint PPT Presentation

Introduction to BCP MCF Example Laszlo Ladanyi 1 cois Margot 2 Fran July 18, 2006 1: IBM T.J. Watson Research Center 2: Tepper School of Business, Carnegie Mellon University BCP: Branch-Cut-Price Software for branch-and-cut-and-price


slide-1
SLIDE 1

Introduction to BCP – MCF Example

Laszlo Ladanyi1 Fran¸ cois Margot2 July 18, 2006

1: IBM T.J. Watson Research Center 2: Tepper School of Business, Carnegie Mellon University

slide-2
SLIDE 2

BCP: Branch-Cut-Price

  • Software for branch-and-cut-and-price
  • Parallel code
  • LP solver : Clp, Cplex, Xpress, . . .
  • Most flexible in COIN-OR
  • Research code (no stand-alone executable)
slide-3
SLIDE 3

BCP: Branch-Cut-Price

  • Software for branch-and-cut-and-price
  • Parallel code
  • LP solver : Clp, Cplex, Xpress, . . .
  • Most flexible in COIN-OR
  • Research code (no stand-alone executable)

BCP code split into four directories: (see coin-Bcp/Bcp/src)

  • include: all header files
  • Tree Manager (TM): Maintain the LP associated with each

node, manage cuts and variables

  • Node level operations (LP): cutting, branching, heuristics,

fixing, column generation

  • Utilities (Member): code for interface between TM and LP,

initialization

slide-4
SLIDE 4

Solver Initialization

Tree Manager Solver

  • read data
slide-5
SLIDE 5

Solver Initialization

Tree Manager Solver

  • read data
  • pack module data
slide-6
SLIDE 6

Solver Initialization

Tree Manager Solver

  • read data
  • pack module data

  • unpack module data
slide-7
SLIDE 7

Solver Initialization

Tree Manager Solver

  • read data
  • pack module data

  • unpack module data
  • setup the LP solver
slide-8
SLIDE 8

Processing a node

Tree Manager Solver

  • select node
slide-9
SLIDE 9

Processing a node

Tree Manager Solver

  • select node
  • pack node LP data
slide-10
SLIDE 10

Processing a node

Tree Manager Solver

  • select node
  • pack node LP data

  • unpack node LP data
slide-11
SLIDE 11

Processing a node

Tree Manager Solver

  • select node
  • pack node LP data

  • unpack node LP data
  • solve
  • generate cuts/vars
  • branch
  • create LP data for sons
slide-12
SLIDE 12

Processing a node

Tree Manager Solver

  • select node
  • pack node LP data

  • unpack node LP data
  • solve
  • generate cuts/vars
  • branch
  • create LP data for sons
  • pack node LP data for

sons

slide-13
SLIDE 13

Processing a node

Tree Manager Solver

  • select node
  • pack node LP data

  • unpack node LP data
  • solve
  • generate cuts/vars
  • branch
  • create LP data for sons
  • unpack node LP data

for sons ←

  • pack node LP data for

sons

slide-14
SLIDE 14

Processing a node

Tree Manager Solver

  • select node
  • pack node LP data

  • unpack node LP data
  • solve
  • generate cuts/vars
  • branch
  • create LP data for sons
  • unpack node LP data

for sons ←

  • pack node LP data for

sons

  • add sons to tree
slide-15
SLIDE 15

BCP Constraints/Variables

Types of Constraints/Variables:

  • Core : present at all nodes
  • Algorithmic : separation/generation algorithm
  • Indexed : e.g. stored in a vector
slide-16
SLIDE 16

BCP Constraints/Variables

Types of Constraints/Variables:

  • Core : present at all nodes
  • Algorithmic : separation/generation algorithm
  • Indexed : e.g. stored in a vector

Algorithmic constraints and variables are local

slide-17
SLIDE 17

BCP Constraints/Variables

Types of Constraints/Variables:

  • Core : present at all nodes
  • Algorithmic : separation/generation algorithm
  • Indexed : e.g. stored in a vector

Algorithmic constraints and variables are local Representation: Constraints are stored as ranged constraints: lb ≤ ax ≤ ub with lb = −DBL MAX or ub = DBL MAX possible

slide-18
SLIDE 18

Implementing a Column Generation Application

Member:

  • Read input
  • Implement variables

TM:

  • Set up the LP at the root node
  • display of a solution

LP:

  • Test feasibility of a solution
  • Column generation method
  • Computation of a lower bound
  • Branching decision
slide-19
SLIDE 19
  • Col. Gen. Example: Multicommodity Flow (MCF-1)
  • Directed graph G = (V , E)
  • N commodities
  • (si, ti) : source-sink pair, i = 0, . . . , N − 1
  • di : supply/demand vector for siti − flow, i = 0, . . . , N − 1
slide-20
SLIDE 20
  • Col. Gen. Example: Multicommodity Flow (MCF-1)
  • Directed graph G = (V , E)
  • N commodities
  • (si, ti) : source-sink pair, i = 0, . . . , N − 1
  • di : supply/demand vector for siti − flow, i = 0, . . . , N − 1

For each arc e ∈ E:

  • 0 : lower bound for total flow on arc
  • ue : finite upper bound for total flow on arc (0 ≤ ue)
  • we : unit cost (0 ≤ we)
slide-21
SLIDE 21

MCF: ILP Formulation

Solution:

  • f i: siti-flow with supply/demand vector di
  • i

f i

e ≤ ue for all e ∈ E

slide-22
SLIDE 22

MCF: ILP Formulation

Solution:

  • f i: siti-flow with supply/demand vector di
  • i

f i

e ≤ ue for all e ∈ E

ILP Formulation: min

  • i

wTf i

  • i

f i ≤ u (1)

  • e=(v,w)∈E

f i

e −

  • e=(w,v)∈E

f i

e = di v

∀v ∈ V , ∀i (2) 0 ≤ f i ≤ u ∀i (3) f i integral ∀i (4)

slide-23
SLIDE 23

MCF: Input data

Class MCF data (see Member/MCF data.hpp):

  • arcs : vector of struct (tail, head, lb, ub, weight)
  • commodities : vector of struct (source, sink, demand)
  • numarcs
  • numnodes
  • numcommodities
  • Setup by MCF data::readDimacsFormat()
slide-24
SLIDE 24

MCF: Input data

Class MCF data (see Member/MCF data.hpp):

  • arcs : vector of struct (tail, head, lb, ub, weight)
  • commodities : vector of struct (source, sink, demand)
  • numarcs
  • numnodes
  • numcommodities
  • Setup by MCF data::readDimacsFormat()

Parameter MCF AddDummySourceSinkArcs : Add numcommodities dummy arcs with large weight to ensure feasibility

slide-25
SLIDE 25

MCF: Master Problem

Master Problem:

  • Column : siti-flow satisfying di for some i
  • F i : matrix of all generated siti-flows (+ dummy flow)
  • λi : multiplier for generated siti-flows
slide-26
SLIDE 26

MCF: Master Problem

Master Problem:

  • Column : siti-flow satisfying di for some i
  • F i : matrix of all generated siti-flows (+ dummy flow)
  • λi : multiplier for generated siti-flows

Example: all arcs upper capacity 2, source = 0, sink = 3, d = 2. 01 02 12 13 23 03 2

slide-27
SLIDE 27

MCF: Master Problem

Master Problem:

  • Column : siti-flow satisfying di for some i
  • F i : matrix of all generated siti-flows (+ dummy flow)
  • λi : multiplier for generated siti-flows

Example: all arcs upper capacity 2, source = 0, sink = 3, d = 2. 01 1 02 1 12 1 13 23 1 03 2

slide-28
SLIDE 28

MCF: Master Problem

Master Problem:

  • Column : siti-flow satisfying di for some i
  • F i : matrix of all generated siti-flows (+ dummy flow)
  • λi : multiplier for generated siti-flows

Example: all arcs upper capacity 2, source = 0, sink = 3, d = 2. 01 1 2 02 1 12 1 2 13 23 1 2 03 2

slide-29
SLIDE 29

MCF: Master Problem

min

  • i

wTF iλi

  • i

F iλi ≤ u (5) eTλi = 1 ∀i (6) λi ≥ 0 ∀i (7) F iλi integer ∀i (8)

slide-30
SLIDE 30

MCF: Master Problem

min

  • i

wTF iλi

  • i

F iλi ≤ u (5) eTλi = 1 ∀i (6) λi ≥ 0 ∀i (7) F iλi integer ∀i (8)

  • F 0

F 1 F 2   λ0 λ1 λ2   ≤ u   1T . . . 1T . . . 1T     λ0 λ1 λ2   = 1

slide-31
SLIDE 31

MCF: Master Problem

min

  • i

wTF iλi

  • i

F iλi ≤ u (π) (5) eTλi = 1 ∀i (νi) (6) λi ≥ 0 ∀i (7) F iλi integer ∀i (8) Pricing of feasible siti-flow f : weight of flow : wTf dual activity: πTf + νi Reduced cost of flow f = wTf − πTf − νi = (wT − πT)f − νi

slide-32
SLIDE 32

Class MCF vars

MCF var:

  • int commodity : index of commodity
  • CoinPackedVector flow : positive flow on arcs
  • weight: objective coefficient

See include/MCF var.hpp, Member/MCF var.cpp

slide-33
SLIDE 33

Class MCF vars

MCF var:

  • int commodity : index of commodity
  • CoinPackedVector flow : positive flow on arcs
  • weight: objective coefficient

See include/MCF var.hpp, Member/MCF var.cpp MCF lp::vars to cols(): generate columns of the master problem for vars

slide-34
SLIDE 34

MCF: Setting the Master at the Root

Variables:

  • Dummy flow variables are algorithmic variables (λi

0 ∀ i)

  • All generated variables are algorithmic

See in TM/MCF tm.cpp: MCF tm::initialize core MCF tm::create root

slide-35
SLIDE 35

MCF: Setting the Master at the Root

Variables:

  • Dummy flow variables are algorithmic variables (λi

0 ∀ i)

  • All generated variables are algorithmic

Constraints:

  • All constraints are core constraints
  • Upper bound constraints: 0 ≤ ue ∀ e ∈ E
  • Dummy upper bound constraints: dem(i)λi

0 ≤ dem(i) ∀i

  • Convexity constraints: λi

0 = 1 ∀ i

See in TM/MCF tm.cpp: MCF tm::initialize core MCF tm::create root

slide-36
SLIDE 36

Class MCF tm: Derived from BCP tm user

Data:

  • MCF data data

Methods:

  • pack module data() : pack data needed at the node level.

Called once for each processor used as a solver.

  • initialize core() : Transmit core constraints/variables to

BCP.

  • create root : set up the problem at the root node
  • pack var algo() : pack algorithmic vars
  • unpack var algo() : unpack algorithmic vars
  • display feasible solution() : display solution
slide-37
SLIDE 37

Node operations

  • 1. Initialize new node
  • 2. Solve node LP
  • 3. Test feasibility of node LP solution
  • 4. Compute lower bound for node LP
  • 5. Fathom node (if possible)
  • 6. Perform fixing on vars
  • 7. Update row effectiveness records
  • 8. Generate cuts, Generate vars
  • 9. Generate heuristic solution
  • 10. Fathom node (if possible)
  • 11. Decide to branch, fathom, or repeat loop
  • 12. Add to node LP the cuts/vars generated, if loop is repeated
  • 13. Purge cut pool, var pool
slide-38
SLIDE 38

Class MCF LP: Derived from BCP lp user

Data:

  • OsiSolverInterface* cg lp: pointer on Osi LP solver used

for column generation

  • MCF data data: problem data
  • vector<MCF branch decision>* branch history:

branch history[i]: vector of branching decision involving commodity i (arc, lb, ub)

  • map<int,double>* flows: flows[i]: map between index
  • f arc and positive flow for commodity i in LP solution
  • BCP vec<BCP var*> gen vars: vector holding generated vars
  • bool generated vars: indicator for success in column

generation See LP/MCF lp.cpp, include/MCF lp.hpp

slide-39
SLIDE 39

Class MCF LP: Derived from BCP lp user (cont)

Methods:

  • unpack module data()
  • pack var algo(), unpack var algo()
  • initialize new search tree node() : Natural place for

initializing user defined variables of MCF lp.

  • test feasibility(): Test feasibility of current LP solution.
  • compute lower bound(): Lower bound on optimal value of

subproblem

  • generate vars in lp(): Pass new variables to BCP
  • vars to cols() : Function generating a column from the var

representation

  • select branching candidates() : Generate rules for

creating potential sons

slide-40
SLIDE 40

MCF: Computing a Lower Bound

Initially, lower bound of a node is set to the lower bound of its father

  • Try to generate a variable with negative reduced cost
  • If successful, lower bound is currently known lower bound
  • If unsuccessful, lower bound is the current LP value

See MCF lp::compute lower bound() in LP/MCF lp.cpp

slide-41
SLIDE 41

MCF: Column Generation

  • π, νi : optimal dual solution of the Master

(see MCF lp::compute lower bound in LP/MCF lp.cpp)

slide-42
SLIDE 42

MCF: Column Generation

  • π, νi : optimal dual solution of the Master

Column generation: min(wT − πT)f i − νi

  • e=(w,v)∈E

f i

e −

  • e=(w,v)∈E

f i

e = di v

∀v ∈ V (9) ℓi ≤ f i ≤ ui (10) f i integral (11) If solution is negative , then f i is the new column (see MCF lp::compute lower bound in LP/MCF lp.cpp)

slide-43
SLIDE 43

MCF: Column Generation

  • π, νi : optimal dual solution of the Master

Column generation: min(wT − πT)f i

  • e=(w,v)∈E

f i

e −

  • e=(w,v)∈E

f i

e = di v

∀v ∈ V (9) ℓi ≤ f i ≤ ui (10) f i integral (11) If solution is < νi, then f i is the new column (see MCF lp::compute lower bound in LP/MCF lp.cpp)

slide-44
SLIDE 44

MCF: Column Generation

  • π, νi : optimal dual solution of the Master

Column generation: min(wT − πT)f i

  • e=(w,v)∈E

f i

e −

  • e=(w,v)∈E

f i

e = di v

∀v ∈ V (9) ℓi ≤ f i ≤ ui (10) f i integral (11) If solution is < νi, then f i is the new column Minimum cost flow problem ⇒ Solve as an LP (see MCF lp::compute lower bound in LP/MCF lp.cpp)

slide-45
SLIDE 45

Branching

MCF lp::select branching candidates(): Called at the end of each iteration. Possible return values are:

  • BCP DoNotBranch Fathomed : fathomed without branching
  • BCP DoNotBranch : continue to work on this node
  • BCP DoBranch : Branching must be done. Must create the

candidates

slide-46
SLIDE 46

MCF: Branching

  • Solution of the Master is fractional
  • No new column is generated
slide-47
SLIDE 47

MCF: Branching

  • Solution of the Master is fractional
  • No new column is generated

⇒ Must branch Branching rule:

  • Select an arc e (not dummy) and i with F iλi = z fractional
  • First child: Use only columns where flow of i on e is > z
  • Second child: Use only columns where flow of i on e is < z
slide-48
SLIDE 48

MCF: Branching

  • Solution of the Master is fractional
  • No new column is generated

⇒ Must branch Branching rule:

  • Select an arc e (not dummy) and i with F iλi = z fractional
  • First child: Use only columns where flow of i on e is > z
  • Second child: Use only columns where flow of i on e is < z
  • Need to know ℓi

e and ui e for all i and e for col. gen.

slide-49
SLIDE 49

MCF: Branching

  • Solution of the Master is fractional
  • No new column is generated

⇒ Must branch Branching rule:

  • Select an arc e (not dummy) and i with F iλi = z fractional
  • First child: Use only columns where flow of i on e is > z
  • Second child: Use only columns where flow of i on e is < z
  • Need to know ℓi

e and ui e for all i and e for col. gen.

⇒ use branch history[i]

slide-50
SLIDE 50

Class MCF branching var

MCF branching var:

  • artificial variable used to keep branching history around
  • weight 0
  • coefficients 0
  • upper: 1, lower 0: identify child

See include/MCF var.hpp, Member/MCF var.cpp

slide-51
SLIDE 51

Class MCF branching var

MCF branching var:

  • artificial variable used to keep branching history around
  • weight 0
  • coefficients 0
  • upper: 1, lower 0: identify child

Data:

  • commodity: commodity i used in branching
  • arc index: arc e used in branching
  • lb child0, ub child0, lb child1, ub child1: bounds for

commodity i on e in the children See include/MCF var.hpp, Member/MCF var.cpp

slide-52
SLIDE 52

Branching object

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children
  • BCP vec<BCP var*> *new vars : vector for new vars
  • BCP vec<BCP cut*> *new cuts : vector for new cuts
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i

slide-53
SLIDE 53

Branching object MCF

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children
  • BCP vec<BCP var*> *new vars : vector for new vars
  • BCP vec<BCP cut*> *new cuts : vector for new cuts
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i

slide-54
SLIDE 54

Branching object MCF

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children 2
  • BCP vec<BCP var*> *new vars : vector for new vars
  • BCP vec<BCP cut*> *new cuts : vector for new cuts
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i

slide-55
SLIDE 55

Branching object MCF

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children 2
  • BCP vec<BCP var*> *new vars : vector for new vars
  • ne new MCF branching var
  • BCP vec<BCP cut*> *new cuts : vector for new cuts
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i

slide-56
SLIDE 56

Branching object MCF

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children 2
  • BCP vec<BCP var*> *new vars : vector for new vars
  • ne new MCF branching var
  • BCP vec<BCP cut*> *new cuts : vector for new cuts NULL
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i

slide-57
SLIDE 57

Branching object MCF

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children 2
  • BCP vec<BCP var*> *new vars : vector for new vars
  • ne new MCF branching var
  • BCP vec<BCP cut*> *new cuts : vector for new cuts NULL
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i [-1, 4, 7]

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i

slide-58
SLIDE 58

Branching object MCF

Create the candidates using: BCP lp branching object::BCP lp branching object() Its relevant parameters are:

  • int children : # children 2
  • BCP vec<BCP var*> *new vars : vector for new vars
  • ne new MCF branching var
  • BCP vec<BCP cut*> *new cuts : vector for new cuts NULL
  • BCP vec<int> *fvp : vector for indices of variables whose

bounds are changed Negative indices : vars from new vars, index −i − 1 corresponding to entry i [-1, 4, 7]

  • BCP vec<int> *fcp : vector for indices of cuts whose

bounds are changed. Negative indices : cuts from new cuts, index −i − 1 corresponding to entry i NULL

slide-59
SLIDE 59

Branching object (cont)

  • BCP vec<double> *fvb : vector for lower/upper bounds for

each vars in fvp, for each child

  • BCP vec<double> *fcb : vector for lower/upper bounds for

each constraint in fcp, for each child

  • 4 additional parameters (implied parts)

Pass NULL for irrelevant parameters

slide-60
SLIDE 60

Branching object (cont)MCF

  • BCP vec<double> *fvb : vector for lower/upper bounds for

each vars in fvp, for each child [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1]

  • BCP vec<double> *fcb : vector for lower/upper bounds for

each constraint in fcp, for each child

  • 4 additional parameters (implied parts)

Pass NULL for irrelevant parameters

slide-61
SLIDE 61

Branching object (cont)MCF

  • BCP vec<double> *fvb : vector for lower/upper bounds for

each vars in fvp, for each child [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1]

  • BCP vec<double> *fcb : vector for lower/upper bounds for

each constraint in fcp, for each child NULL

  • 4 additional parameters (implied parts)

Pass NULL for irrelevant parameters

slide-62
SLIDE 62

Branching object (cont)MCF

  • BCP vec<double> *fvb : vector for lower/upper bounds for

each vars in fvp, for each child [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1]

  • BCP vec<double> *fcb : vector for lower/upper bounds for

each constraint in fcp, for each child NULL

  • 4 additional parameters (implied parts)NULL

Pass NULL for irrelevant parameters

slide-63
SLIDE 63

Branching object: Forced vs. Implied

Forced changes:

  • Used during strong branching
  • Sent to the tree manager if branching object is selected
  • Used in the children if branching object is selected
slide-64
SLIDE 64

Branching object: Forced vs. Implied

Forced changes:

  • Used during strong branching
  • Sent to the tree manager if branching object is selected
  • Used in the children if branching object is selected

Implied changes:

  • Used during strong branching
  • NOT Sent to the tree manager if branching object is selected
  • NOT Used in the children if branching object is selected
slide-65
SLIDE 65

Branching object: Forced vs. Implied

Forced changes:

  • Used during strong branching
  • Sent to the tree manager if branching object is selected
  • Used in the children if branching object is selected

Implied changes:

  • Used during strong branching
  • NOT Sent to the tree manager if branching object is selected
  • NOT Used in the children if branching object is selected

Many implied changes ⇒ storing them is costly. If implied changes are used, implement them also in MCF lp:: initialize new search tree node()

slide-66
SLIDE 66

MCF: Parameter File

Predefined parameters: Class MCF par (see include/MCF par.hpp) Class BCP lp par Class BCP tm par

slide-67
SLIDE 67

MCF: Parameter File

Predefined parameters: Class MCF par (see include/MCF par.hpp) Class BCP lp par Class BCP tm par Some parameters with their default values:

  • MCF AddDummySourceSinkArcs: 1
  • MCF InputFilename: small
  • BCP VerbosityShutUp: 0
  • BCP MaxRunTime : 3600
  • BCP Granularity : 1e-8
  • BCP IntegerTolerance : 1e-5
  • BCP TreeSearchStrategy : 1

// 0: Best Bound 1: BFS 2: DFS