Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description...

433
Introduction to Constraint Programming Helmut Simonis Cork Constraint Computation Centre Computer Science Department University College Cork Ireland CP Meets CAV, Turunc, June 25th, 2012 Helmut Simonis Introduction to CP 1

Transcript of Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description...

Page 1: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Introduction to Constraint Programming

Helmut Simonis

Cork Constraint Computation CentreComputer Science Department

University College CorkIreland

CP Meets CAV, Turunc, June 25th, 2012

Helmut Simonis Introduction to CP 1

Page 2: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Licence

This work is licensed under the Creative CommonsAttribution-Noncommercial-Share Alike 3.0 Unported License.To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ orsend a letter to Creative Commons, 171 Second Street, Suite300, San Francisco, California, 94105, USA.

Helmut Simonis Introduction to CP 2

Page 3: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Acknowledgments

The author is partially supported by Science Foundation Ireland(Grant Number 05/IN/I886). This material was developed aspart of the ECLiPSe ELearning course:http://4c.ucc.ie/~hsimonis/ELearning/index.htmSupport from Cisco Systems and the Silicon Valley CommunityFoundation is gratefully acknowledged.

Helmut Simonis Introduction to CP 3

Page 4: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Objectives

Overview of Core Constraint ProgrammingThree Main Concepts

Constraint PropagationGlobal ConstraintsCustomizing Search

Based on Examples, not Formal Description

Helmut Simonis Introduction to CP 4

Page 5: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Outline

Why Constraint Programming?Constraint PropagationGlobal ConstraintsCustomizing SearchWhat is missing?

Helmut Simonis Introduction to CP 5

Page 6: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Examples in ECLiPSe

Open sourced constraint programming languageDevelopment goes back to 1985ECRC, ICL, IC-Parc, PTL, Ciscohttp://www.eclipse-clp.org/

SpecialitiesDevelop new solvers for specific domainsIntegration with MIP

Helmut Simonis Introduction to CP 6

Page 7: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ECLiPSe ELearning Course

Self-study course in constraint programmingSupported by Cisco Systems and Silicon ValleyCommunity FoundationMulti-media format, video lectures, slides, handout etchttp://4c.ucc.ie/~hsimonis/ELearning/index.htm

Helmut Simonis Introduction to CP 7

Page 8: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Constraint Programming - in a nutshell

Declarative description of problems withVariables which range over (finite) sets of valuesConstraints over subsets of variables which restrict possiblevalue combinationsA solution is a value assignment which satisfies allconstraints

Constraint propagation/reasoningRemoving inconsistent values for variablesDetect failure if constraint can not be satisfiedInteraction of constraints via shared variablesIncomplete

SearchUser controlled assignment of values to variablesEach step triggers constraint propagation

Different domains require/allow different methods

Helmut Simonis Introduction to CP 8

Page 9: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Basic Process

Problem

Human

Model

Constraint Solver/Search

Solution

Helmut Simonis Introduction to CP 9

Page 10: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

More Realistic

Problem

Human

Model

Constraint Solver/Search

Hangs Solution Wrong Solution

Helmut Simonis Introduction to CP 10

Page 11: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Dual Role of Model

Allows Human to Express ProblemClose to Problem DomainConstraints as Abstractions

Allows Solver to ExecuteVariables as Communication MechanismConstraints as Algorithms

Helmut Simonis Introduction to CP 11

Page 12: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Part I

Basic Constraint Propagation

Helmut Simonis Introduction to CP 12

Page 13: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Example 1: SEND+MORE=MONEY

Example of Finite Domain Constraint ProblemModels and ProgramsConstraint Propagation and SearchSome Basic Constraints: linear arithmetic, alldifferent,disequalityA Built-in searchVisualizers for variables, constraints and search

Helmut Simonis Introduction to CP 13

Page 14: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Outline

1 Problem

2 Program

3 Constraint Setup

4 Search

5 Points to Remember

Helmut Simonis Introduction to CP 14

Page 15: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Problem Definition

A Crypt-Arithmetic PuzzleWe begin with the definition of the SEND+MORE=MONEYpuzzle. It is often shown in the form of a hand-written addition:

S E N D+ M O R EM O N E Y

Helmut Simonis Introduction to CP 15

Page 16: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Rules

S E N D+ M O R EM O N E Y

Each character stands for a digit from 0 to 9.Numbers are built from digits in the usual, positionalnotation.Repeated occurrence of the same character denote thesame digit.Different characters denote different digits.Numbers do not start with a zero.The equation must hold.

Helmut Simonis Introduction to CP 16

Page 17: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Outline

1 Problem

2 Program

3 Constraint Setup

4 Search

5 Points to Remember

Helmut Simonis Introduction to CP 17

Page 18: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Model

Each character is a variable, which ranges over the values0 to 9.An alldifferent constraint between all variables, whichstates that two different variables must have differentvalues. This is a very common constraint, which we willencounter in many other problems later on.Two disequality constraints (variable X must be differentfrom value V ) stating that the variables at the beginning ofa number can not take the value 0.An arithmetic equality constraint linking all variables withthe proper coefficients and stating that the equation musthold.

Helmut Simonis Introduction to CP 18

Page 19: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).é Define Module:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 19

Page 20: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).é Make predicate visible:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 20

Page 21: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).é Use ic librarysendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 21

Page 22: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-é Predicate definition

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 22

Page 23: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y], é Define listL :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 23

Page 24: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,é Define integer domain 0..9alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 24

Page 25: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L), é Digits must be differentS #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 25

Page 26: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

S E N D+ M O R EM O N E Y

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,é Numbers don’t start with 01000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 26

Page 27: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

S E N D+ M O R EM O N E Y

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 27

Page 28: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).é built-in search routine

Helmut Simonis Introduction to CP 28

Page 29: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Program Sendmory

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 29

Page 30: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

General Program Structure

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],é VariablesL :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 30

Page 31: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

General Program Structure

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),é ConstraintsS #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).

Helmut Simonis Introduction to CP 31

Page 32: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

General Program Structure

:- module(sendmory).:- export(sendmory/1).:- lib(ic).sendmory(L):-

L = [S,E,N,D,M,O,R,Y],L :: 0..9,alldifferent(L),S #\= 0, M #\= 0,1000*S + 100*E + 10*N + D +1000*M + 100*O + 10*R + E #=10000*M + 1000*O + 100*N + 10*E + Y,labeling(L).é Search

Helmut Simonis Introduction to CP 32

Page 33: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Choice of Model

This is one model, not the model of the problemMany possible alternativesChoice often depends on your constraint system

Constraints availableReasoning attached to constraints

Not always clear which is the best modelOften: Not clear what is the problem

Helmut Simonis Introduction to CP 33

Page 34: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Running the program

To run the program, we have to enter the querysendmory:sendmory(L).

ResultL = [9, 5, 6, 7, 1, 0, 8, 2]yes (0.00s cpu, solution 1, maybe more)

Helmut Simonis Introduction to CP 34

Page 35: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Question

But how did the program come up with this solution?

Helmut Simonis Introduction to CP 35

Page 36: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Outline

1 Problem

2 Program

3 Constraint SetupDomain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

4 Search

5 Points to RememberHelmut Simonis Introduction to CP 36

Page 37: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domain Definition

L = [S,E,N,D,M,O,R,Y],L :: 0..9,

[S,E ,N,D,M,O,R,Y ] ∈ {0..9}

Helmut Simonis Introduction to CP 37

Page 38: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domain Visualization

0 1 2 3 4 5 6 7 8 9SENDMORY

Helmut Simonis Introduction to CP 38

Page 39: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domain Visualization

Rows =Variables

0 1 2 3 4 5 6 7 8 9SENDMORY

Helmut Simonis Introduction to CP 39

Page 40: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domain Visualization

Columns = Values0 1 2 3 4 5 6 7 8 9

SENDMORY

Helmut Simonis Introduction to CP 40

Page 41: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domain Visualization

Cells= State

0 1 2 3 4 5 6 7 8 9SENDMORY

Helmut Simonis Introduction to CP 41

Page 42: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Alldifferent Constraint

alldifferent(L),

Built-in of ic libraryNo initial propagation possibleSuspends, waits until variables are changedWhen variable is fixed, remove value from domain of othervariablesForward checking

Helmut Simonis Introduction to CP 42

Page 43: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Alldifferent Visualization

Uses the same representation as the domain visualizer

0 1 2 3 4 5 6 7 8 9SENDMORY

Helmut Simonis Introduction to CP 43

Page 44: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Disequality Constraints

S #\= 0, M#\= 0,

Remove value from domain

S ∈ {1..9},M ∈ {1..9}

Constraints solved, can be removed

Helmut Simonis Introduction to CP 44

Page 45: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domains after Disequality

0 1 2 3 4 5 6 7 8 9SENDMORY

Helmut Simonis Introduction to CP 45

Page 46: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Equality Constraint

Normalization of linear termsSingle occurence of variablePositive coefficients

Propagation

Helmut Simonis Introduction to CP 46

Page 47: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ 10*N+ D+1000*M+ 100*O+ 10*R+ E

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

Helmut Simonis Introduction to CP 47

Page 48: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ 10*N+ D+1000*M+ 100*O+ 10*R+ E

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

Helmut Simonis Introduction to CP 48

Page 49: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ 10*N+ D+ 100*O+ 10*R+ E

9000*M+ 1000*O+ 100*N+ 10*E+ Y

Helmut Simonis Introduction to CP 49

Page 50: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ 10*N+ D+ 100*O+ 10*R+ E

9000*M+ 1000*O+ 100*N+ 10*E+ Y

Helmut Simonis Introduction to CP 50

Page 51: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ 10*N+ D+ 10*R+ E

9000*M+ 900*O+ 100*N+ 10*E+ Y

Helmut Simonis Introduction to CP 51

