Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP...

427
Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016

Transcript of Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP...

Page 1: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Introduction to ConstraintProgramming

Helmut Simonis

ACP Summerschool, June 20th, 2016

Page 2: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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.

Insight Centre for Data Analytics Slide 2June 20th, 2016

Page 3: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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.

Insight Centre for Data Analytics Slide 3June 20th, 2016

Page 4: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Objectives

• Overview of Core Constraint Programming• Three Main Concepts

• Constraint Propagation• Global Constraints• Customizing Search

• Based on Examples, not Formal Description

Insight Centre for Data Analytics Slide 4June 20th, 2016

Page 5: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

• Why Constraint Programming?

• Constraint Propagation

• Global Constraints

• Customizing Search

• What is missing?

Insight Centre for Data Analytics Slide 5June 20th, 2016

Page 6: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Examples in ECLiPSe

• Open sourced constraint programming language

• Development goes back to 1985

• ECRC, ICL, IC-Parc, PTL, Cisco

• http://www.eclipse-clp.org/

• Specialities• Develop new solvers for specific domains• Integration with MIP

Insight Centre for Data Analytics Slide 6June 20th, 2016

Page 7: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

ECLiPSe ELearning Course

• Self-study course in constraint programming

• Supported by Cisco Systems and Silicon ValleyCommunity Foundation

• Multi-media format, video lectures, slides, handout etc

• http://4c.ucc.ie/~hsimonis/ELearning/index.htm

Insight Centre for Data Analytics Slide 7June 20th, 2016

Page 8: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Constraint Programming - in a nutshell

• Declarative description of problems with• Variableswhich range over (finite) sets of values• Constraints over subsets of variables which restrict

possible value combinations• A solution is a value assignment which satisfies all

constraints

• Constraint propagation/reasoning• Removing inconsistent values for variables• Detect failure if constraint can not be satisfied• Interaction of constraints via shared variables• Incomplete

• Search• User controlled assignment of values to variables• Each step triggers constraint propagation

• Different domains require/allow different methods

Insight Centre for Data Analytics Slide 8June 20th, 2016

Page 9: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Basic Process

Problem

Human

Model

Constraint Solver/Search

Solution

Insight Centre for Data Analytics Slide 9June 20th, 2016

Page 10: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

More Realistic

Problem

Human

Model

Constraint Solver/Search

Hangs Solution Wrong Solution

Insight Centre for Data Analytics Slide 10June 20th, 2016

Page 11: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Dual Role of Model

• Allows Human to Express Problem• Close to Problem Domain• Constraints as Abstractions

• Allows Solver to Execute• Variables as Communication Mechanism• Constraints as Algorithms

Insight Centre for Data Analytics Slide 11June 20th, 2016

Page 12: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Modelling Frameworks

• MiniZinc (NICTA, Australia)

• NumberJack (Insight, Ireland)

• Essence (UK)

• Allow use of multiple back-end solvers

• Compile model into variants for each solver

• A priori solver independent model(CP, MIP, SAT)

Insight Centre for Data Analytics Slide 12June 20th, 2016

Page 13: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Framework Process

Problem

Human

Model

Compile/Reformulate

CP MIP SAT Other

Solution Solution Solution Solution

Insight Centre for Data Analytics Slide 13June 20th, 2016

Page 14: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Part I

Basic Constraint Propagation

Insight Centre for Data Analytics Slide 14June 20th, 2016

Page 15: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Example 1: SEND+MORE=MONEY

• Example of Finite Domain Constraint Problem

• Models and Programs

• Constraint Propagation and Search

• Some Basic Constraints: linear arithmetic, alldifferent,disequality

• A Built-in search

• Visualizers for variables, constraints and search

Insight Centre for Data Analytics Slide 15June 20th, 2016

Page 16: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Constraint Setup

Search

Points to Remember

Insight Centre for Data Analytics Slide 16June 20th, 2016

Page 17: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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-writtenaddition:

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

Insight Centre for Data Analytics Slide 17June 20th, 2016

Page 18: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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.

Insight Centre for Data Analytics Slide 18June 20th, 2016

Page 19: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Constraint Setup

Search

Points to Remember

Insight Centre for Data Analytics Slide 19June 20th, 2016

Page 20: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 beginningof a number can not take the value 0.

• An arithmetic equality constraint linking all variables withthe proper coefficients and stating that the equationmust hold.

Insight Centre for Data Analytics Slide 20June 20th, 2016

Page 21: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 22: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 23: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Program Sendmory

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

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 24: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 25: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 26: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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..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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 27: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 28: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 29: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 30: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 31: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 21June 20th, 2016

Page 32: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 22June 20th, 2016

Page 33: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 22June 20th, 2016

Page 34: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 22June 20th, 2016

Page 35: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Choice of Model

• This is onemodel, not themodel of the problem

• Many possible alternatives• Choice often depends on your constraint system

• Constraints available• Reasoning attached to constraints

• Not always clear which is the bestmodel

• Often: Not clear what is the problem

Insight Centre for Data Analytics Slide 23June 20th, 2016

Page 36: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Running the program

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

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

Insight Centre for Data Analytics Slide 24June 20th, 2016

