96
ID2204: Constraint Programming Introduction & Overview Lecture 01, 2015-03-23 Christian Schulte [email protected] Software and Computer Systems School of Information and Communication Technology KTH – Royal Institute of Technology Sweden

ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

ID2204: Constraint Programming

Introduction & Overview

Lecture 01, 2015-03-23

Christian Schulte [email protected] Software and Computer Systems School of Information and Communication Technology KTH – Royal Institute of Technology Sweden

Page 2: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Lecture Overview

What is Constraint Programming?

Sudoku is Constraint Programming

... more later

Page 3: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Sudoku

...is Constraint Programming!

Page 4: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Sudoku

Assign blank fields digits such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

Page 5: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Sudoku

Assign blank fields digits such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

Page 6: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Sudoku

Assign blank fields digits such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

Page 7: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Sudoku

Assign blank fields digits such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

Page 8: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Block Propagation

No field in block can take digits 3,6,8

8

6 3

Page 9: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Block Propagation

No field in block can take digits 3,6,8 propagate to other fields in block

Rows and columns: likewise

1,2,4,5,7,9 8 1,2,4,5,7,9

1,2,4,5,7,9 6 3

1,2,4,5,7,9 1,2,4,5,7,9 1,2,4,5,7,9

Page 10: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagation

Prune digits from fields such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

1,2,3,4,5,6,7,8,9

Page 11: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagation

Prune digits from fields such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

9 6

2

7

1

9 4

8

6 3

4

6 8

1

8

1,3,5,6,7,8

Page 12: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagation

Prune digits from fields such that: digits distinct per rows, columns, blocks

9

2 9

5 2

7 3

6

2

6 9

7

4 9

1

8

6 3

8 6

4 1

8

1,3,6,7

Page 13: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagation

Prune digits from fields such that: digits distinct per rows, columns, blocks

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

1,3,6

Page 14: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Iterated Propagation

Iterate propagation for rows, columns, blocks What if no assignment: search... later

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

Page 15: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Sudoku is Constraint Programming

Modelling: variables, values, constraints Solving: propagation, search

9

2

2 5

9

7 3

6

2

6 9

7

4 9

1

8

6 3

4

6 8

1

8

Variables: fields take values: digits maintain set of

possible values

Constraints: distinct

relation among variables

Page 16: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Constraint Programming

Variable domains finite domain integer, finite sets, multisets, intervals, ...

Constraints distinct, arithmetic, scheduling, graphs, ...

Solving propagation, branching, exploration, ...

Modelling variables, values, constraints, heuristics, symmetries, ...

Page 17: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Plan of Lecture

Introduction what is constraint programming? principles and applications

Overview course content course goal

Organizational

Page 18: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

What Is Constraint

Programming?

Page 19: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Running Example: SMM

Find distinct digits for letters, such that

SEND

+ MORE

= MONEY

Page 20: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Constraint Model for SMM

Variables: S,E,N,D,M,O,R,Y {0,…,9}

Constraints: distinct(S,E,N,D,M,O,R,Y)

1000×S+100×E+10×N+D

+ 1000×M+100×O+10×R+E

= 10000×M+1000×O+100×N+10×E+Y

S0 M0

Page 21: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Solving SMM

Find values for variables

such that all constraints satisfied

Page 22: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Finding a Solution

Compute with possible values rather than enumerating assignments

Prune inconsistent values constraint propagation

Search

branch: define search tree explore: explore search tree for solution

Page 23: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Constraint Propagation

Page 24: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Important Concepts

Constraint store Propagator Constraint propagation

Page 25: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Constraint Store

Maps variables to possible values stores basic constraints

x{3,4,5} y{3,4,5}

Page 26: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Constraint Store

Maps variables to possible values Others: finite sets, intervals, trees, ...

x{3,4,5} y{3,4,5}

finite domain constraints

Page 27: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Implement (non-basic) constraints

distinct(x1,…,xn)

x + 2*y = z

Page 28: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation

x{3,4,5} y{3,4,5}

xy y>3

Page 29: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation

x{3,4,5} y{3,4,5}

xy y>3

Page 30: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation

x{3,4,5} y{4,5}

xy y>3

Page 31: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation

x{3,4,5} y{4,5}

xy y>3

Page 32: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation

x{4,5} y{4,5}

xy y>3

Page 33: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation Disappear when done (subsumed, entailed)

no more propagation possible

x{4,5} y{4,5}

xy y>3

Page 34: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagators

Amplify store by constraint propagation Disappear when done (subsumed, entailed)

no more propagation possible

x{4,5} y{4,5}

xy

Page 35: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagation for SMM

Results in store S{9} E{4,…,7} N{5,…,8} D{2,…,8}

M{1} O{0} R{2,…,8} Y{2,…,8}

Propagation alone not sufficient! create simpler sub-problems branching