Page 52: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ 10*N+ D+ 10*R+ E

9000*M+ 900*O+ 100*N+ 10*E+ Y

Helmut Simonis Introduction to CP 52

Page 53: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ D+ 10*R+ E

9000*M+ 900*O+ 90*N+ 10*E+ Y

Helmut Simonis Introduction to CP 53

Page 54: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 100*E+ D+ 10*R+ E

9000*M+ 900*O+ 90*N+ 10*E+ Y

Helmut Simonis Introduction to CP 54

Page 55: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Normalization

1000*S+ 91*E+ D+ 10*R

9000*M+ 900*O+ 90*N+ Y

Helmut Simonis Introduction to CP 55

Page 56: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Simplified Equation

1000∗S+91∗E +10∗R+D = 9000∗M +900∗O+90∗N +Y

Helmut Simonis Introduction to CP 56

Page 57: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9 =

9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9

Helmut Simonis Introduction to CP 57

Page 58: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸1000..9918

=

9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..89919

Helmut Simonis Introduction to CP 58

Page 59: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸9000..9918

=

9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..9918

Helmut Simonis Introduction to CP 59

Page 60: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸9000..9918

=

9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..9918

Deduction:M = 1,S = 9,O ∈ {0..1}

Helmut Simonis Introduction to CP 60

Page 61: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸9000..9918

=

9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..9918

Deduction:M = 1,S = 9,O ∈ {0..1}

Why? Skip

Helmut Simonis Introduction to CP 61

Page 62: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Consider lower bound for S

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸9000..9918

= 9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..9918

Lower bound of equation is 9000Rest of lhs (left hand side) (91 ∗E0..9 + 10 ∗R0..9 +D0..9) isatmost 918S must be greater or equal to 9000−918

1000 = 8.082otherwise lower bound of equation not reached by lhs

S is integer, therefore S ≥ d9000−9181000 e = 9

S has upper bound of 9, so S = 9

Helmut Simonis Introduction to CP 62

Page 63: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Consider upper bound of M

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸9000..9918

= 9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..9918

Upper bound of equation is 9918Rest of rhs (right hand side) 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9

is at least 0M must be smaller or equal to 9918−0

9000 = 1.102

M must be integer, therefore M ≤ b9918−09000 c = 1

M has lower bound of 1, so M = 1

Helmut Simonis Introduction to CP 63

Page 64: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Consider upper bound of O

1000 ∗ S1..9 + 91 ∗ E0..9 + 10 ∗ R0..9 + D0..9︸ ︷︷ ︸9000..9918

= 9000 ∗M1..9 + 900 ∗O0..9 + 90 ∗ N0..9 + Y 0..9︸ ︷︷ ︸9000..9918

Upper bound of equation is 9918Rest of rhs (right hand side) 9000 ∗ 1 + 90 ∗ N0..9 + Y 0..9 isat least 9000O must be smaller or equal to 9918−9000

900 = 1.02

O must be integer, therefore O ≤ b9918−9000900 c = 1

O has lower bound of 0, so O ∈ {0..1}

Helmut Simonis Introduction to CP 64

Page 65: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality: Result

0 1 2 3 4 5 6 7 8 9S - - - - - - - - Y

ENDM Y - - - - - - - -O 6 6 6 6 6 6 6 6

RY

Helmut Simonis Introduction to CP 65

Page 66: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9S - - - - - - - - Y

ENDM Y - - - - - - - -O 6 6 6 6 6 6 6 6

RY

Helmut Simonis Introduction to CP 66

Page 67: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9S Y

E |N |D |M Y

OR |Y |

Helmut Simonis Introduction to CP 67

Page 68: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SE |N |D |M Y

O |R |Y |

Helmut Simonis Introduction to CP 68

Page 69: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMO Y

RY

Helmut Simonis Introduction to CP 69

Page 70: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SE |N |D |MO Y

R |Y |

Helmut Simonis Introduction to CP 70

Page 71: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMORY

O = 0, [E ,R,D,N,Y ] ∈ {2..8}

Helmut Simonis Introduction to CP 71

Page 72: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Waking the equality constraint

Triggered by assignment of variablesor update of lower or upper bound

Helmut Simonis Introduction to CP 72

Page 73: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Removal of constants

1000 ∗ 9 + 91 ∗ E2..8 + 10 ∗ R2..8 + D2..8 =

9000 ∗ 1 + 900 ∗ 0 + 90 ∗ N2..8 + Y 2..8

Helmut Simonis Introduction to CP 73

Page 74: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Removal of constants

1000 ∗ 9 + 91 ∗ E2..8 + 10 ∗ R2..8 + D2..8 =

9000 ∗ 1 + 900 ∗ 0 + 90 ∗ N2..8 + Y 2..8

Helmut Simonis Introduction to CP 74

Page 75: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Removal of constants

91 ∗ E2..8 + 10 ∗ R2..8 + D2..8 = 90 ∗ N2..8 + Y 2..8

Helmut Simonis Introduction to CP 75

Page 76: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 1)

91 ∗ E2..8 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸204..816

= 90 ∗ N2..8 + Y 2..8︸ ︷︷ ︸182..728

Helmut Simonis Introduction to CP 76

Page 77: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 1)

91 ∗ E2..8 + 10 ∗ R2..8 + D2..8 = 90 ∗ N2..8 + Y 2..8︸ ︷︷ ︸204..728

Helmut Simonis Introduction to CP 77

Page 78: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 1)

91 ∗ E2..8 + 10 ∗ R2..8 + D2..8 = 90 ∗ N2..8 + Y 2..8︸ ︷︷ ︸204..728

N ≥ 3 = d204− 890

e,E ≤ 7 = b728− 2291

c

Helmut Simonis Introduction to CP 78

Page 79: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 2)

91 ∗ E2..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N3..8 + Y 2..8

Helmut Simonis Introduction to CP 79

Page 80: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 2)

91 ∗ E2..7 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸204..725

= 90 ∗ N3..8 + Y 2..8︸ ︷︷ ︸272..728

Helmut Simonis Introduction to CP 80

Page 81: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 2)

91 ∗ E2..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N3..8 + Y 2..8︸ ︷︷ ︸272..725

Helmut Simonis Introduction to CP 81

Page 82: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 2)

91 ∗ E2..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N3..8 + Y 2..8︸ ︷︷ ︸272..725

E ≥ 3 = d272− 8891

e

Helmut Simonis Introduction to CP 82

Page 83: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 3)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N3..8 + Y 2..8

Helmut Simonis Introduction to CP 83

Page 84: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 3)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸295..725

= 90 ∗ N3..8 + Y 2..8︸ ︷︷ ︸272..728

Helmut Simonis Introduction to CP 84

Page 85: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 3)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N3..8 + Y 2..8︸ ︷︷ ︸295..725

Helmut Simonis Introduction to CP 85

Page 86: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 3)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N3..8 + Y 2..8︸ ︷︷ ︸295..725

N ≥ 4 = d295− 890

e

Helmut Simonis Introduction to CP 86

Page 87: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 4)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N4..8 + Y 2..8

Helmut Simonis Introduction to CP 87

Page 88: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 4)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸295..725

= 90 ∗ N4..8 + Y 2..8︸ ︷︷ ︸362..728

Helmut Simonis Introduction to CP 88

Page 89: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 4)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N4..8 + Y 2..8︸ ︷︷ ︸362..725

Helmut Simonis Introduction to CP 89

Page 90: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 4)

91 ∗ E3..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N4..8 + Y 2..8︸ ︷︷ ︸362..725

E ≥ 4 = d362− 8891

e

Helmut Simonis Introduction to CP 90

Page 91: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 5)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N4..8 + Y 2..8

Helmut Simonis Introduction to CP 91

Page 92: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 5)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸386..725

= 90 ∗ N4..8 + Y 2..8︸ ︷︷ ︸362..728

Helmut Simonis Introduction to CP 92

Page 93: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 5)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N4..8 + Y 2..8︸ ︷︷ ︸386..725

Helmut Simonis Introduction to CP 93

Page 94: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 5)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N4..8 + Y 2..8︸ ︷︷ ︸386..725

N ≥ 5 = d386− 890

e

Helmut Simonis Introduction to CP 94

Page 95: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 6)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N5..8 + Y 2..8

Helmut Simonis Introduction to CP 95

Page 96: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 6)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸386..725

= 90 ∗ N5..8 + Y 2..8︸ ︷︷ ︸452..728

Helmut Simonis Introduction to CP 96

Page 97: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 6)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N5..8 + Y 2..8︸ ︷︷ ︸452..725

Helmut Simonis Introduction to CP 97

Page 98: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Propagation of equality (Iteration 6)

91 ∗ E4..7 + 10 ∗ R2..8 + D2..8 = 90 ∗ N5..8 + Y 2..8︸ ︷︷ ︸452..725

N ≥ 5 = d452− 890

e,E ≥ 4 = d452− 8891

e

No further propagation at this point

Helmut Simonis Introduction to CP 98

Page 99: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Domain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Domains after setup

0 1 2 3 4 5 6 7 8 9SENDMORY

Helmut Simonis Introduction to CP 99

Page 100: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Outline

1 Problem

2 Program

3 Constraint Setup

4 SearchStep 1Step 2Further StepsSolution

5 Points to RememberHelmut Simonis Introduction to CP 100

Page 101: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

labeling built-in

labeling([S,E,N,D,M,O,R,Y])

Try variable is order givenTry values starting from smallest value in domainWhen failing, backtrack to last open choiceChronological BacktrackingDepth First search

Helmut Simonis Introduction to CP 101

Page 102: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Search Tree Step 1

Variable S already fixed

S

E9

Helmut Simonis Introduction to CP 102

Page 103: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Step 2, Alternative E = 4

Variable E ∈ {4..7}, first value tested is 4

