Embed
Email

patterns

Document Sample

Shared by: changcheng2
Categories
Tags
Stats
views:
7
posted:
1/15/2012
language:
pages:
67
Constraint Patterns







Toby Walsh

4C, UCC & Uppsala

Thanks

Fahiem Bacchus, David Basin, Christian

Bessiere, Alan Bundy, Xinguang Chen,

Berthe Choueiry, Elizabeth Churchill,

Dave Clarke, Simon Colton, Joe

Culberson, Carmel Domshlak, Pierre

Flener, Jeremy Frank, Alan Frisch, Ian

Gent, Fausto Giunchiglia, Ian Green,

Emmanel Hebrard, Brahim Hnich, Holger

Hoos, Zeynep Kiziltan, Ewan MacIntyre,

Suresh Manandhar, Pedro Meseguer, Ian

Miguel, Alex Nunes, Justin Pearson,

Patrick Prosser, Francesca Rossi,

Roberto Sebastiani, Paul Shaw, Dan

Sheridan, John Slaney, Barbara Smith,

Graham Steel, Kostas Stergiou, Armagan

Tarim, Neven Tomov, Peter van Beek,

Hans van Maaren, Brent Venable, Adolfo

Villafiorita, Tetsuya Yoshida

Thanks

 Funding agencies

SFI, EPSRC, SERC,

EU, Royal Society,

British Council



 Universities & Research

Institutes

4C, UCC, Uppsala Univ,

ANU, Univ. of York,

Strathclyde Univ.,

Edinburgh Univ., Univ.

of Genova, IRST, INRIA

Outline

 Design patterns

 Constraint patterns

 Matrix model

 Matrix symmetry

 Dual model

 Implied constraints

 Constraint pattern

repository

 How to help

Patterns

 Christopher Alexander

 Professor of architecture

(UC Berkeley)

 A Pattern Language

 OUP, 1977

 Patterns document the

implicit knowledge

people need when

designing buildings

Patterns

 151. Small Meeting Rooms

May be part of University (43),

Town Hall (44), Office (146) ..

 Conflict

The larger meetings are, the

less people get out of them

 Resolution

Make at least 70% of all

meeting rooms really small,

for 12 or less. Locate them in

the most public parts, evenly

scattered among the

workplaces

Design patterns

 Design Patterns:

Elements of Reusable

OO Software

 Eric Gamma, Richard

Helm, Ralph Johnson &

John Vlissides (aka Gang

of Four)

 1998 Dr Dobb’s Journal

Excellence in

Programming award

Design patterns



 A recurring solution to a

standard problem



 Patterns have a context

in which they apply



 They must balance a set

of opposing forces

Design patterns

 Mechanism for describing

best practice & good

design



 Well engineered code

exhibits many common

patterns



 Design patterns support

and encourage good

software engineering

So you want to be an

America‟s Cup helmsman?

 Learn the rules

 Port tack gives way to

starboard, ...



 Learn basic principles

 Cover tack to protect any

lead, …

 Study past races to learn

winning patterns

 Riding a gust to overtake on a

downwind leg, …

So you want to be a good

software engineer?

 Learn the rules

 Algorithms, data structures, …



 Learn basic principles

 Data abstraction, …



 Study other software engineers

to learn winning patterns

 Construct an iterator method so

elements of a compound object

can be accessed without

exposing the underlying

representation

Constraint patterns

 Record recurring patterns

in constraint models



 Deal with complex,

interacting forces



 Capture knowledge of

expert modellers





Smith in a Box

Benefits

 Help tackle modelling

“bottleneck”



 Toolkits extended to

support common

patterns

 Row & col symmetry



 Pattern automation

 Implied constraint

generation

Possible drawbacks

 Hard work

 Effort of community not one

individual





 Modelling will remain an art

 New problems often have

unique feature or combination

of features





 Patterns are not executable

 But we can automate aspects

of them

Constraint pattern

 Pattern name

 Context

 Circumstances in which pattern occurs

 Problem

 Specific problem pattern solves

 Forces

 Opposing considerations when deciding a solution

 Solution

 Example

Matrix models



 Context for many

constraint patterns



 Itself a pattern!



 Constraint program

with array(s) of

decision variables

Matrix models



 Often the problem has a

matrix in the specification



 Many timetabling and

scheduling problems

 Mike Trick schedules the

College baseball league

using a matrix model

Matrix models



 Common in other

applications

 Even if the matrix is

not so obvious in the

problem specification

Matrix models

 Warehouse location

problem

 What warehouses to build to

supply a set of stores?



 Prob034 in CSPLib

 Problem (and solution)

taken from OPL manual

Warehouse location

Supply Warehouse

0..1 0..1 0..1 0..1

0..1 0..1 0..1 0..1

Store 0..1 0..1 0..1 0..1

0..1 0..1 0..1 0..1

0..1 0..1 0..1 0..1

0..1 0..1 0..1 0..1



Warehouse

Open



0..1 0..1 0..1 0..1

Warehouse location

Supply Warehouse

 Each store has a warehouse: 0..1 0..1 0..1 0..1

sum(i,Supply[i,j])=1

0..1 0..1 0..1 0..1

 Warehouse capacity:

Store 0..1 0..1 0..1 0..1