Page 37: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Example in NumberJack

from Numberjack import *def get_model():

model = Model()s, m = (Variable(1, 9) for val in range(2))e, n, d, o, r, y =

(Variable(0, 9) for val in range(6))model.add( s*1000 + e*100 + n*10 + d +

m*1000 + o*100 + r*10 + e ==m*10000 + o*1000 + n*100 + e*10 + y)

model.add(AllDiff((s, e, n, d, m, o, r, y)))return s, e, n, d, m, o, r, y, model

def solve(param):s, e, n, d, m, o, r, y, model = get_model()solver = model.load(param[’solver’])solver.setVerbosity(param[’verbose’])solver.solve()

Insight Centre for Data Analytics Slide 25June 20th, 2016

Page 38: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

MiniZinc

include "alldifferent.mzn";

var 1..9: S;var 0..9: E;var 0..9: N;var 0..9: D;var 1..9: M;var 0..9: O;var 0..9: R;var 0..9: Y;constraint 1000 * S + 100 * E + 10 * N + D

+ 1000 * M + 100 * O + 10 * R + E= 10000 * M + 1000 * O + 100 * N + 10 * E + Y;

constraint alldifferent([S,E,N,D,M,O,R,Y]);

solve satisfy;

Insight Centre for Data Analytics Slide 26June 20th, 2016

Page 39: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

JSR331 (Standardized JAVA Solver Interface)

public class SendMoreMoney extends Problem {public void define() {Var S = variable( "S",1, 9);Var E = variable( "E",0, 9);Var N = variable( "N",0, 9);Var D = variable( "D",0, 9);Var M = variable( "M",1, 9);Var O = variable( "O",0, 9);Var R = variable( "R",0, 9);Var Y = variable( "Y",0, 9);Var[] vars = new Var[] { S, E, N, D, M, O, R, Y };postAllDiff(vars);int coef[] = { 1000, 100, 10, 1, 1000, 100, 10, 1,

-10000, -1000, -100, -10, -1 };Var[] sendmoremoney = new Var[] { S, E, N, D,

M, O, R, E, M, O, N, E, Y};post(coef, sendmoremoney, "=", 0);

}Insight Centre for Data Analytics Slide 27June 20th, 2016

Page 40: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

JSR331 (II)

package org.jcp.jsr331.samples;import javax.constraints.Solution;import javax.constraints.SolutionIterator;import javax.constraints.Var;import javax.constraints.impl.Problem;

public void solve() {Solution s = getSolver().findSolution();

}

public static void main(String[] args) {SendMoreMoney p = new SendMoreMoney();p.define();p.solve();

}}

Insight Centre for Data Analytics Slide 28June 20th, 2016

Page 41: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Question

• But how did the program come up with this solution?

Insight Centre for Data Analytics Slide 29June 20th, 2016

Page 42: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Constraint SetupDomain DefinitionAlldifferent ConstraintDisequality ConstraintsEquality Constraint

Search

Points to Remember

Insight Centre for Data Analytics Slide 30June 20th, 2016

Page 43: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domain Definition

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

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

Insight Centre for Data Analytics Slide 31June 20th, 2016

Page 44: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domain Visualization

0 1 2 3 4 5 6 7 8 9SENDMORY

Insight Centre for Data Analytics Slide 32June 20th, 2016

Page 45: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domain Visualization

Rows =Variables

0 1 2 3 4 5 6 7 8 9SENDMORY

Insight Centre for Data Analytics Slide 32June 20th, 2016

Page 46: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domain Visualization

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

SENDMORY

Insight Centre for Data Analytics Slide 32June 20th, 2016

Page 47: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domain Visualization

Cells= State

0 1 2 3 4 5 6 7 8 9SENDMORY

Insight Centre for Data Analytics Slide 32June 20th, 2016

Page 48: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Alldifferent Constraint

alldifferent(L),

• Built-in of ic library

• No initial propagation possible

• Suspends, waits until variables are changed

• When variable is fixed, remove value from domain ofother variables

• Forward checking

Insight Centre for Data Analytics Slide 33June 20th, 2016

Page 49: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Alldifferent Visualization

Uses the same representation as the domain visualizer

0 1 2 3 4 5 6 7 8 9SENDMORY

Insight Centre for Data Analytics Slide 34June 20th, 2016

Page 50: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Disequality Constraints

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

Remove value from domain

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

Constraints solved, can be removed

Insight Centre for Data Analytics Slide 35June 20th, 2016

Page 51: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domains after Disequality

0 1 2 3 4 5 6 7 8 9SENDMORY

Insight Centre for Data Analytics Slide 36June 20th, 2016

Page 52: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Equality Constraint

• Normalization of linear terms• Single occurence of variable• Positive coefficients

• Propagation

Insight Centre for Data Analytics Slide 37June 20th, 2016

Page 53: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 54: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 55: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 56: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 57: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 58: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 59: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 60: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 61: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Normalization

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

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

Insight Centre for Data Analytics Slide 38June 20th, 2016

Page 62: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Simplified Equation

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

Insight Centre for Data Analytics Slide 39June 20th, 2016

Page 63: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation

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

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

Insight Centre for Data Analytics Slide 40June 20th, 2016