S

E4

9

Helmut Simonis Introduction to CP 103

Page 104: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Assignment E = 4

0 1 2 3 4 5 6 7 8 9SE Y - - -NDMORY

Helmut Simonis Introduction to CP 104

Page 105: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of E = 4, equality constraint

91 ∗ 4 + 10 ∗ R2..8 + D2..8 = 90 ∗ N5..8 + Y 2..8

Helmut Simonis Introduction to CP 105

Page 106: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of E = 4, equality constraint

91 ∗ 4 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸386..452

= 90 ∗ N5..8 + Y 2..8︸ ︷︷ ︸452..728

Helmut Simonis Introduction to CP 106

Page 107: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of E = 4, equality constraint

91 ∗ 4 + 10 ∗ R2..8 + D2..8 = 90 ∗ N5..8 + Y 2..8︸ ︷︷ ︸452

Helmut Simonis Introduction to CP 107

Page 108: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of E = 4, equality constraint

91 ∗ 4 + 10 ∗ R2..8 + D2..8 = 90 ∗ N5..8 + Y 2..8︸ ︷︷ ︸452

N = 5,Y = 2,R = 8,D = 8

Helmut Simonis Introduction to CP 108

Page 109: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Result of equality propagation

0 1 2 3 4 5 6 7 8 9SEN Y - - -D - - - - - - Y

MOR - - - - - - Y

Y Y - - - - - -

Helmut Simonis Introduction to CP 109

Page 110: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SEN Y - - -D - - - - - - Y

MOR - - - - - - Y

Y Y - - - - - -

Helmut Simonis Introduction to CP 110

Page 111: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9S |E |N Y - - |D - - - - - - Y

M |O |R - - - - - - Y

Y Y - - - - - |

Alldifferent fails!

Helmut Simonis Introduction to CP 111

Page 112: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Step 2, Alternative E = 5

Return to last open choice, E , and test next value

S

E4

N5

9

Helmut Simonis Introduction to CP 112

Page 113: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Assignment E = 5

0 1 2 3 4 5 6 7 8 9SE - Y - -NDMORY

Helmut Simonis Introduction to CP 113

Page 114: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SE - Y - -NDMORY

Helmut Simonis Introduction to CP 114

Page 115: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SE Y

N |D |MOR |Y |

Helmut Simonis Introduction to CP 115

Page 116: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMORY

N 6= 5,N ≥ 6

Helmut Simonis Introduction to CP 116

Page 117: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ R2..8 + D2..8 = 90 ∗ N6..8 + Y 2..8

Helmut Simonis Introduction to CP 117

Page 118: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ R2..8 + D2..8︸ ︷︷ ︸477..543

= 90 ∗ N6..8 + Y 2..8︸ ︷︷ ︸542..728

Helmut Simonis Introduction to CP 118

Page 119: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ R2..8 + D2..8 = 90 ∗ N6..8 + Y 2..8︸ ︷︷ ︸542..543

Helmut Simonis Introduction to CP 119

Page 120: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ R2..8 + D2..8 = 90 ∗ N6..8 + Y 2..8︸ ︷︷ ︸542..543

N = 6,Y ∈ {2,3},R = 8,D ∈ {7..8}

Helmut Simonis Introduction to CP 120

Page 121: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Result of equality propagation

0 1 2 3 4 5 6 7 8 9SEN Y - -D 6 6 6 6

MOR - - - - - Y

Y 6 6 6 6

Helmut Simonis Introduction to CP 121

Page 122: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SEN Y - -D 6 6 6 6

MOR - - - - - Y

Y 6 6 6 6

Helmut Simonis Introduction to CP 122

Page 123: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SEND |MOR Y

Y

Helmut Simonis Introduction to CP 123

Page 124: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SEND Y

MORY

Helmut Simonis Introduction to CP 124

Page 125: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMORY

D = 7

Helmut Simonis Introduction to CP 125

Page 126: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ 8 + 7 = 90 ∗ 6 + Y 2..3

Helmut Simonis Introduction to CP 126

Page 127: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ 8 + 7︸ ︷︷ ︸542

= 90 ∗ 6 + Y 2..3︸ ︷︷ ︸542..543

Helmut Simonis Introduction to CP 127

Page 128: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ 8 + 7 = 90 ∗ 6 + Y 2..3︸ ︷︷ ︸542

Helmut Simonis Introduction to CP 128

Page 129: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Propagation of equality

91 ∗ 5 + 10 ∗ 8 + 7 = 90 ∗ 6 + Y 2..3︸ ︷︷ ︸542

Y = 2

Helmut Simonis Introduction to CP 129

Page 130: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Last propagation step

0 1 2 3 4 5 6 7 8 9SENDMORY Y -

Helmut Simonis Introduction to CP 130

Page 131: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N5

9

Helmut Simonis Introduction to CP 131

Page 132: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N

D6

5

9

Helmut Simonis Introduction to CP 132

Page 133: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N

D

M7

6

5

9

Helmut Simonis Introduction to CP 133

Page 134: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N

D

M

O1

7

6

5

9

Helmut Simonis Introduction to CP 134

Page 135: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N

D

M

O

R0

1

7

6

5

9

Helmut Simonis Introduction to CP 135

Page 136: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N

D

M

O

R

Y8

0

1

7

6

5

9

Helmut Simonis Introduction to CP 136

Page 137: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Further Steps: Nothing more to do

S

E4

N

D

M

O

R

Y2

8

0

1

7

6

5

9

Helmut Simonis Introduction to CP 137

Page 138: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Complete Search Tree

S

E4

N

D

M

O

R

Y2

8

0

1

7

6

5 6 7

9

Helmut Simonis Introduction to CP 138

Page 139: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Step 1Step 2Further StepsSolution

Solution

9 5 6 7+ 1 0 8 51 0 6 5 2

Helmut Simonis Introduction to CP 139

Page 140: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Outline

1 Problem

2 Program

3 Constraint Setup

4 Search

5 Points to Remember

Helmut Simonis Introduction to CP 140

Page 141: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Points to Remember

Constraint models are expressed by variables andconstraints.Problems can have many different models, which canbehave quite differently. Choosing the best model is an art.Constraints can take many different forms.Propagation deals with the interaction of variables andconstraints.It removes some values that are inconsistent with aconstraint from the domain of a variable.Constraints only communicate via shared variables.

Helmut Simonis Introduction to CP 141

Page 142: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Constraint SetupSearch

Points to Remember

Points to Remember

Propagation usually is not sufficient, search may berequired to find a solution.Propagation is data driven, and can be quite complex evenfor small examples.The default search uses chronological depth-firstbacktracking, systematically exploring the complete searchspace.The search choices and propagation are interleaved, afterevery choice some more propagation may further reducethe problem.

Helmut Simonis Introduction to CP 142

Page 143: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Part II

Global Constraints

Helmut Simonis Introduction to CP 143

Page 144: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Example 2: Sudoku

Global ConstraintsPowerful modelling abstractionsNon-trivial propagationDifferent consistency levels

Example: Sudoku puzzle

Helmut Simonis Introduction to CP 144

Page 145: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Outline

6 Problem

7 Initial Propagation (Forward Checking)

8 Improved Reasoning

9 Search

Helmut Simonis Introduction to CP 145

Page 146: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Problem Definition

SudokuFill in numbers from 1 to 9 so that each row, column and blockcontain each number exactly once

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Helmut Simonis Introduction to CP 146

Page 147: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Problem Definition

SudokuFill in numbers from 1 to 9 so that each row, column and blockcontain each number exactly once

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

4 2 8 5 6 3 1 7 93 5 9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6 3 9 8 2 5 75 9 2 7 4 1 3 8 68 3 7 6 2 5 9 4 12 7 4 9 5 6 8 1 36 8 3 2 1 4 7 9 59 1 5 8 3 7 6 2 4

Helmut Simonis Introduction to CP 147

Page 148: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Model

A variable for each cell, ranging from 1 to 9A 9x9 matrix of variables describing the problemPreassigned integers for the given hintsalldifferent constraints for each row, column and 3x3block

Helmut Simonis Introduction to CP 148

Page 149: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Reminder: alldifferent

Argument: list of variablesMeaning: variables are pairwise differentReasoning: Forward Checking (FC)

When variable is assigned to value, remove the value fromall other variablesIf a variable has only one possible value, then it is assignedIf a variable has no possible values, then the constraint failsConstraint is checked whenever one of its variables isassignedEquivalent to decomposition into binary disequalityconstraints

Helmut Simonis Introduction to CP 149

Page 150: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Main Program

model(Matrix):-Matrix[1..9,1..9] :: 1..9,(for(I,1,9),param(Matrix) do

alldifferent(Matrix[I,1..9]),alldifferent(Matrix[1..9,I])

),(multifor([I,J],[1,1],[7,7],[3,3]),param(Matrix) do

alldifferent(flatten(Matrix[I..I+2,J..J+2]))),flatten_array(Matrix,List),labeling(List).

Helmut Simonis Introduction to CP 150

Page 151: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain Visualizer

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Problem shown as matrixEach cell corresponds to a variableInstantiated: Shows integer value (large)Uninstantiated: Shows values in domain

Helmut Simonis Introduction to CP 151

Page 152: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Outline

6 Problem

7 Initial Propagation (Forward Checking)

8 Improved Reasoning

9 Search

Helmut Simonis Introduction to CP 152

Page 153: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Initial State (Forward Checking)

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Helmut Simonis Introduction to CP 153

Page 154: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Skip Animation

Helmut Simonis Introduction to CP 154

Page 155: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 155

Page 156: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 2 35 6

7 9 81 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 156

Page 157: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 2 35 6

7 9 81 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 91 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 35 6

7 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 157

Page 158: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 2 35 6

7 9 81 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

2 34 5 68 9