Page 36: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Constraints and Propagators

Constraints state relations among variables which value combinations satisfy constraint

Propagators implement constraints prune values in conflict with constraint

Constraint propagation drives propagators for several constraints

Page 37: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Search

Page 38: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Important Concepts

Branching Exploration Branching heuristics Best-solution search

Page 39: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Search: Branching

Create subproblems with additional information enable further constraint propagation

x{4,5} y{4,5}

xy

x{4} y{4}

xy

x{5} y{4,5}

xy

x=4 x4

Page 40: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Example Branching Strategy

Pick variable x with at least two values Pick value n from domain of x Branch with x=n and xn

Part of model

Page 41: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Search: Exploration

Iterate propagation and branching Orthogonal: branching exploration Nodes:

Unsolved Failed Succeeded

Page 42: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

SMM: Unique Solution

SEND

+ MORE

= MONEY

9567

+ 1085

= 10652

Page 43: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Heuristics for Branching

Which variable least possible values (first-fail) application dependent heuristic

Which value minimum, median, maximum x=m or xm

split with median m x<m or xm

Problem specific

Page 44: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

SMM: Solution With First-fail

SEND

+ MORE

= MONEY

9567

+ 1085

= 10652

Page 45: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Send Most Money (SMM++)

Find distinct digits for letters, such that

and MONEY maximal

SEND

+ MOST

= MONEY

Page 46: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Best Solution Search

Naïve approach: compute all solutions choose best

Branch-and-bound approach:

compute first solution add “betterness” constraint to open nodes next solution will be “better” prunes search space

Page 47: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Find first solution

Page 48: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Explore with additional constraint

Page 49: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Explore with additional constraint

Page 50: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Guarantees better solutions

Page 51: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Guarantees better solutions

Page 52: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Last solution best

Page 53: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Branch-and-bound Search

Proof of optimality

Page 54: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Modelling SMM++

Constraints and branching as before Order among solutions with constraints

so-far-best solution S,E,N,D,M,O,T,Y

current node S,E,N,D,M,O,T,Y

constraint added 10000×M+1000×O+100×N+10×E+Y

<

10000×M+1000×O+100×N+10×E+Y

Page 55: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

SMM++: Branch-and-bound

SEND

+ MOST

= MONEY

9782

+ 1094

= 10876

Page 56: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

SMM++: All Solution Search

SEND

+ MOST

= MONEY

9782

+ 1094

= 10876

Page 57: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Summary

Page 58: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Summary: Key Ideas and Principles

Modelling variables with domain constraints to state relations branching strategy solution ordering

Solving constraint propagation constraint branching search tree exploration

applications

principles

Page 59: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Widely Applicable

Timetabling Scheduling Crew rostering Resource allocation Workflow planning and optimization Gate allocation at airports Sports-event scheduling Railroad: track allocation, train allocation, schedules Automatic composition of music Genome sequencing Frequency allocation …

Page 60: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Draws on Variety of Techniques

Artificial intelligence basic idea, search, ...

Operations research scheduling, flow, ...

Algorithms graphs, matching, networks, ...

Programming languages programmability, extensionability, ...

Page 61: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Essential Aspect

Compositional middleware for combining smart algorithmic problem substructures

components (propagators) scheduling graphs flows …

plus essential extra constraints

Page 62: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Principles

Models for constraint propagation properties and guarantees

Strong constraint propagation global constraints with strong algorithmic methods mantra: search kills, search kills, search k…

Branching strategies Exploration strategies

Page 63: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

SMM: Strong Propagation

SEND

+ MORE

= MONEY

9567

+ 1085

= 10652

Page 64: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Scheduling Resources

Modelling Propagation Strong propagation

Page 65: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling Resources: Problem

Tasks duration resource

Precedence constraints

determine order among two tasks

Resource constraints

at most one task per resource [disjunctive, non-preemptive scheduling]

Page 66: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling: Bridge Example

Infamous: additional

side constraints!

Page 67: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling: Solution

Start time for each task

All constraints satisfied

Earliest completion time minimal make-span

Page 68: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling: Model

Variable for start-time of task a

start(a) Precedence constraint: a before b

start(a) + dur(a) start(b)

Page 69: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagating Precedence

start(a){0,…,7} start(b){0,…,5}

a

b

a before b

Page 70: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Propagating Precedence

start(a){0,…,7} start(b){0,…,5}

a

b

a

b

a before b

start(a){0,…,2} start(b){3,…,5}

Page 71: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling: Model

Variable for start-time of task a

start(a) Precedence constraint: a before b

start(a) + dur(a) start(b) Resource constraint: a before b

or b before a

Page 72: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling: Model

Variable for start-time of task a

start(a) Precedence constraint: a before b

start(a) + dur(a) start(b) Resource constraint: start(a) + dur(a) start(b)

or b before a

Page 73: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Scheduling: Model

