Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description...
Transcript of Introduction to Constraint ProgrammingConstraint Programming - in a nutshell Declarative description...
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
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
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
Objectives
Overview of Core Constraint ProgrammingThree Main Concepts
Constraint PropagationGlobal ConstraintsCustomizing Search
Based on Examples, not Formal Description
Helmut Simonis Introduction to CP 4
Outline
Why Constraint Programming?Constraint PropagationGlobal ConstraintsCustomizing SearchWhat is missing?
Helmut Simonis Introduction to CP 5
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
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
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
Basic Process
Problem
Human
Model
Constraint Solver/Search
Solution
Helmut Simonis Introduction to CP 9
More Realistic
Problem
Human
Model
Constraint Solver/Search
Hangs Solution Wrong Solution
Helmut Simonis Introduction to CP 10
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
ProblemProgram
Constraint SetupSearch
Points to Remember
Part I
Basic Constraint Propagation
Helmut Simonis Introduction to CP 12
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemProgram
Constraint SetupSearch
Points to Remember
Question
But how did the program come up with this solution?
Helmut Simonis Introduction to CP 35
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemInitial Propagation (Forward Checking)
Improved ReasoningSearch
Part II
Global Constraints
Helmut Simonis Introduction to CP 143
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemInitial Propagation (Forward Checking)
Improved ReasoningSearch
Domain ConsistencyComparison
Another Simple Example
Can we deduce this without enumeratingsolutions?
Helmut Simonis Introduction to CP 206
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemProgram
Naive SearchImprovements
Part III
Customizing Search
Helmut Simonis Introduction to CP 288
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
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
ProblemProgram
Naive SearchImprovements
Outline
10 Problem
11 Program
12 Naive Search
13 Improvements
Helmut Simonis Introduction to CP 291
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
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
ProblemProgram
Naive SearchImprovements
Model
Outline
10 Problem
11 ProgramModel
12 Naive Search
13 Improvements
Helmut Simonis Introduction to CP 294
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
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
ProblemProgram
Naive SearchImprovements
Outline
10 Problem
11 Program
12 Naive Search
13 Improvements
Helmut Simonis Introduction to CP 297
ProblemProgram
Naive SearchImprovements
Default Strategy
1
Skip Animation
Helmut Simonis Introduction to CP 298
ProblemProgram
Naive SearchImprovements
Default Strategy
1
21
Back to Start Skip Animation
Helmut Simonis Introduction to CP 299
ProblemProgram
Naive SearchImprovements
Default Strategy
1
2
33
1
Back to Start Skip Animation
Helmut Simonis Introduction to CP 300
ProblemProgram
Naive SearchImprovements
Default Strategy
1
2
35
3
1
Back to Start Skip Animation
Helmut Simonis Introduction to CP 301
ProblemProgram
Naive SearchImprovements
Default Strategy
1
2
35
46
3
1
Back to Start Skip Animation
Helmut Simonis Introduction to CP 302
ProblemProgram
Naive SearchImprovements
Default Strategy
1
2
35
42
6
3
1
Back to Start Skip Animation
Helmut Simonis Introduction to CP 303
ProblemProgram
Naive SearchImprovements
Default Strategy
1
2
35
42 8
6
3
1
Back to Start Skip Animation
Helmut Simonis Introduction to CP 304
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemProgram
Naive SearchImprovements
Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable
FirstFail Strategy (Size 16)
1
Skip Animation
Helmut Simonis Introduction to CP 363
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemProgram
Naive SearchImprovements
Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable
Comparing Solutions
Naive First Fail
Helmut Simonis Introduction to CP 386
ProblemProgram
Naive SearchImprovements
Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable
Comparing Solutions
Naive First Fail
Solutions are different!
Helmut Simonis Introduction to CP 387
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
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
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
ProblemProgram
Naive SearchImprovements
Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable
Start from Middle (Size 16)
9
Skip Animation
Helmut Simonis Introduction to CP 391
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ProblemProgram
Naive SearchImprovements
Dynamic Variable ChoiceImproved HeuristicsMaking Search More Stable
Comparing Solutions
Naive First Fail Middle
Helmut Simonis Introduction to CP 417
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
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
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
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
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
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
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
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
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
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
Part IV
What is missing?
Helmut Simonis Introduction to CP 428
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
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
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
Refined Process
Problem
Human
User Model
Reformulation
Implementation Model
Constraint Solver/Search
SolutionHelmut Simonis Introduction to CP 432
What is CP actually used for?
http://hsimonis.wordpress.com
Helmut Simonis Introduction to CP 433