2 34 5 68 9 1 7

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 35 6

7 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 158

Page 159: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5 68 9 1 7

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 35 6

7 8 9

1 24 5 68 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 159

Page 160: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5 68 9 1 7

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5 67 9

14 5 67 9 8

14 5 67 9

14 5 67 9 3 2

1 35 6

7 8 9

1 24 5 68 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 160

Page 161: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

9

14 5 67 9 8

14 5 67 9

14 5 67 9 3 2

1 35 6

7 8 9

1 24 5 68 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 161

Page 162: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

9

14 5 67 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

1 347 9

1 347 9 8 2 5

1 347 9

1 35 6

7 8 9 91 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 162

Page 163: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

1 347 9 8 2 5

1 347 9

1 35 6

7 8 9 91 2 34 5

9

2 34 57 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 163

Page 164: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

1 347 9 8 2 5

1 347 9

1 35 6

7 91 2 34 5

2 34 57

1 2 34 5 67

1 2 34 5 67

1 2 34 5 67 8

1 2 34 5 67

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 164

Page 165: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 34 5 67

1 2 34 5 67 8

1 2 34 5 67

1 35 6

7 8 9 3 7 62 3

4 69

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 165

Page 166: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 34 5 67

1 2 34 5 67 8

1 2 34 5 67

158 3 7 6

24

1 24 58 9

1 24 58

1 24 58

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 166

Page 167: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 2 34 5 67 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 2 34 5

9

2 34 57 8 9 5

1 2 35 6

7 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 167

Page 168: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 2 34 5 67 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 34

9

348 9 5

1 369

1 34 68 9

1 34 68 9

1 34 68 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 168

Page 169: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 34

9

348 9 5

1 369

1 348

1 34 68 9

1 34 68 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 34 57 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 169

Page 170: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 34

9

348 9 5

1 369

1 348

1 34 68 9

1 34 68 9

35 6

7 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

2 35 6

7 8 9

2 35 6

7 8 91 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 170

Page 171: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

24 6

9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24

1 24 58

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 34 68 9

35 6

7 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

2 35 6

7 8 91 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 24 67 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 171

Page 172: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

24 6

9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24

1 24 58

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 34 68 9

35 6

7 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

2 35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 172

Page 173: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

24 6

9

35 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 3

7 91 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7158 3 7 6

24

1 25 9

1 24

158

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 93

5 67 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 173

Page 174: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 35 6

7 93

5 69

25 6

2 359 1 7

2 35 69

34 58

24 6

9

35 68 9

15 6

7 9

15 6

1594 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 3

7 91 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7158 3 7 6

24

1 25 9

1 24

158

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 93

5 67 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 174

Page 175: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

2 369

2 35 69

1 35

7

1 26

7 9

1 35 6

7 93

5 69

25 6

2 359 1 7

2 35 69

34 58

24 6

9

35 68 9

15 6

7 9

15 6

1594 5

9 8 5 69

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 3

7 91 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7158 3 7 6

24

1 25 9

1 24

158

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 93

5 67 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 175

Page 176: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

2 369

2 35 69

15

7

16

7 9

15 6

7 93

5 69

25 6

2 359 1 7

2 35 694 58

4 69

5 68 9

15 6

7 9

15 6

1594 5

9 8 5 69

14 57 3 2

1 4 63

47 9

34

9 8 2 51 3

7 9

5 9 22 3

4 57

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7

8 3 7 62

41 25 9

1 24

158

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 93

5 67 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 176

Page 177: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

2 369

2 35 69

15

7

16

7 9

15 6

7 9369

25 6

359 1 7

2 35 694 58

4 69

5 68 9

67 9

15 6

1594 5

9 8 5 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7 9

5 9 23

47

34 6

1 36

7

1 347 8

1 36

7

8 3 7 62

41 25 9

1 24

15

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 936

7 9

25 68

359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 93

7 9

1 258

1 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 177

Page 178: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

2 369

2 35 69

15

7

16

7 9

15 6

7 9369

25 6

359 1 7

2 35 694 58

4 69

5 68 9

67 9

15 6

1594 5

9 8 5 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7 9

5 9 23

47

34

1 3

7

1 347 8

1 36

7

8 3 7 6 2 5 9 4 12 7

1 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 936

7 9

25 68

359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 93

7 9

1 258

1 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 178

Page 179: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

348 9 5

1 369

1 348

169

36

8 936

7 9

25 68

359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 93

7 9

1 258

1 359

2 35

7 8 9

3

9

1 2 3

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 179

Page 180: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

348 9 5

1 369

1 348

169

36

8 9369

5 68

359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 93

9

158

1 359

2 35

7 8 9

3

9

1 2 3

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 180

Page 181: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 348

169

36

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

26

7 9

35 6

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 181

Page 182: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Propagation Steps (Forward Checking)

41 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4Back to Start

Helmut Simonis Introduction to CP 182

Page 183: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

After Setup (Forward Checking)

41 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

Helmut Simonis Introduction to CP 183

Page 184: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Outline

6 Problem

7 Initial Propagation (Forward Checking)

8 Improved ReasoningDomain ConsistencyComparison

9 Search

Helmut Simonis Introduction to CP 184

Page 185: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Can we do better?

The alldifferent constraint is missing propagationHow can we do more propagation?Do we know when we derive all possible information fromthe constraint?

Constraints only interact by changing domains of variables

Helmut Simonis Introduction to CP 185

Page 186: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

A Simpler Example

:-lib(ic).

top:-X :: 1..2,Y :: 1..2,Z :: 1..3,alldifferent([X,Y,Z]),writeln([X,Y,Z]).

Helmut Simonis Introduction to CP 186

Page 187: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Using Forward Checking

No variable is assignedNo reduction of domainsBut, values 1 and 2 can be removed from ZThis means that Z is assigned to 3

Helmut Simonis Introduction to CP 187

Page 188: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Visualization of alldifferent as Graph

X

Y

Z

1

2

3Show problem as graph with two types of nodes

Variables on the leftValues on the right

If value is in domain of variable, show link between themThis is called a bipartite graph

Helmut Simonis Introduction to CP 188

Page 189: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

A Simpler Example

Value Graph for

X :: 1..2,

Y :: 1..2,

Z :: 1..3

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 189

Page 190: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

A Simpler Example

Check interval [1,2]X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 190

Page 191: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

A Simpler Example

Find variables completelycontained in intervalThere are two: X and YThis uses up the capacity of theinterval

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 191

Page 192: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

A Simpler Example

No other variable can use thatinterval

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 192

Page 193: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

A Simpler Example

Only one value left in domain of Z,this can be assigned

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 193

Page 194: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Idea (Hall Intervals)

Take each interval of possible values, say size NFind all K variables whose domain is completely containedin intervalIf K > N then the constraint is infeasibleIf K = N then no other variable can use that intervalRemove values from such variables if their bounds changeIf K < N do nothingRe-check whenever domain bounds change

Helmut Simonis Introduction to CP 194

Page 195: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Implementation

Problem: Too many intervals (O(n2)) to considerSolution:

Check only those intervals which update boundsEnumerate intervals incrementallyStarting from lowest(highest) valueUsing sorted list of variables

Complexity: O(n log(n)) in standard implementationsImportant: Only looks at min/max bounds of variables

Helmut Simonis Introduction to CP 195

Page 196: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Bounds Consistency

DefinitionA constraint achieves bounds consistency, if for the lower andupper bound of every variable, it is possible to find values for allother variables between their lower and upper bounds whichsatisfy the constraint.

Helmut Simonis Introduction to CP 196

Page 197: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Can we do better?

Bounds consistency only considers min/max boundsIgnores “holes” in domainSometimes we can improve propagation looking at thoseholes

Helmut Simonis Introduction to CP 197

Page 198: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

:-lib(ic).

top:-X :: [1,3],Y :: [1,3],Z :: 1..3,alldifferent([X,Y,Z]),writeln([X,Y,Z]).

Helmut Simonis Introduction to CP 198

Page 199: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Value Graph for

X :: [1,3],

Y :: [1,3],

Z :: 1..3

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 199

Page 200: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Check interval [1,2]No domain of a variablecompletely contained in intervalNo propagation

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 200

Page 201: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Check interval [2,3]No domain of a variablecompletely contained in intervalNo propagation

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 201

Page 202: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

But, more propagation is possible,there are only two solutions

X

Y

Z

1

2

3

Helmut Simonis Introduction to CP 202

Page 203: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Solution 1: assignment in blueX

Y

Z

1

2

3

Helmut Simonis Introduction to CP 203

Page 204: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Solution 2: assignment in greenX

Y

Z

1

2

3

Helmut Simonis Introduction to CP 204

Page 205: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Solution 1 Solution 2 CombinedX

Y

Z

1

2

3

X

Y

Z

1

2

3

X

Y

Z

1

2

3

Combining solutions shows that Z=1 andZ=3 are not possible.

Helmut Simonis Introduction to CP 205

Page 206: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Another Simple Example

Can we deduce this without enumeratingsolutions?

Helmut Simonis Introduction to CP 206

Page 207: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Solutions and maximal matchings

A Matching is subset of edges which do not coincide in anynodeNo matching can have more edges than number ofvariablesEvery solution corresponds to a maximal matching andvice versaIf a link does not belong to some maximal matching, then itcan be removed

Helmut Simonis Introduction to CP 207

Page 208: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Implementation

Possible to compute all links which belong to somematching

Without enumerating all of them!

Enough to compute one maximal matchingRequires algorithm for strongly connected componentsExtra work required if more values than variablesAll links (values in domains) which are not supported canbe removedComplexity: O(n1.5d)

Helmut Simonis Introduction to CP 208

Page 209: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Domain Consistency

DefinitionA constraint achieves domain consistency, if for every variableand for every value in its domain, it is possible to find values inthe domains of all other variables which satisfy the constraint.