Page 64: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 40June 20th, 2016

Page 65: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 40June 20th, 2016

Page 66: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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}

Insight Centre for Data Analytics Slide 40June 20th, 2016

Page 67: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 40June 20th, 2016

Page 68: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 9000

• Rest of lhs (left hand side) (91 ∗ E0..9 + 10 ∗ R0..9 + D0..9)is atmost 918

• S must be greater or equal to 9000−9181000 = 8.082

• otherwise 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

Insight Centre for Data Analytics Slide 41June 20th, 2016

Page 69: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 9918

• Rest of rhs (right hand side) 900 ∗O0..9 + 90 ∗N0..9 + Y 0..9

is at least 0

• M must be smaller or equal to 9918−09000 = 1.102

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

• M has lower bound of 1, so M = 1

Insight Centre for Data Analytics Slide 42June 20th, 2016

Page 70: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 9918

• Rest of rhs (right hand side) 9000 ∗ 1 + 90 ∗ N0..9 + Y 0..9 isat least 9000

• O must be smaller or equal to 9918−9000900 = 1.02

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

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

Insight Centre for Data Analytics Slide 43June 20th, 2016

Page 71: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 44June 20th, 2016

Page 72: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 45June 20th, 2016

Page 73: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

E |N |D |M Y

OR |Y |

Insight Centre for Data Analytics Slide 45June 20th, 2016

Page 74: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

O |R |Y |

Insight Centre for Data Analytics Slide 45June 20th, 2016

Page 75: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

RY

Insight Centre for Data Analytics Slide 45June 20th, 2016

Page 76: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

R |Y |

Insight Centre for Data Analytics Slide 45June 20th, 2016

Page 77: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMORY

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

Insight Centre for Data Analytics Slide 45June 20th, 2016

Page 78: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Waking the equality constraint

• Triggered by assignment of variables

• or update of lower or upper bound

Insight Centre for Data Analytics Slide 46June 20th, 2016

Page 79: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Removal of constants

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

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

Insight Centre for Data Analytics Slide 47June 20th, 2016

Page 80: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Removal of constants

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

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

Insight Centre for Data Analytics Slide 47June 20th, 2016

Page 81: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Removal of constants

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

Insight Centre for Data Analytics Slide 47June 20th, 2016

Page 82: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 1)

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

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

Insight Centre for Data Analytics Slide 48June 20th, 2016

Page 83: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 1)

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

Insight Centre for Data Analytics Slide 48June 20th, 2016

Page 84: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 48June 20th, 2016

Page 85: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 2)

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

Insight Centre for Data Analytics Slide 49June 20th, 2016

Page 86: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 2)

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

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

Insight Centre for Data Analytics Slide 49June 20th, 2016

Page 87: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 2)

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

Insight Centre for Data Analytics Slide 49June 20th, 2016

Page 88: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 49June 20th, 2016

Page 89: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 3)

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

Insight Centre for Data Analytics Slide 50June 20th, 2016

Page 90: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 3)

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

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

Insight Centre for Data Analytics Slide 50June 20th, 2016

Page 91: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 3)

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

Insight Centre for Data Analytics Slide 50June 20th, 2016

Page 92: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 50June 20th, 2016

Page 93: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 4)

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

Insight Centre for Data Analytics Slide 51June 20th, 2016

Page 94: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 4)

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

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

Insight Centre for Data Analytics Slide 51June 20th, 2016

Page 95: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 4)

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

Insight Centre for Data Analytics Slide 51June 20th, 2016

Page 96: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 51June 20th, 2016

Page 97: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 5)

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

Insight Centre for Data Analytics Slide 52June 20th, 2016

Page 98: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 5)

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

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

Insight Centre for Data Analytics Slide 52June 20th, 2016

Page 99: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 5)

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

Insight Centre for Data Analytics Slide 52June 20th, 2016

Page 100: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 52June 20th, 2016

Page 101: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 6)

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

Insight Centre for Data Analytics Slide 53June 20th, 2016

Page 102: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 6)

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

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

Insight Centre for Data Analytics Slide 53June 20th, 2016

Page 103: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality (Iteration 6)

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

Insight Centre for Data Analytics Slide 53June 20th, 2016

Page 104: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 53June 20th, 2016

Page 105: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Domains after setup

0 1 2 3 4 5 6 7 8 9SENDMORY

Insight Centre for Data Analytics Slide 54June 20th, 2016

Page 106: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Constraint Setup

SearchStep 1Step 2Further StepsSolution

Points to Remember

Insight Centre for Data Analytics Slide 55June 20th, 2016

Page 107: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

labeling built-in

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

• Try variable is order given

• Try values starting from smallest value in domain

• When failing, backtrack to last open choice

• Chronological Backtracking

• Depth First search

Insight Centre for Data Analytics Slide 56June 20th, 2016

Page 108: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Search Tree Step 1

Variable S already fixed

S

E9

Insight Centre for Data Analytics Slide 57June 20th, 2016

Page 109: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Step 2, Alternative E = 4

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

S

E4

9

Insight Centre for Data Analytics Slide 58June 20th, 2016

Page 110: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Assignment E = 4

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

