Matrix Modelling Alan M Frisch and Ian Miguel

  • Slides: 28
Download presentation
Matrix Modelling Alan M. Frisch and Ian Miguel (York) Brahim Hnich, Zeynep Kiziltan (Uppsala)

Matrix Modelling Alan M. Frisch and Ian Miguel (York) Brahim Hnich, Zeynep Kiziltan (Uppsala) Toby Walsh (Cork)

What is matrix modelling? w Constraint programs with one or more matrix of decision

What is matrix modelling? w Constraint programs with one or more matrix of decision vars w Common patterns in such models n Extend modelling languages & solvers to exploit them

Obvious matrix models w Often the problem has a matrix in the specification w

Obvious matrix models w Often the problem has a matrix in the specification w Many timetabling and scheduling problems n Mike Trick schedules the College baseball league using a matrix model!

Sports scheduling. Regin’s Round Robin Tournament model Week 1 Week 2 Week 3 Week

Sports scheduling. Regin’s Round Robin Tournament model Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Period 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3

Matrix modelling w Matrix models are very common in other applications n Even if

Matrix modelling w Matrix models are very common in other applications n Even if the matrix is not so obvious in the problem specification

Example: warehouse location w Supply chain management w How many warehouses do we build

Example: warehouse location w Supply chain management w How many warehouses do we build and where do we build them? n n One in the middle of the US One on each coast … w Problem (and solution) taken from OPL manual

Matrix model: variables Warehouse Supply Store 0. . 1 0. . 1 0. .

Matrix model: variables Warehouse Supply Store 0. . 1 0. . 1 0. . 1 Warehouse Open 0. . 1

Matrix model: constraints Warehouse Supply § Each store has a warehouse: row sum Supply=1

Matrix model: constraints Warehouse Supply § Each store has a warehouse: row sum Supply=1 § Warehouse capacity: column sum Supply <= ci § Channelling constraints: Supply[i, j]=1 implies Open[i]=1 § Optimization variable: Cost = matrix sum Supply[i, j]*distcost[i, j] + opencost * row sum Open Store 0. . 1 0. . 1 0. . 1 Warehouse Open 0. . 1

Matrix model: spot the difference! Warehouse Supply Store 0. . 1 0. . 1

Matrix model: spot the difference! Warehouse Supply Store 0. . 1 0. . 1 <c 2 … 0. . 1 Open 0. . 1 =1 =1 …

Matrix model: spot the difference! Periods Sched Course 0. . 1 0. . 1

Matrix model: spot the difference! Periods Sched Course 0. . 1 0. . 1 l< <d … 0. . 1 Load 0. . l 0. . 1 =1 =1 …

Balance academic curriculum problem w Very similar matrix model n n Channelling now to

Balance academic curriculum problem w Very similar matrix model n n Channelling now to weighted sum not 0/1 var Optimization var changes w Matrix modelling n n Exploiting these patterns Provide high level primitives l l To state such problems compactly To reason effectively

Diversity of matrix models w Combinatorial problems n BIBDs, magic squares, projective planes, …

Diversity of matrix models w Combinatorial problems n BIBDs, magic squares, projective planes, … w Design n Rack configuration, template and slab design, … w Scheduling n Classroom, social golfer, … w Assignment n Warehouse location, progressive party, …

Why matrix model? w Ease of problem statement n Side constraints, variable indexing, …

Why matrix model? w Ease of problem statement n Side constraints, variable indexing, … w Improved constraint propagation n Symmetry breaking, indistinguishable values, linear models, … Suggests two lines of attack 1. Matrix operations should become first class objects in constraint programming languages. 2. MATLAB should be extended so it is a constraint modelling language

Common constraint types w Row or column sum w Weighted row/column sum w Single

Common constraint types w Row or column sum w Weighted row/column sum w Single non-zero entry w Matrix sum w Scalar product w Channelling w Ordering rows/matrices This pretty much describes all the examples! These constraints should be provided as language primitives? Efficient and powerful propagators developed?

Ease of problem statement w Steel mill slab design w Nasty “colour” constraint n

Ease of problem statement w Steel mill slab design w Nasty “colour” constraint n Stops it being simple knapsack problem w Channel into matrix model n Colour constraint easily and efficiently stated

Steel mill slab design • 3 possible slab sizes (1, 3 or 4), 9