Also called generalized arc consistency (GAC)or hyper arc consistency

Helmut Simonis Introduction to CP 209

Page 210: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Can we still do better?

NO! This extracts all information from this one constraintWe could perhaps improve speed, but not propagationBut possible to use different modelOr model interaction of multiple constraints

Helmut Simonis Introduction to CP 210

Page 211: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Should all constraints achieve domain consistency?

Domain consistency is usually more expensive thanbounds consistency

Overkill for simple problemsNice to have choices

For some constraints achieving domain consistency isNP-hard

We have to live with more restricted propagation

Helmut Simonis Introduction to CP 211

Page 212: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Initial State (Domain Consistency)

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Helmut Simonis Introduction to CP 212

Page 213: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Skip Animation

Helmut Simonis Introduction to CP 213

Page 214: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 214

Page 215: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 2 35 6

7 9 81 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 7 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 215

Page 216: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 2 35 6

7 9 81 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 91 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 7

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 35 6

7 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 216

Page 217: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 2 35 6

7 9 81 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

2 34 5 68 9

2 34 5 68 9 1 7

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 35 6

7 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 217

Page 218: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5 68 9 1 7

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9 3 2

1 35 6

7 8 9

1 24 5 68 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 218

Page 219: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5 68 9 1 7

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5 67 9

14 5 67 9 8

14 5 67 9

14 5 67 9 3 2

1 35 6

7 8 9

1 24 5 68 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5 67 8 9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 219

Page 220: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

9

14 5 67 9 8

14 5 67 9

14 5 67 9 3 2

1 35 6

7 8 9

1 24 5 68 6

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8 2 5

1 2 34 5 67 8 9

1 35 6

7 8 9 91 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 220

Page 221: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

9

14 5 67 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

1 347 9

1 347 9 8 2 5

1 347 9

1 35 6

7 8 9 91 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

1 2 34 5 67 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 221

Page 222: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

1 347 9 8 2 5

1 347 9

1 35 6

7 8 9 91 2 34 5

9

2 34 57 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 8

1 2 34 5 67 8 9

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 222

Page 223: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

1 347 9 8 2 5

1 347 9

1 35 6

7 91 2 34 5

2 34 57

1 2 34 5 67

1 2 34 5 67

1 2 34 5 67 8

1 2 34 5 67

1 35 6

7 8 9 3 7 61 2 34 5 67 8 9

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 223

Page 224: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 34 5 67

1 2 34 5 67 8

1 2 34 5 67

1 35 6

7 8 9 3 7 62 3

4 69

1 2 34 5 67 8 9 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 224

Page 225: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 3

4 5 68 9

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

14 5 67 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 34 5 67

1 2 34 5 67 8

1 2 34 5 67

158 3 7 6

24

1 24 58 9

1 24 58

1 24 58

2 71 2 34 5

9

2 34 57 8 9 5

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 34 5 67 8 9 6

1 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 225

Page 226: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 2 34 5 67 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 2 34 5

9

2 34 57 8 9 5

1 2 35 6

7 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 226

Page 227: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

2 34 5 68 9

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 5 67 9 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 2 34 5 67 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 34

9

348 9 5

1 369

1 34 68 9

1 34 68 9

1 34 68 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 227

Page 228: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 34

9

348 9 5

1 369

1 348

1 34 68 9

1 34 68 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9 1 4

1 34 57 8

1 2 34 5 67 8 9

1 2 34 5 67 8 9

1 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 228

Page 229: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 2 35 6

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

2 34 5 68 9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24 58

1 24 58

2 71 34

9

348 9 5

1 369

1 348

1 34 68 9

1 34 68 9

35 6

7 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

2 35 6

7 8 9

2 35 6

7 8 91 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 2 34 5 67 8 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 229

Page 230: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

24 6

9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24

1 24 58

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 34 68 9

35 6

7 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

2 35 6

7 8 91 35 6

7 8 9

1 24 5 68

1 2 34 5

9

2 34 57 8 9

2 34 6

9

1 2 35 6

7 9 61 24 67 9 4

Back to Start Skip Animation

Helmut Simonis Introduction to CP 230

Page 231: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 2 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

24 6

9

2 34 5 68 9

15 6

7 9

14 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9

14 6

347 9

34

9 8 2 51 347 9

1 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 2 34 5 67

158 3 7 6

24

1 25 9

1 24

1 24 58

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 34 68 9

35 6

7 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

2 35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 231

Page 232: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 35 6

7 93

5 68 9

24 5 68

2 34 5

9 1 72 35 69

34 58

24 6

9

35 68 9

714 5 6

14 5

94 57 9 8

15 6

7 9

14 57 3 2

1 3

7 9 4 63

47 9

34

9 8 2 51 3

7 91 35 6

7 91 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7158 3 7 6

24

1 25 9

1 24

158

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 93

5 67 8 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 35

7 8 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 232

Page 233: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 35

7 9

2 369

1 2 35 6

7 9

1 35

7

1 26

7 9

1 35 6

7 93

5 69

25 6

2 359 1 7

2 35 69

34 58

24 6

9

35 68 9

715 6

159 4 8

15 69

14 5 3 2

1 3

9 4 63

7 9

3

9 8 2 51 3

7 91 35 6 9

1 2 34 5

2 34 57

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7158 3 7 6

24

1 25 9

1 24

158

2 71 34

9

348 9 5

1 369

1 348

14 6

9

1 36

8 93

5 68 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 358 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 233

Page 234: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 359

2 369

2 35 69

1 35

7

1 26

7 9

1 35 6

7 93

5 69

25 6

2 359 1 7

2 35 69

34 58

24 6

9

35 68 9

715 6

159 4 8 5 6

9

15 3 2

1 3

9 4 63

7 9

3

9 8 2 51 3

7 91 35 6 9

1 2 34 5

2 35

7

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7158 3 7 6

24

1 25 9

1 24

158

2 71 34

9

3

8 9 51 3

69

1 348

14 6

9

1 36

8 93

5 68 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 358 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 234

Page 235: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

41 25 6 8

2 359

2 369

2 35 69

15

7

16

7 9

15 6

7 93

5 69

25 6

2 359 1 7

2 35 694 58

4 69

5 68 9

715 6

159 4 8 5 6

9

15 3 2

1 4 63

7 9

3

9 8 2 51 3

7 9

5 9 22 35

7

2 34 6

1 2 35 6

7

1 34 57 8

1 35 6

7

8 3 7 62

41 25 9

1 24

158

2 7 43

8 9 51 3

69

1 348

14 6

9

1 36

8 93

5 68 9

25 68

2 359

2 35

7 8 9 1 43

57 8

26

7 9

35 6

7 8 91 358 9

1 258

1 2 359

2 35

7 8 9

2 3

9

1 2 35

7 9 61 2

7 9 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 235

Page 236: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

4 2 8 5 6 3 11

67 9

15 6

7 9369 5

359 1 7 2 4 6 8

7 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7 9

5 9 23

7 4 11 347 8 6

8 3 7 6 2 5 9 4 12 7 4

3

8 9 5 6 8 11 3

68 9

6 83

59 2 1 4

35

7 8

26

7 9 53

9 1 5 82 3

9 7 6 2 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 236

Page 237: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7 9

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 237

Page 238: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 238

Page 239: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 239

Page 240: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4Back to Start Skip Animation

Helmut Simonis Introduction to CP 240

Page 241: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Propagation Steps (Domain Consistency)

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4Back to Start

Helmut Simonis Introduction to CP 241

Page 242: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

After Setup (Domain Consistency)

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4

Helmut Simonis Introduction to CP 242

Page 243: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Comparison

Forward Checking Bounds Consistency Domain Consistency4

1 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

41 2

8 5 62 3 1

7

1

7 9 7 93

9

25

3

9 1 72 3

4 58

69

58 9

7 615 4 8 9

15 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

7

34 1

3

7 8 68 3 7 6 2 5 9 4 12 7 4

3

8 9 5 61 3

8

1

9

3

8 9

6 58

3

9

2 3

8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

15

2

8

3

9 7 61 2

4

4 2 8 5 6 3 1 7 9 7 93

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4

Helmut Simonis Introduction to CP 243

Page 244: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Domain ConsistencyComparison

Typical?

This does not always happenSometimes, two methods produce same amount ofpropagationPossible to predict in certain special casesIn general, tradeoff between speed and propagationNot always fastest to remove inconsistent values earlyBut often required to find a solution at all

Helmut Simonis Introduction to CP 244

Page 245: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Outline

6 Problem

7 Initial Propagation (Forward Checking)

8 Improved Reasoning

9 Search

Helmut Simonis Introduction to CP 245

Page 246: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Simple search routine

Enumerate variables in given orderTry values starting from smallest one in domainComplete, chronological backtracking

Helmut Simonis Introduction to CP 246

Page 247: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4

1 25 6 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

Skip Animation

Helmut Simonis Introduction to CP 247

Page 248: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

41

Back to Start Skip Animation

Helmut Simonis Introduction to CP 248

Page 249: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 2

369

2 369

57

67 9

5 67 9

369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

4

52

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 249

Page 250: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 2

369

369

57

67 9

5 67 9

369

25 6

359 1 7

3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

3

2

4

53

2

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 250

Page 251: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 2

369

369

57

67 9

5 67 9

369

25 6

359 1 7

3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

6

2

4

53 6

2

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 251

Page 252: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 2

369

369

57

67 9

5 67 9

369

25 6

359 1 7

3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

9

2

4

53 6 9

2

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 252

Page 253: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 3

369

2 369

57

67 9

5 67 9

369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

4

53 6 9

2

53

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 253

Page 254: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 3 6

9

269

57

67 9

5 67 9

369

25 6

359 1 7