Insight Centre for Data Analytics Slide 59June 20th, 2016

Page 111: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of E = 4, equality constraint

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

Insight Centre for Data Analytics Slide 60June 20th, 2016

Page 112: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of E = 4, equality constraint

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

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

Insight Centre for Data Analytics Slide 60June 20th, 2016

Page 113: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of E = 4, equality constraint

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

Insight Centre for Data Analytics Slide 60June 20th, 2016

Page 114: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 60June 20th, 2016

Page 115: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Result of equality propagation

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

MOR - - - - - - Y

Y Y - - - - - -

Insight Centre for Data Analytics Slide 61June 20th, 2016

Page 116: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

MOR - - - - - - Y

Y Y - - - - - -

Insight Centre for Data Analytics Slide 62June 20th, 2016

Page 117: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

MOR - - - - - - Y

Y Y - - - - -

Alldifferent fails!

Insight Centre for Data Analytics Slide 62June 20th, 2016

Page 118: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Step 2, Alternative E = 5

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

S

E4

N5

9

Insight Centre for Data Analytics Slide 63June 20th, 2016

Page 119: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Assignment E = 5

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

Insight Centre for Data Analytics Slide 64June 20th, 2016

Page 120: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

Insight Centre for Data Analytics Slide 65June 20th, 2016

Page 121: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

N |D |MOR |Y |

Insight Centre for Data Analytics Slide 65June 20th, 2016

Page 122: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMORY

N 6= 5,N ≥ 6

Insight Centre for Data Analytics Slide 65June 20th, 2016

Page 123: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

Insight Centre for Data Analytics Slide 66June 20th, 2016

Page 124: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

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

Insight Centre for Data Analytics Slide 66June 20th, 2016

Page 125: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

Insight Centre for Data Analytics Slide 66June 20th, 2016

Page 126: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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}

Insight Centre for Data Analytics Slide 66June 20th, 2016

Page 127: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 67June 20th, 2016

Page 128: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 68June 20th, 2016

Page 129: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

Y

Insight Centre for Data Analytics Slide 68June 20th, 2016

Page 130: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

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

MORY

Insight Centre for Data Analytics Slide 68June 20th, 2016

Page 131: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of alldifferent

0 1 2 3 4 5 6 7 8 9SENDMORY

D = 7

Insight Centre for Data Analytics Slide 68June 20th, 2016

Page 132: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

Insight Centre for Data Analytics Slide 69June 20th, 2016

Page 133: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

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

Insight Centre for Data Analytics Slide 69June 20th, 2016

Page 134: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

Insight Centre for Data Analytics Slide 69June 20th, 2016

Page 135: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Propagation of equality

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

Y = 2

Insight Centre for Data Analytics Slide 69June 20th, 2016

Page 136: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Last propagation step

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

Insight Centre for Data Analytics Slide 70June 20th, 2016

Page 137: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 138: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N

D6

5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 139: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N

D

M7

6

5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 140: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N

D

M

O1

7

6

5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 141: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N

D

M

O

R0

1

7

6

5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 142: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N

D

M

O

R

Y8

0

1

7

6

5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 143: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Further Steps: Nothing more to do

S

E4

N

D

M

O

R

Y2

8

0

1

7

6

5

9

Insight Centre for Data Analytics Slide 71June 20th, 2016

Page 144: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Complete Search Tree

S

E4

N

D

M

O

R

Y2

8

0

1

7

6

5 6 7

9

Insight Centre for Data Analytics Slide 72June 20th, 2016

Page 145: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Solution

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

Insight Centre for Data Analytics Slide 73June 20th, 2016

Page 146: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Constraint Setup

Search

Points to Remember

Insight Centre for Data Analytics Slide 74June 20th, 2016

Page 147: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 anart.

• 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.

Insight Centre for Data Analytics Slide 75June 20th, 2016

Page 148: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Points to Remember

• Propagation usually is not sufficient, search may berequired to find a solution.

• Propagation is data driven, and can be quite complexeven for small examples.

• The default search uses chronological depth-firstbacktracking, systematically exploring the completesearch space.

• The search choices and propagation are interleaved, afterevery choice some more propagation may further reducethe problem.

Insight Centre for Data Analytics Slide 76June 20th, 2016

Page 149: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Part II

Global Constraints

Insight Centre for Data Analytics Slide 77June 20th, 2016

Page 150: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Example 2: Sudoku

• Global Constraints• Powerful modelling abstractions• Non-trivial propagation• Different consistency levels

• Example: Sudoku puzzle

Insight Centre for Data Analytics Slide 78June 20th, 2016

Page 151: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Initial Propagation (Forward Checking)

Improved Reasoning

Search

Insight Centre for Data Analytics Slide 79June 20th, 2016

Page 152: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 80June 20th, 2016

Page 153: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 80June 20th, 2016

Page 154: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Model

• A variable for each cell, ranging from 1 to 9

• A 9x9 matrix of variables describing the problem

• Preassigned integers for the given hints

• alldifferent constraints for each row, column and 3x3block

Insight Centre for Data Analytics Slide 81June 20th, 2016

Page 155: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Reminder: alldifferent

• Argument: list of variables