sum(j,Supply[i,j]) eliminates all row symmetry

 Efficient & effective global constraints

 GAC(X

Matrix symmetry





 Lex order both rows and columns

 Lex order must be in same direction

 Called “double LEX”

 Extends to higher dimensions

A B C A B C

D E F D E F

G H I G H I

Consistent Consistent





A B C A B C

D E F D E F

G H I G H I

Inconsistent Inconsistent

Double LEX leaves symmetry

0 1 0 1



0 1 Swap 2 columns 1 0

Swap row 1 and 3

1 0 1 0







Surprising as lex ordering rows breaks all row symmetry, &

lex ordering cols breaks all col symmetry!

Matrix symmetry



 All symmetry can be broken

 When variables take distinct values

 Simply push largest value to a particular corner

 Order 1st row and 1st col

 0/1 variables, 1 occurs once in each row/col

 Double LEX then leaves an unique solution

Matrix symmetry pattern

 Pattern name: MatrixSymmetry

 Context

A matrix model with partial row and/or column symmetry.

 Problem

Symmetry increases the size of the search space.

 Forces

Eliminating all symmetry can be too expensive.

Elimination no symmetry can leave too much search.

 Solution

Consider posting lex ordering constraints on symmetric rows/cols

Alternatively post lex ordering in one dimension, and multiset in other

 Example

Balanced incomplete block design (prob028 in CSPLib)

Dealing with matrix symmetry

Active research area

Breaking Row and Column Symmetries in

Matrix Models, CP02

Global Constraints for Lexicographic

Orderings, CP02

Multiset Ordering Constraints, IJCAI-03

Constraints for Breaking more Row and

Column Symmetries, CP03

Generic SBDD using GAP and ECLIPSE,

CP03

Symmetry Breaking for Matrix Models

using Stabilizers, CP03

….

Dual model pattern



 Often choice for the

decision variables?

 Consider scheduling

the World Cup.

 Are Vars=games,

vals=times

 or Vars=times,

vals=games ?

Permutation problems

 |vars|=|vals|

 each var has unique val



 Many examples

 scheduling

 timetabling

 routing

 assignment problems



 Permute vars for vals

 which do we choose?

TSP problem = find permutation of cities

which makes a tour of minimum length

Dual model pattern

 Pattern name: DualModel

 Context

An informal problem specification.

 Problem

Choosing between a primal & an alternative dual viewpoint.

 Forces

Certain constraints can be easier to post on primal or dual.

Certain constraint can propagate better on primal or dual.

 Solution

Consider combined model with channelling between primal & dual variables.

 Example

Balanced academic curriculum problem (prob030 in CSPLib)

Implied constraints pattern

 Pattern name: ImpliedConstraints

 Context

A basic constraint model.

 Problem

Search going down obviously futile branches.

 Forces

Overhead of introducing additional constraints.

Applicability of the new implied constraints.

 Solution

Introduce implied constraints that prune such branches.

 Example

Golomb ruler problem (prob006 in CSPLib)

Model transformation



 Can greatly reduce the effort of solving a

problem

 Experts work hard to identify useful

transformations, e.g.

 Adding implied constraints.

 Breaking symmetry.

 Removing redundant constraints.

 Replacing constraints with their logical equivalents.

CGRASS



 Constraint GeneRation And Symmetry-breaking.

 Designed to automate the task of finding useful

model transformations.

 Based on, and extends, Bundy‟s proof planning.

 Modelling expertise captured by methods.

 Methods selectively applied to transform the problem.







[Frisch, Miguel, Walsh, 02]

Golomb ruler problem



 Place n ticks at integer points on a ruler

of length m

 All inter-tick distances unique

 Astronomy, crystallography

 Previously, implied constraints added by

hand [Smith et al „00]

Input to CGRASS



x1  x2 x1  x3 x2  x3



x1 - x2  x2 – x1 x1- x2  x2 – x3 x1- x2  x3 – x1



x1 - x3  x2 – x1 x1- x3  x3 – x1 x1- x3  x3 – x2



x2 - x1  x3 – x2 x2 - x3  x3 – x1 x2 - x3  x3 – x2

Output of CGRASS



x1 < x2 x2 < x3 x1  x3





z0 = x1 – x2 z1 = x2 – x3 z2 = x3 – x1





Alldiff(z0, z1, z2)

Constraint patterns repository



 4c.ucc.ie/patterns

 Catalog of patterns

 Mailing list

 Links

 …

 How you can help

 Submit your patterns

now!

Conclusions

 Constraint patterns

 Useful way to describe

modelling expertise

 MatrixModel,

MatrixSymmetry,

DualModel,

ImpliedConstraints, …

 How you can help

 Send me your patterns!



Related docs
Other docs by changcheng2
examples
Views: 0  |  Downloads: 0
Reg_2011_Cl_3à_pr_gir_2
Views: 0  |  Downloads: 0
odgupdates
Views: 0  |  Downloads: 0
CecilCounty
Views: 0  |  Downloads: 0
CP_Snow_lect
Views: 0  |  Downloads: 0
Magie_et_croyances
Views: 3  |  Downloads: 0
RFHSnack_bar_Schedule_2010
Views: 1  |  Downloads: 0
Porcelain _ Bakelite Lampholders
Views: 0  |  Downloads: 0
Algebra
Views: 3  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!