2694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 6 7 9

3

9 8 2 53

7

5 9 2 47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9 8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

2

7 8 9

3

9

2 3

7 9 61 2

7 9 4

6

2

4

53 6 9

2

56

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 254

Page 255: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8 3 6

9

269

57

67 9

5 67 9

369

25 6

359 1 7

2694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 6 7 9

3

9 8 2 53

7

5 9 2 47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9 8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

2

7 8 9

3

9

2 3

7 9 61 2

7 9 4

9

2

4

53 6 9

2

56 9

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 255

Page 256: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8

2 359

369

2 369

57

67 9

5 67 9

369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

5

2

4

53 6 9

2

56 9

3 5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 256

Page 257: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 1 8

2 359

369

2 369

57

67 9

5 67 9

369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

5 6 594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

958

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

9

2

4

53 6 9

2

56 9

3 5 9

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 257

Page 258: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8

2 359

369

2 369

15

7

16

7 95 6

7 9369

25 6

359 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

4

53 6 9

2

56 9

3 5 9

1

42

Back to Start Skip Animation

Helmut Simonis Introduction to CP 258

Page 259: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 3

369

369

15

7

16

7 95 6

7 9369

5 63

59 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

4

53 6 9

2

56 9

3 5 9

1

4

53

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 259

Page 260: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 3 6

969

15

7

16

7 95 6

7 9369

5 63

59 1 7

2694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 6 7 9

3

9 8 2 53

7

5 9 2 47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9 8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2

7 8 9

3

9

2 3

7 9 61 2

7 9 4

6

2

4

53 6 9

2

56 9

3 5 9

1

4

56

3

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 260

Page 261: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 3 6

969

15

7

16

7 95 6

7 9369

5 63

59 1 7

2694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 6 7 9

3

9 8 2 53

7

5 9 2 47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9 8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2

7 8 9

3

9

2 3

7 9 61 2

7 9 4

9

2

4

53 6 9

2

56 9

3 5 9

1

4

56 9

3

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 261

Page 262: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 5

369

369

15

7

16

7 95 6

7 9369

5 63

59 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594 5

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

2

4

53 6 9

2

56 9

3 5 9

1

4

56 9

3

55

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 262

Page 263: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 5

369

369

1

7

16

7 96

7 9369

5 63

59 1 7

2 3694 58

69

5 68 9

67 9

15 6

1594

9 8 69

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34

1 3

7

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5369

1 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9

2 3

7 9 61 2

7 9 4

3

2

4

53 6 9

2

56 9

3 5 9

1

4

56 9

3

53

5

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 263

Page 264: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 5 6 3

1

7

16

7 96

7 9369

5 63

59 1 7 2 4 5

869

5 68 9

67 9

15 6

159 4 8 9

14 57 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

47

34 1

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5 61 3

8

1

9

3

8 9369

5 68

359

2 3

7 8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

7 8 9

3

9 7 61 2

7 9 4

2

4

53 6 9

2

56 9

3 5 9

1

4

56 9

3

53

76

5

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 264

Page 265: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 5 6 3 1

1

7 9 7 9369

5 63

59 1 7 2 4 5

869

5 68 9

67

15 6

15 4 8 9

15

7 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7

34 1

3

7 836

7

8 3 7 6 2 5 9 4 12 7

1 34

9

3

8 9 5 61 3

8

1

9

3

8 9369

5 68

359

2 3

8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

1 359

2 3

8 9

3

9 7 61 2

9 4

2

4

53 6 9

2

56 9

3 5 9

1

4

56 9

3

53

7

81

6

5

2

Back to Start Skip Animation

Helmut Simonis Introduction to CP 265

Page 266: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Forward Checking)4 2 8 5 6 3 1 7 93 5 9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6 3 9 8 2 5 75 9 2 7 4 1 3 8 68 3 7 6 2 5 9 4 12 7 4 9 5 6 8 1 36 8 3 2 1 4 7 9 59 1 5 8 3 7 6 2 4

2

4

53 6 9

2

56 9

3 5 9

1

4

56 9

3

53

7

87

1

6

5

2

Back to Start

Helmut Simonis Introduction to CP 266

Page 267: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Bounds Consistency)4

1 2

8 5 62 3 1

7

1

7 9 7 93

9

25

3

9 1 72 3

4 58

69

58 9

7 615 4 8 9

15 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

7

34 1

3

7 8 68 3 7 6 2 5 9 4 12 7 4

3

8 9 5 61 3

8

1

9

3

8 9

6 58

3

9

2 3

8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

15

2

8

3

9 7 61 2

4

2

Skip Animation

Helmut Simonis Introduction to CP 267

Page 268: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Bounds Consistency)4

1 2

8 5 62 3 1

7

1

7 9 7 93

9

25

3

9 1 72 3

4 58

69

58 9

7 615 4 8 9

15 3 2

1 4 63

7 9

3

9 8 2 53

7

5 9 23

7

34 1

3

7 8 68 3 7 6 2 5 9 4 12 7 4

3

8 9 5 61 3

8

1

9

3

8 9

6 58

3

9

2 3

8 9 1 43

57 8

2

7 9

35

7 8 93

9

158

15

2

8

3

9 7 61 2

4

1

21

Back to Start Skip Animation

Helmut Simonis Introduction to CP 268

Page 269: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Bounds Consistency)4 2 8 5 6 3 1

1

7 9 7 93

9 53

9 1 7 2 4 6 58 9

7 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7

34 1

3

7 8 68 3 7 6 2 5 9 4 12 7 4

3

8 9 5 6 8 13

8 9

6 83

9 2 1 43

57 8

2

7 9 53

9 1 5 83

9 7 6 2 4

21

82

Back to Start Skip Animation

Helmut Simonis Introduction to CP 269

Page 270: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Bounds Consistency)4 2 8 5 6 3 1 7 93 5 9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6 3 9 8 2 5 75 9 2 7 4 1 3 8 68 3 7 6 2 5 9 4 12 7 4 9 5 6 8 1 36 8 3 2 1 4 7 9 59 1 5 8 3 7 6 2 4

21

87

2

Back to Start

Helmut Simonis Introduction to CP 270

Page 271: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Domain Consistency)4 2 8 5 6 3 1 7 9 7 9

3

9 53

9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6

3

7 9

3

9 8 2 53

7

5 9 23

7 4 13

7 8 68 3 7 6 2 5 9 4 12 7 4

3

9 5 6 8 13

9

6 83

9 2 1 43

7 7 9 53

9 1 5 83

9 7 6 2 4

8

Skip Animation

Helmut Simonis Introduction to CP 271

Page 272: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Search Tree (Domain Consistency)4 2 8 5 6 3 1 7 93 5 9 1 7 2 4 6 87 6 1 4 8 9 5 3 21 4 6 3 9 8 2 5 75 9 2 7 4 1 3 8 68 3 7 6 2 5 9 4 12 7 4 9 5 6 8 1 36 8 3 2 1 4 7 9 59 1 5 8 3 7 6 2 4

87

Back to Start

Helmut Simonis Introduction to CP 272

Page 273: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Tradeoff: nodes and effort

How many nodes do we need to explore?How much effort do we spend in each node?Extreme 1: SAT, do very little reasoning in each node, butdo many nodes very rapidlyExtreme 2: MIP, do a lot of reasoning in root node, and ineach node, reduce number of nodes to exploreConstraint Programming: Choice of balance tuneable forproblem

Helmut Simonis Introduction to CP 273

Page 274: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Global Constraint Catalog

http://www.emn.fr/z-info/sdemasse/gccat/index.html

Description of 399 global constraints, 3250 pagesNot all of them are widely usedDetailed, meta-data description of constraints in Prolog

Helmut Simonis Introduction to CP 274

Page 275: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Key Global Constraints

alldifferent

cumulative

cycle

diffn

element

global_cardinality

minimum_weight_alldifferent

nvalue

sort

Helmut Simonis Introduction to CP 275

Page 276: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

alldifferent(L)

A collection of variables L are pairwise differentAlgorithm: Flow, refinementsUse: EverywhereSimilar: permutation, alldifferent_except_0,lex_alldifferent

Helmut Simonis Introduction to CP 276

Page 277: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

cumulative(Tasks, Limit)

A set of tasks with start times si , durations di and resourcerequirements ri do not exceed resource limit Limit at anytimeAlgorithm: compulsory parts, energy, edge-finding,not-first/not-lastUse: Scheduling, PlacementSimilar: disjunctive

Helmut Simonis Introduction to CP 277

Page 278: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

cycle(N, Succ)

A graph given by the successors si of nodes i contains NcyclesAlgorithm: alldifferent, strongly connectedcomponentsUse: Transportation, SchedulingSimilar: circuit, tree

Helmut Simonis Introduction to CP 278

Page 279: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

diffn(Obj)

n-dimensional objects given by orign < xi1, ..., xin > andsize < di1, ...,din > do not overlapAlgorithm: sweep, compulsory partsUse: placementSimilar: geost

Helmut Simonis Introduction to CP 279

Page 280: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

element(X, L, C)

C is the xth element of LAlgorithm: basicUse: functional dependencies, costSimilar: table

Helmut Simonis Introduction to CP 280

Page 281: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

global_cardinality(L, Values)

Count how often certain values occur in the collection ofvariables LAlgorithm: Flow, refinementsUse: TImetablingSimilar: generalizes alldifferent, among_seq

Helmut Simonis Introduction to CP 281

Page 282: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

minimum_weight_alldifferent(L, Matrix,Cost)

Cost is the cost of the assignment of the variables in L, thecost of each entry is given by the Matrix of cost values.The entries in L are pairwise different.Algorithm: Hungarian Method, Flow, SimplexUse: Resource allocationSimilar: global_cardinality_with_costs

Helmut Simonis Introduction to CP 282