• Meaning: variables are pairwise different• Reasoning: Forward Checking (FC)

• When variable is assigned to value, remove the value fromall other variables

• If a variable has only one possible value, then it is assigned• If a variable has no possible values, then the constraint

fails• Constraint is checked whenever one of its variables is

assigned• Equivalent to decomposition into binary disequality

constraints

Insight Centre for Data Analytics Slide 82June 20th, 2016

Page 156: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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).

Insight Centre for Data Analytics Slide 83June 20th, 2016

Page 157: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 matrix

• Each cell corresponds to a variable

• Instantiated: Shows integer value (large)

• Uninstantiated: Shows values in domain

Insight Centre for Data Analytics Slide 84June 20th, 2016

Page 158: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Initial Propagation (Forward Checking)

Improved Reasoning

Search

Insight Centre for Data Analytics Slide 85June 20th, 2016

Page 159: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 86June 20th, 2016

Page 160: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 161: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 162: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 163: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 164: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 165: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 166: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 167: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 168: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 169: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 170: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 171: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 172: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 173: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 174: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 175: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 176: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 177: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 178: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 179: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 180: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 181: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 182: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 183: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 184: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 185: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 186: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 187: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 188: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start

Insight Centre for Data Analytics Slide 87June 20th, 2016

Page 189: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 88June 20th, 2016

Page 190: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Initial Propagation (Forward Checking)

Improved ReasoningDomain ConsistencyComparison

Search

Insight Centre for Data Analytics Slide 89June 20th, 2016

Page 191: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Can we do better?

• The alldifferent constraint is missing propagation• How can we do more propagation?• Do we know when we derive all possible information from

the constraint?

• Constraints only interact by changing domains ofvariables

Insight Centre for Data Analytics Slide 90June 20th, 2016

Page 192: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

A Simpler Example

:-lib(ic).

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

Insight Centre for Data Analytics Slide 91June 20th, 2016

Page 193: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Using Forward Checking

• No variable is assigned

• No reduction of domains

• But, values 1 and 2 can be removed from Z

• This means that Z is assigned to 3

Insight Centre for Data Analytics Slide 92June 20th, 2016

Page 194: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Visualization of alldifferent as Graph

X

Y

Z

1

2

3• Show problem as graph with two types of nodes

• Variables on the left• Values on the right

• If value is in domain of variable, show link between them

• This is called a bipartite graph

Insight Centre for Data Analytics Slide 93June 20th, 2016

Page 195: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

A Simpler Example

Value Graph for

X :: 1..2,

Y :: 1..2,

Z :: 1..3

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 94June 20th, 2016

Page 196: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

A Simpler Example

Check interval [1,2]X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 94June 20th, 2016

Page 197: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

A Simpler Example

• Find variables completelycontained in interval

• There are two: X and Y

• This uses up the capacity of theinterval

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 94June 20th, 2016

Page 198: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

A Simpler Example

No other variable can use thatinterval

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 94June 20th, 2016

Page 199: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

A Simpler Example

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

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 94June 20th, 2016

Page 200: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Idea (Hall Intervals)

• Take each interval of possible values, say size N• Find all K variables whose domain is completelycontained in interval

• If K > N then the constraint is infeasible

• If K = N then no other variable can use that interval

• Remove values from such variables if their bounds change

• If K < N do nothing

• Re-check whenever domain bounds change

Insight Centre for Data Analytics Slide 95June 20th, 2016

Page 201: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Implementation

• Problem: Too many intervals (O(n2)) to consider• Solution:

• Check only those intervals which update bounds• Enumerate intervals incrementally• Starting from lowest(highest) value• Using sorted list of variables

• Complexity: O(n log(n)) in standard implementations

• Important: Only looks at min/max bounds of variables

Insight Centre for Data Analytics Slide 96June 20th, 2016

Page 202: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Bounds Consistency

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

Insight Centre for Data Analytics Slide 97June 20th, 2016

Page 203: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Can we do better?

• Bounds consistency only considers min/max bounds

• Ignores ‘‘holes’’ in domain

• Sometimes we can improve propagation looking at thoseholes

Insight Centre for Data Analytics Slide 98June 20th, 2016

Page 204: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

:-lib(ic).

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

Insight Centre for Data Analytics Slide 99June 20th, 2016

Page 205: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

Value Graph for

X :: [1,3],

Y :: [1,3],

Z :: 1..3

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 206: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

• Check interval [1,2]

• No domain of a variablecompletely contained in interval

• No propagation

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 207: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

• Check interval [2,3]

• No domain of a variablecompletely contained in interval

• No propagation

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 208: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

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

X

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 209: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

Solution 1: assignment in blueX

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 210: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

Solution 2: assignment in greenX

Y

Z

1

2

3

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 211: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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.

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 212: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Another Simple Example

Can we deduce this without enumeratingsolutions?

Insight Centre for Data Analytics Slide 100June 20th, 2016

Page 213: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Solutions and maximal matchings

• AMatching is subset of edges which do not coincide inany node

• No matching can have more edges than number ofvariables

• Every solution corresponds to amaximal matching andvice versa

• If a link does not belong to some maximal matching, thenit can be removed