Variable for start-time of task a

start(a) Precedence constraint: a before b

start(a) + dur(a) start(b) Resource constraint: start(a) + dur(a) start(b)

or start(b) + dur(b) start(a)

Page 74: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Reified Constraints

Use control variable b{0,1} c b=1 Propagate

c holds propagate b=1 c holds propagate b=0 b=1 holds propagate c

b=0 holds propagate c

Page 75: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Reified Constraints

Use control variable b{0,1} c b=1 Propagate

c holds propagate b=1 c holds propagate b=0 b=1 holds propagate c

b=0 holds propagate c

not easy!

Page 76: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Reification for Disjunction

Reify each precedence [start(a) + dur(a) start(b)] b0=1 and

[start(b) + dur(b) start(a)] b1=1

Model disjunction b0 + b1 1

Page 77: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Model Is Too Naive

Local view individual task pairs O(n2) propagators for n tasks

Global view ("global" constraints) all tasks on resource single propagator smarter algorithms possible

Page 78: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Example: Edge Finding

Find ordering among tasks (“edges”) For each subset of tasks {a}B

assume: a before B

deduce information for a and B

assume: B before a

deduce information for a and B

join computed information can be done in O(n2)

Page 79: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Summary

Modeling easy but not always efficient constraint combinators (reification) global constraints smart heuristics

More on constraint-based scheduling Baptiste, Le Pape, Nuijten. Constraint-based Scheduling, Kluwer, 2001.

Page 80: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Course Overview

Page 81: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Content Overview

As to be expected, no surprises: applications

principles

pragmatics limitations

Page 82: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Modeling with CP

Basic solving methods constraint propagation search

Typical techniques for modeling in different application areas

redundant constraints, symmetry elimination

Refining models by strong algorithmic methods

Heuristic search methods Application to hard real-size problems

Page 83: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Principles Underlying CP

Models for propagation search

and their essential properties Different levels of consistency (propagation

strength) Different constraint domains

finite domains, finite sets, ...

Page 84: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Strong Algorithmic Methods

Régin's distinct algorithm Edge-finding Integration

achieving required properties for propagation

Page 85: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Relation to Other Techniques

Integer programming Local search Discussion of merits and weaknesses Hybrid approaches

Page 86: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Goals: Learning Outcomes

explain and apply basic modeling techniques for constraint problems, including the selection of variables, constraints, and optimization criteria.

describe and apply depth-first search and branch-and-bound search for solving constraint problems.

describe and define constraint propagation, search branching, and search tree exploration

prove correctness, consistency, and completeness of propagators implementing constraints.

define and prove correctness of branching strategies. describe optimizations of constraint propagation based on

fixpoint reasoning.

Page 87: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Goals: Learning Outcomes

describe advanced modeling techniques, analyze combinatorial problems for the applicability of these techniques, and apply and combine them

techniques include: general symmetries, value and variable symmetries, symmetry breaking with constraints, symmetry breaking during search, domination constraints, redundant constraints, redundant modeling and channeling, using strong algorithmic techniques, and branching heuristics.

describe and apply Régin's algorithm for the distinct constraint as an example of strong constraint propagation

explain algorithms for the element constraint, linear constraints, and disjunctive scheduling constraints.

implement a simple propagation algorithm. describe the main strength and weaknesses of constraint

programming and how constraint programming relates to other methods (local search and integer programming)

Page 88: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

Organizational

Page 89: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Material

Lecture notes (slides) available before the lectures…

Additional material book excerpts scientific articles notes written by me Modeling and Programming with Gecode

Page 90: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

How to Pass?

Pass exam has 200 (3 hour exam) exam points 100 total points needed grading scale linear (see www)

Total pts = exam pts + bonus pts Bonus points

from assignments at most 20 points

Page 91: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Assignments

Four assignments each 5 bonus points if submitted in time one to three weeks for solving

Points only valid in this academic year!

Page 92: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Assignment Tasks

Exploration tasks small tryouts need to be done in order to do…

Submission tasks submit in time, get bonus points do them, do them submit to me by email [email protected]

Both practical and principles

Page 93: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Software: Gecode

Gecode C++ library course web: links to Gecode page

Download and install

at least version 4.4.0 (available on Monday)

Start reading “Modeling and Programming with Gecode”

at the beginning of Part M are reading instructions

Page 94: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Contacting…

Christian Schulte [email protected] other options (urgent cases), see my homepage

Page 95: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Summary

Constraint programming… …is exciting! …is fun! Understanding of principles and applications

necessary

Read the webpage https://www.kth.se/social/course/ID2204/

Page 96: ID2204: Constraint Programming Introduction & Overview · which value combinations satisfy constraint ... Send Most Money (SMM++) Find distinct digits for letters, such that . and

2015-03-23

Acknowledgments

I am grateful to Pierre Flener for helpful comments and bugreports on these slides