Page 283: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

nvalue(N, L)

Count the number N of distinct values in a collection ofvariables LAlgorithm: specific, bounds-consistency onlyUse: Assignment problemsSimilar: same

Helmut Simonis Introduction to CP 283

Page 284: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

sort(L,K)

K is the sorted collection of the variables in LAlgorithm: specificUse: Building block for reformulation of other constraints

Helmut Simonis Introduction to CP 284

Page 285: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Why are there so many global constraints?

Algorithmic aspectMore specific restrictions allow more refined algorithms

Modelling aspectCapture exactly the properties of the problem we are after

Families of constraints, restrictions and generalizations

Helmut Simonis Introduction to CP 285

Page 286: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Constraint Programming to the rescue!

Constraint Seeker tool (Beldiceanu, Simonis 2011)http://seeker.mines-nantes.fr/

Given positive and negative examples, produce ranked listof possible matching global constraintsItself a collection of constraint programs

Helmut Simonis Introduction to CP 286

Page 287: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemInitial Propagation (Forward Checking)

Improved ReasoningSearch

Basis of modelling tool

Model Seeker (Beldiceanu, Simonis 2012)From positive sample solutions find potential models forproblemExpressed as conjunction of global constraintsFor highly structured problemsDo you have sample solutions?

Helmut Simonis Introduction to CP 287

Page 288: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Part III

Customizing Search

Helmut Simonis Introduction to CP 288

Page 289: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

What we want to introduce

Importance of search strategy, constraints alone are notenoughDynamic variable ordering exploits information frompropagationVariable and value choiceHard to find strategy which works all the timesearch builtin, flexible search abstractionDifferent way of improving stability of search routine

Helmut Simonis Introduction to CP 289

Page 290: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Example Problem

N-Queens puzzleRather weak constraint propagationMany solutions, limited number of symmetriesEasy to scale problem size

Helmut Simonis Introduction to CP 290

Page 291: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Outline

10 Problem

11 Program

12 Naive Search

13 Improvements

Helmut Simonis Introduction to CP 291

Page 292: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Problem Definition

8-QueensPlace 8 queens on an 8× 8 chessboard so that no queenattacks another. A queen attacks all cells in horizontal, verticaland diagonal direction. Generalizes to boards of size N × N.

Helmut Simonis Introduction to CP 292

Page 293: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Problem Definition

8-QueensPlace 8 queens on an 8× 8 chessboard so that no queenattacks another. A queen attacks all cells in horizontal, verticaland diagonal direction. Generalizes to boards of size N × N.

Solution for board size 8× 8

Helmut Simonis Introduction to CP 293

Page 294: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Model

Outline

10 Problem

11 ProgramModel

12 Naive Search

13 Improvements

Helmut Simonis Introduction to CP 294

Page 295: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Model

Basic Model

Cell based ModelA 0/1 variable for each cell to say if it is occupied or notConstraints on rows, columns and diagonals to enforceno-attackN2 variables, 6N − 2 constraints

Column (Row) based ModelA 1..N variable for each column, stating position of queen inthe columnBased on observation that each column must containexactly one queenN variables, N2/2 binary constraints

Helmut Simonis Introduction to CP 295

Page 296: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Model

Model

assign [X1,X2, ...XN ]

s.t.

∀1 ≤ i ≤ N : Xi ∈ 1..N∀1 ≤ i < j ≤ N : Xi 6= Xj

∀1 ≤ i < j ≤ N : Xi 6= Xj + i − j∀1 ≤ i < j ≤ N : Xi 6= Xj + j − i

Helmut Simonis Introduction to CP 296

Page 297: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Outline

10 Problem

11 Program

12 Naive Search

13 Improvements

Helmut Simonis Introduction to CP 297

Page 298: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

Skip Animation

Helmut Simonis Introduction to CP 298

Page 299: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

21

Back to Start Skip Animation

Helmut Simonis Introduction to CP 299

Page 300: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

33

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 300

Page 301: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 301

Page 302: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

46

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 302

Page 303: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42

6

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 303

Page 304: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 304

Page 305: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

47

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 305

Page 306: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

52

7

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 306

Page 307: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54

2

7

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 307

Page 308: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 308

Page 309: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

48

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 309

Page 310: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42

8

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 310

Page 311: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 311

Page 312: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

34

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 312

Page 313: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

42

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 313

Page 314: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45

2

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 314

Page 315: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7

2

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 315

Page 316: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 316

Page 317: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

46

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 317

Page 318: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43

6

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 318

Page 319: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 319

Page 320: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

47

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 320

Page 321: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

53

7

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 321

Page 322: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56

3

7

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 322

Page 323: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3

7

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 323

Page 324: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 324

Page 325: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

48

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 325

Page 326: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43

8

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 326

Page 327: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 327

Page 328: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

35

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 328

Page 329: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

42

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 329

Page 330: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

2

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 330

Page 331: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

58

2

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 331

Page 332: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53

8

2

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 332

Page 333: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 333

Page 334: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

47

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 334

Page 335: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

52

7

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 335

Page 336: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54

2

7

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 336

Page 337: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 337

Page 338: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

48

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 338

Page 339: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

52

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 339

Page 340: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54

2

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 340

Page 341: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 341

Page 342: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

56

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 342

Page 343: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

5

63

6

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 343

Page 344: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

5

6

77

3

6

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 344

Page 345: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

5

6

7

82

7

3

6

8

5

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 345

Page 346: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

5

6

7

84

2

7

3

6

8

5

1

Back to Start

Helmut Simonis Introduction to CP 346

Page 347: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

First Solution

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

3

45 7 8

2

43 8

6

4

56 8

3 5

7

43 5

8

4

3

46

53 6

8

2

4

54 6

2

7

4

54 7

2

5

6

7

84

2

7

3

6

8

5

1

Helmut Simonis Introduction to CP 347

Page 348: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Observations

Even for small problem size, tree can become largeNot interested in all detailsIgnore all automatically fixed variablesFor more compact representation abstract failed sub-trees

Helmut Simonis Introduction to CP 348

Page 349: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Compact Representation

Number inside triangle: Number of choicesNumber under triangle: Number of failures1

2

4

7

3

6

10

4

3

2

3

2

1

2

7

4

1

2

2 6

8

5

1

Helmut Simonis Introduction to CP 349

Page 350: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Exploring other board sizes

How stable is the model?Try all sizes from 4 to 100Timeout of 100 seconds

Helmut Simonis Introduction to CP 350

Page 351: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Naive Stategy, Problem Sizes 4-100

0

5

10

15

20

25

0 5 10 15 20 25 30

Tim

e[s]

Problem Size

"naive/all.txt"

Helmut Simonis Introduction to CP 351

Page 352: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Observations

Time very reasonable up to size 20Sizes 20-30 times very variableNot just linked to problem sizeNo size greater than 30 solved within timeout

Helmut Simonis Introduction to CP 352

Page 353: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Outline

10 Problem

11 Program

12 Naive Search

13 ImprovementsDynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Helmut Simonis Introduction to CP 353

Page 354: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Possible Improvements

Better constraint reasoningRemodelling problem with 3 alldifferent constraintsGlobal reasoning as described beforeNot explored here

Better control of searchStatic vs. dynamic variable orderingBetter value choiceNot using complete depth-first chronological backtracking

Helmut Simonis Introduction to CP 354

Page 355: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Static vs. Dynamic Variable Ordering

Heuristic Static OrderingSort variables before search based on heuristicMost important decisionsSmallest initial domain

Dynamic variable orderingUse information from constraint propagationDifferent orders in different parts of search treeUse all information available

Helmut Simonis Introduction to CP 355

Page 356: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

First Fail strategy

Dynamic variable orderingAt each step, select variable with smallest domainIdea: If there is a solution, better chance of finding itIdea: If there is no solution, smaller number of alternativesNeeds tie-breaking method

Helmut Simonis Introduction to CP 356

Page 357: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Modification of Program

:-module(nqueen).:-export(top/0).:-lib(ic).

top:-nqueen(8,L), writeln(L).

nqueen(N,L):-length(L,N),L :: 1..N,alldifferent(L),noattack(L),labeling(L).é replace with

Helmut Simonis Introduction to CP 357

Page 358: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Modification of Program

:-module(nqueen).:-export(top/0).:-lib(ic).

top:-nqueen(8,L), writeln(L).

nqueen(N,L):-length(L,N),L :: 1..N,alldifferent(L),noattack(L),search(L,0,first_fail,indomain,complete,[]).

Helmut Simonis Introduction to CP 358

Page 359: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Variable Choice

Determines the order in which variables are assignedinput_order assign variables in static order givenfirst_fail select variable with smallest domain firstmost_constrained like first_fail, tie break based onnumber of constraints in which variable occursOthers, including programmed selection

Helmut Simonis Introduction to CP 359

Page 360: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Value Choice

Determines the order in which values are tested forselected variablesindomain Start with smallest value, on backtracking trynext larger valueindomain_max Start with largest valueindomain_middle Start with value closest to middle ofdomainindomain_random Choose values in random order

Helmut Simonis Introduction to CP 360

Page 361: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Comparison

Board size 16x16Naive (Input Order) StrategyFirst Fail variable selection

Helmut Simonis Introduction to CP 361

Page 362: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Naive (Input Order) Strategy (Size 16)

1

2

3

4

5

145

209

4

188

322

8

197

358

9

173

292

10

200

326

11

184

282

12

6

7

4

8

4

8

13

6

9

15

12

8

2

3

4

94

1

2

8

104

118

127

16

6

15

12

14

9

13

2

5

3

1

Helmut Simonis Introduction to CP 362

Page 363: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

Skip Animation

Helmut Simonis Introduction to CP 363

Page 364: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

21

Back to Start Skip Animation

Helmut Simonis Introduction to CP 364