Insight Centre for Data Analytics Slide 101June 20th, 2016

Page 214: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Implementation

• Possible to compute all links which belong to somematching

• Without enumerating all of them!

• Enough to compute one maximal matching

• Requires algorithm for strongly connected components

• Extra work required if more values than variables

• All links (values in domains) which are not supported canbe removed

• Complexity: O(n1.5d)

Insight Centre for Data Analytics Slide 102June 20th, 2016

Page 215: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 103June 20th, 2016

Page 216: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Can we still do better?

• NO! This extracts all information from this one constraint

• We could perhaps improve speed, but not propagation

• But possible to use different model

• Or model interaction of multiple constraints

Insight Centre for Data Analytics Slide 104June 20th, 2016

Page 217: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Should all constraints achieve domain consistency?

• Domain consistency is usually more expensive thanbounds consistency

• Overkill for simple problems• Nice to have choices

• For some constraints achieving domain consistency isNP-hard

• We have to live with more restricted propagation

Insight Centre for Data Analytics Slide 105June 20th, 2016

Page 218: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 106June 20th, 2016

Page 219: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 220: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 221: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 222: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 223: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 224: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 225: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 226: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 227: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 228: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 229: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 230: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 231: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 232: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 233: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 234: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 235: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 236: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 237: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 238: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 239: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 240: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 241: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 242: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 243: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 244: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 245: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 246: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 247: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 4

Back to Start

Insight Centre for Data Analytics Slide 107June 20th, 2016

Page 248: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 108June 20th, 2016

Page 249: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 109June 20th, 2016

Page 250: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Typical?

• This does not always happen

• Sometimes, two methods produce same amount ofpropagation

• Possible to predict in certain special cases

• In general, tradeoff between speed and propagation

• Not always fastest to remove inconsistent values early

• But often required to find a solution at all

Insight Centre for Data Analytics Slide 110June 20th, 2016

Page 251: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Initial Propagation (Forward Checking)

Improved Reasoning

Search

Insight Centre for Data Analytics Slide 111June 20th, 2016

Page 252: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Simple search routine

• Enumerate variables in given order

• Try values starting from smallest one in domain

• Complete, chronological backtracking

Insight Centre for Data Analytics Slide 112June 20th, 2016

Page 253: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 254: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 255: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 256: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 257: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 258: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 259: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 260: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 261: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 262: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 263: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 264: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 265: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 266: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 267: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 268: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 269: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 270: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 271: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 272: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 StartInsight Centre for Data Analytics Slide 113June 20th, 2016

Page 273: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 114June 20th, 2016

Page 274: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 114June 20th, 2016

Page 275: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 114June 20th, 2016

Page 276: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 StartInsight Centre for Data Analytics Slide 114June 20th, 2016

Page 277: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 AnimationInsight Centre for Data Analytics Slide 115June 20th, 2016

Page 278: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 StartInsight Centre for Data Analytics Slide 115June 20th, 2016

Page 279: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Global Constraint Catalog

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

• Description of 354 global constraints, 2800 pages

• Not all of them are widely used

• Detailed, meta-data description of constraints in Prolog

Insight Centre for Data Analytics Slide 116June 20th, 2016

Page 280: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Families of Global Constraints

• Value Counting• alldifferent, global cardinality

• Scheduling• cumulative

• Properties of Sequences• sequence, no_valley

• Graph Properties• circuit,tree

Insight Centre for Data Analytics Slide 117June 20th, 2016

Page 281: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Common Algorithmic Techniques

• Flow Based Algorithms

• Automata

• Task Intervals

• Reduced Cost Filtering

• Decomposition

Insight Centre for Data Analytics Slide 118June 20th, 2016

Page 282: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Part III

Customizing Search

Insight Centre for Data Analytics Slide 119June 20th, 2016

Page 283: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

What we want to introduce

• Importance of search strategy, constraints alone are notenough

• Dynamic variable ordering exploits information frompropagation

• Variable and value choice

• Hard to find strategy which works all the time

• search builtin, flexible search abstraction

• Different way of improving stability of search routine

Insight Centre for Data Analytics Slide 120June 20th, 2016

Page 284: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Example Problem

• N-Queens puzzle

• Rather weak constraint propagation

• Many solutions, limited number of symmetries

• Easy to scale problem size

Insight Centre for Data Analytics Slide 121June 20th, 2016

Page 285: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Naive Search

Improvements

Insight Centre for Data Analytics Slide 122June 20th, 2016

Page 286: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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 .

Insight Centre for Data Analytics Slide 123June 20th, 2016

Page 287: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 123June 20th, 2016

Page 288: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

ProgramModel

Naive Search

Improvements

Insight Centre for Data Analytics Slide 124June 20th, 2016

Page 289: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Basic Model

• Cell based Model• A 0/1 variable for each cell to say if it is occupied or not• Constraints on rows, columns and diagonals to enforce

no-attack• N2 variables, 6N − 2 constraints

• Column (Row) based Model• A 1..N variable for each column, stating position of queen

in the column• Based on observation that each column must contain

exactly one queen• N variables, N2/2 binary constraints

Insight Centre for Data Analytics Slide 125June 20th, 2016