Steel mill slab design • 3 possible slab sizes (1, 3 or 4), 9 orders • 5 colours, but only 2 allowed on any one slab 3 2 a 2 b 1 1 1 c d e f g 1 h i

Example solution 2 2 (size 4) h 1 a 3 b 1 1 (size

Example solution 2 2 (size 4) h 1 a 3 b 1 1 (size 3) e f g 1 (size 1) c 1 (size 1) d 1 (size 1) i

Matrix model for the slab design problem 3 2 oa 1 oc ob 1

Matrix model for the slab design problem 3 2 oa 1 oc ob 1 od 1 oe 1 of s 1 s 2 1 og Red oa ob oc od oe of og oh oi 2 oh Green Blue Orange 1 oi Brown s 1 1 … Col sum=1, row sum<slab size s 2 1 … Col sum=1, row sum<2

Example solution 3 2 oa 1 oc ob 1 od 1 oe 1 of

Example solution 3 2 oa 1 oc ob 1 od 1 oe 1 of 2 oh 1 og 1 oi s 1 = 4, s 2 = 3, s 3 = 3, s 4 = 3 Red Green Blue Orange Brown s 1 0 0 0 1 1 oa ob oc od oe of og oh oi s 1 0 0 0 1 1 1 s 2 1 0 0 0 0 s 2 1 1 0 0 0 s 3 0 1 0 0 0 s 4 0 0 0 1 1 1 0 0 0 s 4 0 0 1 1 0 … 0 0 0 0 0 … 0 0 0

Improved propagation w Warehouse location n n Could have used 1 -d matrix, Supply(store)=warehouse

Improved propagation w Warehouse location n n Could have used 1 -d matrix, Supply(store)=warehouse But then warehouse capacity constraint l Difficult to state w Need to sum demand from all stores such that Supply(store)=warehouse l Difficult to propagate

Improved propagation w Warehouse location n n Instead of 1 -d matrix, Supply(store)=warehouse We

Improved propagation w Warehouse location n n Instead of 1 -d matrix, Supply(store)=warehouse We used 2 -d matrix, Supply(store, warehouse)=0/1 2 -d matrix allows us to use purely linear constraints => can even use LP solver

Symmetry breaking w Often rows or columns (or both) are symmetric n n All

Symmetry breaking w Often rows or columns (or both) are symmetric n n All weeks (cols) can be permuted in a timetable All slabs (rows) of same size can be permuted w Lex order rows/cols n n Never work with children or animals Can do both if row and cols are both symmetric Efficient O(n) GAC algorithm, patent pending

Symmetry-breaking • Lexicographically ordering rows breaks all row symmetry • Lexicographically ordering cols breaks

Symmetry-breaking • Lexicographically ordering rows breaks all row symmetry • Lexicographically ordering cols breaks all col symmetry

Symmetry-breaking problem • Lexicographically ordering both rows & cols does not break all row

Symmetry-breaking problem • Lexicographically ordering both rows & cols does not break all row & col symmetry: 0 1 1 0 Other techniques for dealing with symmetry like SBDS also have problems as there are n! symmetries

Indistinguishable values w Values in problem can be indistinguishable In progressive party problem: Assign(guest,

Indistinguishable values w Values in problem can be indistinguishable In progressive party problem: Assign(guest, period)=host But host boats of same size are indistinguishable n w Channel into 0/1 matrix with extra dimension Assign 3(guest, period, host)=0/1 n Value symmetry => variable symmetry

Transforming value symmetry into variable symmetry w Suppose all values are indistinguishable a c

Transforming value symmetry into variable symmetry w Suppose all values are indistinguishable a c {b, d} a b c d 1 0 0 0 1 0 1 Now the rows are indistinguishable So we are in a previously solved case!

Variable indexing w Use variables to index into arrays n E. g. channelling in

Variable indexing w Use variables to index into arrays n E. g. channelling in progressive party problem Assign 3(guest, period, Assign(guest, period))=1 compared to Assign 3(guest, period, host)=1 iff Assign(guest, period)=host n Reduces number of constraints from cubic to quadratic Hooker (and others) argue that such indexing is one of the significant advantages CP has over IP

Conclusions w Matrix models common w Common types of constraints posted on matrices n

Conclusions w Matrix models common w Common types of constraints posted on matrices n Row/column sum, symmetry breaking, channelling, … w Matrix operations should be made first-class objects in modelling languages n MATLAB, EXCEL, …