Page 365: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

33

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 365

Page 366: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

65

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 366

Page 367: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

84

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 367

Page 368: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

137

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 368

Page 369: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

116

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 369

Page 370: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

102

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 370

Page 371: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

913

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 371

Page 372: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

715

13

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 372

Page 373: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711

15

13

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 373

Page 374: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

13

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 374

Page 375: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

716

13

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 375

Page 376: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711

16

13

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 376

Page 377: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 377

Page 378: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

914

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 378

Page 379: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

14

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 379

Page 380: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

1416

14

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 380

Page 381: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

14

78

16

14

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 381

Page 382: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

14

710

8

16

14

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 382

Page 383: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

14

710 13

8

16

14

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 383

Page 384: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

14

710 13

8

129

16

14

2

6

7

4

5

3

1

Back to Start Skip Animation

Helmut Simonis Introduction to CP 384

Page 385: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

10

9

711 14

15

711 15

16

13

912

14

710 13

8

128

9

16

14

2

6

7

4

5

3

1

Back to Start

Helmut Simonis Introduction to CP 385

Page 386: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Comparing Solutions

Naive First Fail

Helmut Simonis Introduction to CP 386

Page 387: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Comparing Solutions

Naive First Fail

Solutions are different!

Helmut Simonis Introduction to CP 387

Page 388: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

FirstFail, Problem Sizes 4-100

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

0 10 20 30 40 50 60 70 80 90

Tim

e[s]

Problem Size

"first_fail/all.txt"

Helmut Simonis Introduction to CP 388

Page 389: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Observations

This is much betterBut some sizes are much harderTimeout for sizes 88, 91, 93, 97, 98, 99

Helmut Simonis Introduction to CP 389

Page 390: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Can we do better?

Improved initial orderingQueens on edges of board are easier to assignDo hard assignment first, keep simple choices for laterBegin assignment in middle of board

Matching value choiceValues in the middle of board have higher impactAssign these early at top of search treeUse indomain_middle for this

Helmut Simonis Introduction to CP 390

Page 391: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

Skip Animation

Helmut Simonis Introduction to CP 391

Page 392: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

88

Back to Start Skip Animation

Helmut Simonis Introduction to CP 392

Page 393: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

1210

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 393

Page 394: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

59

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 394

Page 395: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

146

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 395

Page 396: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

65

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 396

Page 397: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

44

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 397

Page 398: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 398

Page 399: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

311

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 399

Page 400: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1513

11

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 400

Page 401: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515

13

11

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 401

Page 402: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

11

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 402

Page 403: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

153

11

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 403

Page 404: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157

3

11

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 404

Page 405: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 405

Page 406: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

1616

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 406

Page 407: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

711

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 407

Page 408: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 408

Page 409: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

1115

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 409

Page 410: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

15

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 410

Page 411: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

1014

15

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 411

Page 412: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

102

14

15

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 412

Page 413: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

102 3

14

15

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 413

Page 414: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

102 3

14

15

151

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 414

Page 415: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

102 3

14

15

15

1115

1

11

16

4

5

6

9

10

8

Back to Start Skip Animation

Helmut Simonis Introduction to CP 415

Page 416: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Start from Middle (Size 16)

9

8

12

5

14

6

412

3

1515 7

13

157 1

3

11

16

77

113

102 3

14

15

15

113

15

1

11

16

4

5

6

9

10

8

Back to Start

Helmut Simonis Introduction to CP 416

Page 417: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Comparing Solutions

Naive First Fail Middle

Helmut Simonis Introduction to CP 417

Page 418: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Comparing Solutions

Naive First Fail Middle

Again, solutions are different!

Helmut Simonis Introduction to CP 418

Page 419: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Middle, Problem Sizes 4-100

0

5

10

15

20

25

30

35

0 10 20 30 40 50 60 70 80 90 100

Tim

e[s]

Problem Size

"middle/all.txt"

Helmut Simonis Introduction to CP 419

Page 420: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Observations

Not always better than first failFor size 16, trees are similar sizeTimeout only for size 94But still, one strategy does not work for all problem sizesThere are ways to resolve this!

Helmut Simonis Introduction to CP 420

Page 421: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Approach 1: Heuristic Portfolios

Try multiple strategies for the same problemWith multi-core CPUs, run them in parallelOnly one needs to be successful for each problem

Helmut Simonis Introduction to CP 421

Page 422: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Approach 2: Restart with Randomization

Only spend limited number of backtracks for a searchattemptWhen this limit is exceeded, restart at beginningRequires randomization to explore new search branchRandomize variable choice by random tie breakRandomize value choice by shuffling valuesNeeds strategy when to restart

Helmut Simonis Introduction to CP 422

Page 423: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Approach 3: Partial Search

Abandon depth-first, chronological backtrackingDon’t get locked into a failed sub-treeA wrong decision at a level is not detected, and we have toexplore the complete subtree below to undo that wrongchoiceExplore more of the search treeSpend time in promising parts of tree

Helmut Simonis Introduction to CP 423

Page 424: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Example: Credit Search

Explore top of tree completely, based on creditStart with fixed amount of creditEach node consumes one credit unitSplit remaining credit amongst childrenWhen credit runs out, start bounded backtrack searchEach branch can use only K backtracksIf this limit is exceeded, jump to unexplored top of tree

Helmut Simonis Introduction to CP 424

Page 425: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Credit, Search Tree Problem Size 9448

47

51

44

53

39

59

35

28

68

25

62

32

65

29

66

27

26

61

63

31

64

76

70

77

74

19

20

18

78

79

24

80

17

21

82

81

15

75

11

84

14

16

12

6

9

30

71

83

92

93

69

5

3

72

1

73

2

22

4

85

8

94

13

10

86

87

88

77

8989 17

84

86

7

8987 17

7

8989 17

5

3

75 84

88

83

8888

77

8989 17

3

86

4 87

18

87

88

77 84

86

77 5

3 88

17

7

91

8818 16

89 15

7

91

8818 16

91 15

5

4

75

8818 16

84

87

82

7

87

91

8818 16

89

83

7

5

13

81

78

12

80

9

79

72

27

76

20

19

70

75

74

69

24

22

23

28

67

21

71

25

73

29

65

68

61

26

31

30

66

64

32

63

33

34

62

35

60

58

36

38

59

57

37

56

39

53

55

40

29

66

27

26

61

63

67

70

19

72

77

76

74

17

18

78

16

15

21

75

81

12

20

79

36

22

14

80

13

71

10

83

84

94

82

92

91

23

93

24

90

4

73

2

11

5

3

85

9

8

86

87

88

784 10

4

784 85

91 3

82

88

784 10

83

784 2

91

710 2

3

5

88

784 2

4

784 85

83 3

90

88

72 85

91

710 85

83

4

80

87

6

8882 83

85 1

5

883 4

82

89

6

81

15

7

11

16

72

21

17

74

24

22

70

71

25

75

66

20

28

78

67

23

27

73

61

69

68

29

26

32

31

63

30

65

64

34

62

59

33

60

36

57

58

35

38

37

56

39

53

40

55

54

65

29

66

30

71

70

83

77

86

82

80

79

84

55

26

76

31

22

49

27

19

20

73

75

13

34

74

78

12

11

9

10

5

8

6

69

72

81

4

23

3

85

14

7

1

2

21

87

24

88

18

16

15

89

9085 17

5

91

90

92

93

94

17

33

56

67

61

54

50

52

58

36

46

41

42

43

40

37

452

38

57

60

63

647

3

91

5

2

93

92

9

89

8

86

84

6

90

11

85

80

83

87

14

10

94

13

88

78

4

17

1

15

77

82

18

12

74

81

20

16

76

19

79

22

21

70

23

75

73

71

67

26

72

25

65

69

27

24

30

66

68

28

33

29

64

63

62

61

37

32

31

36

60

34

35

59

39

57

53

38

58

56

40

54

55

41

42

50

52

43

51

46

44

45

48

49

47

Helmut Simonis Introduction to CP 425

Page 426: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Credit, Problem Sizes 4-200

0

0.5

1

1.5

2

2.5

0 50 100 150 200

Tim

e[s]

Problem Size

"credit/all.txt"

Helmut Simonis Introduction to CP 426

Page 427: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

ProblemProgram

Naive SearchImprovements

Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Points to Remember

Choice of search can have huge impact on performanceDynamic variable selection can lead to large reduction ofsearch spacePackaged search can do a lot, but programming searchadds even moreDepth-first chronologicial backtracking not always bestchoiceHow to control this explosion of search alternatives?

Helmut Simonis Introduction to CP 427

Page 428: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Part IV

What is missing?

Helmut Simonis Introduction to CP 428

Page 429: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Many Specialized Topics

How to design efficient core engineHybrids with LP/MIP toolsHybrids with SATSymmetry breakingUse of MDD/BDD to encode sets of solutionsHigh level modelling toolsDebugging/visualization

Helmut Simonis Introduction to CP 429

Page 430: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Reformulation

Just because the user has modelled it this way, it doesn’tmean we have to solve it that way

Replace some constraint(s) by other, equivalent constraintsBecause we don’t have that constraint in our systemFor performance

Helmut Simonis Introduction to CP 430

Page 431: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Learning

While solving the problem we can learn how to strengthenthe model/search

Understand which constraints/method contribute topropagation and change scheduleLearn no-good constraints by explaining failureAdapt search strategy based on search experience

Helmut Simonis Introduction to CP 431

Page 432: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

Refined Process

Problem

Human

User Model

Reformulation

Implementation Model

Constraint Solver/Search

SolutionHelmut Simonis Introduction to CP 432

Page 433: Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description of problems with Variables which range over (finite) sets of values Constraints

What is CP actually used for?

http://hsimonis.wordpress.com

Helmut Simonis Introduction to CP 433