Page 290: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 126June 20th, 2016

Page 291: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Naive Search

Improvements

Insight Centre for Data Analytics Slide 127June 20th, 2016

Page 292: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 293: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

21

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 294: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

33

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 295: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 296: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

46

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 297: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42

6

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 298: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 299: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

47

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 300: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

52

7

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 301: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

54

2

7

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 302: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 303: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

48

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 304: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42

8

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 305: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 306: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Default Strategy

1

2

35

42 8

6

4

54 8

2

7

42 6

8

3

34

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 307: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 308: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 309: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 310: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 311: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 312: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 313: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 314: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 315: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 316: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 317: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 318: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 319: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 320: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 321: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 322: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 323: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 324: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 325: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 326: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 327: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 328: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 329: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 330: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 331: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 332: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 333: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 334: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 335: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 336: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 337: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 338: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 339: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 340: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 128June 20th, 2016

Page 341: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 129June 20th, 2016

Page 342: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Observations

• Even for small problem size, tree can become large

• Not interested in all details

• Ignore all automatically fixed variables

• For more compact representation abstract failedsub-trees

Insight Centre for Data Analytics Slide 130June 20th, 2016

Page 343: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 131June 20th, 2016

Page 344: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Exploring other board sizes

• How stable is the model?

• Try all sizes from 4 to 100

• Timeout of 100 seconds

Insight Centre for Data Analytics Slide 132June 20th, 2016

Page 345: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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"

Insight Centre for Data Analytics Slide 133June 20th, 2016

Page 346: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Observations

• Time very reasonable up to size 20

• Sizes 20-30 times very variable

• Not just linked to problem size

• No size greater than 30 solved within timeout

Insight Centre for Data Analytics Slide 134June 20th, 2016

Page 347: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Outline

Problem

Program

Naive Search

ImprovementsDynamic Variable ChoiceImproved HeuristicsMaking Search More Stable

Insight Centre for Data Analytics Slide 135June 20th, 2016

Page 348: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Possible Improvements

• Better constraint reasoning• Remodelling problem with 3 alldifferent constraints• Global reasoning as described before• Not explored here

• Better control of search• Static vs. dynamic variable ordering• Better value choice• Not using complete depth-first chronological backtracking

Insight Centre for Data Analytics Slide 136June 20th, 2016

Page 349: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Static vs. Dynamic Variable Ordering

• Heuristic Static Ordering• Sort variables before search based on heuristic• Most important decisions• Smallest initial domain

• Dynamic variable ordering• Use information from constraint propagation• Different orders in different parts of search tree• Use all information available

Insight Centre for Data Analytics Slide 137June 20th, 2016

Page 350: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

First Fail strategy

• Dynamic variable ordering

• At each step, select variable with smallest domain

• Idea: If there is a solution, better chance of finding it

• Idea: If there is no solution, smaller number ofalternatives

• Needs tie-breaking method

Insight Centre for Data Analytics Slide 138June 20th, 2016

Page 351: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 139June 20th, 2016

Page 352: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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,[]).

Insight Centre for Data Analytics Slide 139June 20th, 2016

Page 353: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Variable Choice

• Determines the order in which variables are assigned

• input_order assign variables in static order given

• first_fail select variable with smallest domain first

• most_constrained like first_fail, tie break based onnumber of constraints in which variable occurs

• Others, including programmed selection

Insight Centre for Data Analytics Slide 140June 20th, 2016

Page 354: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Value Choice

• Determines the order in which values are tested forselected variables

• indomain Start with smallest value, on backtracking trynext larger value

• indomain_max Start with largest value

• indomain_middle Start with value closest to middle ofdomain

• indomain_random Choose values in random order

Insight Centre for Data Analytics Slide 141June 20th, 2016

Page 355: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Comparison

• Board size 16x16

• Naive (Input Order) Strategy

• First Fail variable selection

Insight Centre for Data Analytics Slide 142June 20th, 2016

Page 356: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 143June 20th, 2016

Page 357: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 358: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

21

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 359: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

2

33

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 360: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

2

3

65

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 361: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

2

3

6

84

5

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 362: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

2

3

6

8

137

4

5

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 363: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

2

3

6

8

13

116

7

4

5

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 364: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

FirstFail Strategy (Size 16)

1

2

3

6

8

13

11

102

6

7

4

5

3

1

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 365: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 366: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 367: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 368: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 369: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 370: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 371: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 372: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 373: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 374: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 375: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 376: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 377: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 378: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 379: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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

Insight Centre for Data Analytics Slide 144June 20th, 2016

Page 380: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Comparing Solutions

Naive First Fail

Insight Centre for Data Analytics Slide 145June 20th, 2016

Page 381: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Comparing Solutions

Naive First Fail

Solutions are different!

Insight Centre for Data Analytics Slide 145June 20th, 2016

Page 382: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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"

Insight Centre for Data Analytics Slide 146June 20th, 2016

Page 383: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Observations

• This is much better

• But some sizes are much harder

• Timeout for sizes 88, 91, 93, 97, 98, 99

Insight Centre for Data Analytics Slide 147June 20th, 2016

Page 384: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Can we do better?

• Improved initial ordering• Queens on edges of board are easier to assign• Do hard assignment first, keep simple choices for later• Begin assignment in middle of board

• Matching value choice• Values in the middle of board have higher impact• Assign these early at top of search tree• Use indomain_middle for this

Insight Centre for Data Analytics Slide 148June 20th, 2016

Page 385: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 386: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

88

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 387: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

1210

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 388: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

59

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 389: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

146

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 390: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

14

65

6

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 391: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

14

6

44

5

6

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 392: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

14

6

412

4

5

6

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 393: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

14

6

412

311

4

5

6

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 394: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

14

6

412

3

1513

11

4

5

6

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 395: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (Size 16)

9

8

12

5

14

6

412

3

1515

13

11

4

5

6

9

10

8

Back to Start Skip Animation

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 396: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 397: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 398: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 399: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 400: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 401: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 402: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 403: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 404: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 405: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 406: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 407: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 408: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 409: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 410: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Start fromMiddle (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

Insight Centre for Data Analytics Slide 149June 20th, 2016

Page 411: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Comparing Solutions

Naive First Fail Middle

Insight Centre for Data Analytics Slide 150June 20th, 2016

Page 412: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Comparing Solutions

Naive First Fail Middle

Again, solutions are different!

Insight Centre for Data Analytics Slide 150June 20th, 2016

Page 413: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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"

Insight Centre for Data Analytics Slide 151June 20th, 2016

Page 414: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Observations

• Not always better than first fail

• For size 16, trees are similar size

• Timeout only for size 94

• But still, one strategy does not work for all problem sizes

• There are ways to resolve this!

Insight Centre for Data Analytics Slide 152June 20th, 2016

Page 415: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Approach 1: Heuristic Portfolios

• Try multiple strategies for the same problem

• With multi-core CPUs, run them in parallel

• Only one needs to be successful for each problem

Insight Centre for Data Analytics Slide 153June 20th, 2016

Page 416: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Approach 2: Restart with Randomization

• Only spend limited number of backtracks for a searchattempt

• When this limit is exceeded, restart at beginning

• Requires randomization to explore new search branch

• Randomize variable choice by random tie break

• Randomize value choice by shuffling values

• Needs strategy when to restart

Insight Centre for Data Analytics Slide 154June 20th, 2016

Page 417: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Approach 3: Partial Search

• Abandon depth-first, chronological backtracking

• Don’t get locked into a failed sub-tree

• A wrong decision at a level is not detected, and we haveto explore the complete subtree below to undo thatwrong choice

• Explore more of the search tree

• Spend time in promising parts of tree

Insight Centre for Data Analytics Slide 155June 20th, 2016

Page 418: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Example: Credit Search

• Explore top of tree completely, based on credit

• Start with fixed amount of credit

• Each node consumes one credit unit

• Split remaining credit amongst children

• When credit runs out, start bounded backtrack search

• Each branch can use only K backtracks

• If this limit is exceeded, jump to unexplored top of tree

Insight Centre for Data Analytics Slide 156June 20th, 2016

Page 419: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Credit, Search Tree Problem Size 94

48

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

Insight Centre for Data Analytics Slide 157June 20th, 2016

Page 420: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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"

Insight Centre for Data Analytics Slide 158June 20th, 2016

Page 421: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Points to Remember

• Choice of search can have huge impact on performance

• Dynamic variable selection can lead to large reduction ofsearch space

• Packaged search can do a lot, but programming searchadds even more

• Depth-first chronologicial backtracking not always bestchoice

• How to control this explosion of search alternatives?

Insight Centre for Data Analytics Slide 159June 20th, 2016

Page 422: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Part IV

What is missing?

Insight Centre for Data Analytics Slide 160June 20th, 2016

Page 423: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Many Specialized Topics

• How to design efficient core engine

• Hybrids with LP/MIP tools

• Hybrids with SAT

• Symmetry breaking

• Use of MDD/BDD to encode sets of solutions

• High level modelling tools

• Debugging/visualization

Insight Centre for Data Analytics Slide 161June 20th, 2016

Page 424: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

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, equivalentconstraints

• Because we don’t have that constraint in our system• For performance

Insight Centre for Data Analytics Slide 162June 20th, 2016

Page 425: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Learning

• While solving the problem we can learn how tostrengthen the model/search

• Understand which constraints/method contribute topropagation and change schedule

• Learn no-good constraints by explaining failure• Adapt search strategy based on search experience

Insight Centre for Data Analytics Slide 163June 20th, 2016

Page 426: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Refined Process

Problem

Human

User Model

Reformulation

Implementation Model

Constraint Solver/Search

Solution

Insight Centre for Data Analytics Slide 164June 20th, 2016

Page 427: Introduction to Constraint Programming...Introduction to Constraint Programming Helmut Simonis ACP Summerschool, June 20th, 2016 Licence This work is licensed under the Creative Commons

Exercises

• Install Constraint Solver of your Choice

• MiniZinc (MiningZinc) will be used in later sessions

• Run Sendmoremoney, Sudoku, Queens examples

• Can you choose which propagator to use for alldifferent?

• Can you use different search strategies?

Insight Centre for Data Analytics Slide 165June 20th, 2016