constraint solving: problems, domains and search methods

83
Ontologi es Reasonin g Component s Agents Simulatio ns Constraint Solving: Constraint Solving: Problems, Domains and Search Problems, Domains and Search Methods Methods Jacques Robin

Upload: lynn-nelson

Post on 30-Dec-2015

45 views

Category:

Documents


2 download

DESCRIPTION

Constraint Solving: Problems, Domains and Search Methods. Jacques Robin. Outline. What is constraint solving? Constraint domains Constraint solving inference services Practical applications of CSP Finite domain Constraint Solving Problem (CSP) solving through search CSP search algorithms. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Constraint Solving: Problems, Domains and Search Methods

OntologiesReasoningComponentsAgentsSimulations

Constraint Solving:Constraint Solving:Problems, Domains and Search Problems, Domains and Search

MethodsMethods

Jacques Robin

Page 2: Constraint Solving: Problems, Domains and Search Methods

OutlineOutline

What is constraint solving? Constraint domains Constraint solving inference services Practical applications of CSP Finite domain Constraint Solving Problem (CSP) solving through

search CSP search algorithms

Page 3: Constraint Solving: Problems, Domains and Search Methods

What is Constraint Solving?What is Constraint Solving?

A versatile paradigm for symbolic, numerical and hybrid symbolico-numerical automated reasoning

Relies on hybrid logical-numerical knowledge representation formalism

Relies on AI search, term rewriting, operation research and mathematical inference algorithms

Allows reasoning with incomplete information Takes as input intentional and extensional knowledge

When input knowledge is consistent and complete, returns as output extensional knowledge

When input knowledge is consistent but incomplete, returns as output intentional and extensional knowledge that is more concise and easy to understand than the input

Identifies inconsistent input knowledge Most other automated reasoning paradigms (monotonic

deduction, belief revision, belief update, abduction, planning, optimization) can be reformulated as one form of constraint solving

Page 4: Constraint Solving: Problems, Domains and Search Methods

Constraint Solving Problems (CSP)Constraint Solving Problems (CSP)

Input: Set of variables, each one associated with an associated domain of

possible values (constants) Set of functions defining mapping between these domains Set of relations (called primitive constraints), including equations

and inequations, over these domains A logical conjunction of such relations (called a compound

constraints) Output:

Composed of same elements as input If the input is just rightly constrained, the output is one complete

consistent variable valuation, i.e., a logical conjunction of equations of the form <variable> = <constant value>.

If the input is underconstrained, the output is a simplification of the input, i.e., a logically equivalent conjunction of primitive constraints containing fewer constraints and/or functions and/or variables.

If the input is overconstrained, the output is “fail” for there exists no variable valuation that simultaneously satisfy all constraints.

Page 5: Constraint Solving: Problems, Domains and Search Methods

CSP Example: Analog Circuit CSP Example: Analog Circuit ModelingModeling

Particular circuit instance data sets: PD1 = ( V = 10 R1 = 10 R2 = 5 ), extensional PD2 = ( V = 10 R2 = 10 I1 = 5 ), extensional PD3 = ( R1 = 10 R2 = 5 ), extensional PD4 = ( V = 10 R1 = 5 I = 1 0 R2 ), intensional Solving particular circuit instance model PM1 = GM PD1 yields extensional consistent solution: V = 10 V1 = 10 V2 = 10 R1 = 10 R2 = 5 I = 3 I1 = 1 I2 = 2

Solving particular circuit instance model PM2 = GM PD2yields extensional consistent solution:V = 10 V1 = 10 V2 = 10 R1 = 2 R2 = 10 I = 6 I1 = 5 I2 = 1

Solving particular circuit instance model PM2 = GM PD2yields intentional consistent solution:V x 3 = I x 10

Solving particular circuit instance model PM4 = GM PD4yields fail (inconsistent input)

II1

I2

V

+

--3_

+

--

V1V2

--

R1 R2

Intentional generic circuitclass model GM:

021

021

021

02

01

222

111

III

III

VV

VV

VV

RIV

RIV

Page 6: Constraint Solving: Problems, Domains and Search Methods

CSP Example: Building SchedulingCSP Example: Building Scheduling

Particular query Q1:TS = 0 Tm = min(TE)

Solution to particular problem GM Q1:TS = 0 TA = 7

TB = 11 TC = 10

TD = 12 TE = 15

Tm = 15

Particular query Q2:TE 14

Solution to particular problem GM Q2: fail

start

foundations

interior walls

exterior walls

chimney

roof

doors

tiles

windows3

3

2

2

3

3

4

7

0

CE

DE

BE

CD

AD

AC

AB

SA

S

TT

TT

TT

TT

TT

TT

TT

TT

TGeneric Building Model GM:

Building a House

Doors2 days

Stage B

Interior Walls4 days

Chimney3 days

Stage D

Stage E

Tiles3 days

Roof2 days

Windows3 days

Stage C

Exterior Walls3 days

Stage A

Foundations7 days

Stage S

Page 7: Constraint Solving: Problems, Domains and Search Methods

CSP Example: Map ColoringCSP Example: Map Coloring

Generic Australia map coloring model AMCM:WT SO WT NT NT SO NT Q Q SO Q NSW NSW SO NSW V V SO

Color set instance BGR:WT {blue, green, red} SO {blue, green, red} NT {blue, green, red} Q {blue, green, red} NSW {blue, green, red} V {blue, green, red} T {blue, green, red}

Solving specific Australian map coloring problemAMCM BGR yields complete consistent solution:SO = blue WA = red NT = green Q = red NSW = green V = red T = green

Solving specific Australian map coloring problem with any set instance with two-color domains for all variables yields fail

Page 8: Constraint Solving: Problems, Domains and Search Methods

The Language of CSP: MOF The Language of CSP: MOF Metamodel Metamodel

<<enum>>FOL

Connective

FOL Atom FOL Term

0 ..*

args

args 0 .. *

FOL Formula

<<enum>FOL

Quantifier

1 ..*

0 ..*

connective

QuantifierPrefix

0 .. *

{ disjoint, complete }

PredicateSymbol

functor{ disjoint, complete }

Non-FunctionalTerm

FunctionalTerm

ConstantSymbol

VariableFunctionSymbol

functor

Ground Term

Non-GroundTerm

AndFormula

CompoundConstraint

PrimitiveConstraint

1 ..*

ValuationVariable

Assignment1 ..*

ConstraintDomain1 ..*

1 ..*

1 ..*

ConstraintSymbol

Page 9: Constraint Solving: Problems, Domains and Search Methods

CSP Domains: MOF MetamodelCSP Domains: MOF Metamodel

Constraint Domain (CD)

Nominal FD

Finite CD Infinite CD

{non-overlapping, complete}

=, , true, false

String CD

concat

Mixed CD2 .. *

,

Ordinal FD

,

Boolean CD

, , , ~, ,

{0,1}

Integer Linear Equations Inequalities N

Real Linear Equations Inequalities+, -, *

Real Polynomial Equations Inequalities

+, -, *, ^

Symbolic FDReal

Equations Inequalities

,

+, -, *, /, ^, logn, sin, cos,

...

R

InfiniteSymbolic CD

Integer FDEquations

InequalitiesN

Symbolic CD Numeric CD

{non-overlapping, complete}

RationalTrees CD

Function Symbolname: String

1 .. *

Page 10: Constraint Solving: Problems, Domains and Search Methods

CSP Solving ServicesCSP Solving Services

Substitution Satisfaction Absolute Implication Absolute Equivalence Normalization Absolute Simplification Projection Relative Implication Relative Equivalence Relative Simplification Local Propagation Optimization Labeling

Page 11: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: SubstitutionCSP Solving Services: Substitution

Substitute(:Valuation, C:CompoundConstraint):CompoundConstraint returns result of substituting in C the variables in by their value

in . Examples:

C: B = P + I x P B2 = B + I x B 1: B = 1200 P = 1000 I = 0.2 B2 = 1440

1(C): 1200 = 1000 + 0.2 x 1000 1440 = 1200 + 0.2 x 1200

2: B = 1 I = 1

2(C): 1 = P + 1 x P B2 = 1 + 1 x 1

3: B = 1 P = 0 I = 1 B2 = 1

3(C): 1 = 0 + 1 x 0 1 = 1 + 1 x 1

Page 12: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: SatisfactionCSP Solving Services: Satisfaction

Satisfiable(C:CompoundConstraint):Boolean result = true iff :Valuation | Substitute(, C) holds if result = true, also returns .

Examples: C1: B = P + I x P B2 = B + I x B Satisfiable(C1) = true, since: 1 = (B = 1200 P = 1000 I = 0.2 B2 = 1440) 1(C1) = (1200 = 1000 + 0.2 x 1000 1440 = 1200 + 0.2 x 1200)

(1200 = 1000 + 20000/100 1440 = 1200 + 24000/100) (1200 = 1000 + 200 1440 = 1200 + 240) (1200 = 1200 1440 = 1440) (true true) true

C2: X = Y + 1 Y = X + 1 Satisfiable(C2) = false, since C2 (X = X + 1 + 1 Y = X + 1) (X = X + 2 Y = X + 1)

(0 = 2 Y = X + 1) (false Y = X + 1) false

Page 13: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: CSP Solving Services: Absolute Implication and EquivalenceAbsolute Implication and Equivalence

Implies(C1:CompoundConstraint, C2:CompoundConstraint):Boolean result = true iff :Valuation, (C1) satisfiable (C2) satisfiable

Examples: C1 = (TS 0 TA TS + 7 TB TA + 4 TC TA + 3

TD TC + 2 TE TB + 2 TE TC + 3 TE TD + 3) C2 = TB TC

Implies(C1,C2) = false Since = (TS = 0 TA = 7 TB = 11 TC = 12 TD = 14 TE = 17)

satisfies C1 but not C2 C3 = C1 TE = 15 Implies(C3,C2) = true Since C3 12 TD 10 TC TA 7 TB 11

Equivalent(C1:CompoundConstraint, C2:CompoundConstraint): Boolean result = true iff :Valuation, (C1) satisfiable (C2) satisfiable

C1 C2 iff (C1 C2) and (C2 C1)

Page 14: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: NormalizationCSP Solving Services: Normalization

Solved form compound constraint: X1 = e1 ... XN = eN such that none of the variables X1 ... XN occur in any of the expressions e1 ...

eN. Normalize(C:CompoundConstraint):CompoundConstraint

result = S is in solved form and verifies S C C Examples:

C = (X = 2 + Y 2*Y + X – T = Z X + Y = 4 Z + T = 5) S = Normalize(C) = (X = 3 Y = 1 Z = 5 – T) C (X = 2 + Y 2*Y + 2 + Y – T = Z 2 + Y + Y = 4 Z = 5 - T) (X = 2 + Y 3*Y + 2 – T = 5 - T 2*Y = 4 - 2 Z = 5 - T) (X = 2 + Y 3*Y + 2 = 5 Y = 1 Z = 5 - T) (X = 2 + 1 3*1 + 2 = 5 Y = 1 Z = 5 - T) (X = 3 5 = 5 Y = 1 Z = 5 - T) (X = 3 true Y = 1 Z = 5 - T) (X = 3 Y = 1 Z = 5 - T) = S

Page 15: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services:CSP Solving Services:Absolute SimplificationAbsolute Simplification

Simplify(C:CompoundConstraint):CompoundConstraint result = S is equivalent, simpler constraint, i.e., S C and S has fewer primitive constraints than C and/or S has more constraints in solved form than C and/or S has fewer function symbols than C and/or S has fewer variables than C

Examples: C = (X Y + Z U + V X + V U = Z + Y V + V = 0 {U,V,X,Y,Z} N) S = (X = Y + Z U = Z + Y V = 0 {U,V,X,Y,Z} N) Since C (X Y + Z U + V X + V U = Z + Y V = 0 {U,V,X,Y,Z}

N) (X Y + Z 0 + U X + 0 U = Z + Y {U,V,X,Y,Z} N V =

0) (X Y + Z U X U = Z + Y {U,V,X,Y,Z} N V = 0) (X Y + Z Z + Y X U = Z + Y V = 0 {U,X,Y,Z} N) S

Page 16: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: ProjectionCSP Solving Services: Projection

Valuation extension: Given a valuation B of the form (X1 = v1 ... XB = vB)

Any valuation E of the form (X1 = v1 ... XB = vB XB+1 = vB+1 ... XE = vE )is an extension of B.

Partial solution: A valuation P is a partial solution of a constraint C iff

F :Valuation, F extends P and P is a solution of C

Notation: vars(C) = set of variables occurring in constraint C Project(C:CompoundConstraint,Vs:VariableSet):CompoundConst

raint precondition: Vs vars(C) result P verifies:1. vars(P) Vs2. C P3. P :Valuation over Vs, P solution of P P partial solution of C

Page 17: Constraint Solving: Problems, Domains and Search Methods

Projection ExamplesProjection Examples

C1 = (X Y Y Z Z T T 0) Project(C1,{X}) = X 0

C2 = (f(Y,Y) = f(X,Z) s(Z) = s(T) f bijection) Project(C2,{X,Z}) = (X = Z)

C3 = (X + Y 1 X - Y 1 - X + Y 1 - X - Y 1) Project(C3,{X}) = (- 1 X X 1)

Counter-example: C4 = (X = f(Y,Z)) Project(C4,{X}) = fail there is no primitive constraint in C1

that either do not contain X or can be simplified

YY

- Y- Y

XX- X- X11- 1- 1

- 1- 1

11

XX- X- X11- 1- 1

Page 18: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: Local CSP Solving Services: Local PropagationPropagation

Determined solved form of compound constraint: X1 = v1 ... XN = vN

where X1 ... XN are variables and v1 ... vN are constants

Propagate(Cd:CompoundConstraint, C:CompoundConstraint):CompoundConstraint preconditions: 1. Cd sub-conjunction of C2. Cd in determined solved form result = Propagate(Cd(C),choose(Cd’,determines(Cd,C))), i.e.,1. apply Cd as valuation substitution on C2. find which other sub-conjunctions of C become determined by this

substitution -- determines(Cd,C)3. choose one of them Cd’4. recursively propagate Cd’ on Cd(C)5. stop when propagation fails to determine new member of C

Page 19: Constraint Solving: Problems, Domains and Search Methods

Local Propagation ExampleLocal Propagation Example

C = (V = V1 V = V2 V1 = I1 x R1 V2 = I2 x R2 I = I1 + I2) Cd = (V = 10 R1 = 5 R2 = 10) Propagate(Cd,C) = (V = 10 V1 = 10 V2 = 10 I1 = 2 I2 = 1 I =

3)

Since:1. Cd(C) = (10 = V1 10 = V2 V1 = I1 x 5 V2 = I2 x 10 I = I1 + I2)2. Cd’ = (V1 = 10 V2 = 10)3. Cd’(Cd(C)) = (10 = 10 10 = 10 10 = I1 x 5 10 = I2 x 10 I = I1 +

I2)4. Cd’’ = (I1 = 2 I2 = 1)5. Cd’’(Cd’(Cd(C))) = (10 = V1 10 = V2 10 = 2 x 5 10 = 1 x 10 I = 2

+ 1)

Page 20: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: OptimizationCSP Solving Services: Optimization

Optimize(C:CompoundConstraint, F:CostFunction):Valuation if C overconstrained result = fail if C just rightly constrained result = unique u such that u(C)

satisfiable if C underconstrained result = one of the lowest-cost solutions, i.e.,

o such that o(C) satisfiable and such that (C) satisfiable, F(o) F()

if there is no such lower-cost solution, result = none Examples:

C1 = (X + Y 4) F(X,Y) = X^2 + Y^2 Optimize(C1,F) = (X = 2 Y = 3) G(X,Y) = X + Y Optimize(C1,G) = any solution to C2 = (X + Y = 5) C3 = X 0 H(X) = X Optimize(C3,H) = none

Page 21: Constraint Solving: Problems, Domains and Search Methods

CSP Solving Services: LabelingCSP Solving Services: Labeling

Label(C:CompoundConstraint):ValuationSet precondition: C over finite domain result = {:Valuation | (C) satisfiable}

Example: C1 = (WT SO WT NT NT SO NT Q Q SO

Q NSW NSW SO NSW V V SO) C2 = (WT {blue, green, red} SO {blue, green, red}

NT {blue, green, red} Q {blue, green, red} NSW {blue, green, red} V {blue, green, red} T {blue, green, red})

Label(C1 C2) = (SO = blue WA = red NT = green Q = red NSW = green V = red T = green)

Page 22: Constraint Solving: Problems, Domains and Search Methods

Constraint SolversConstraint Solvers

Constraint solver: software providing one CSP service Many CSP services can be implemented through judicious

assembly and reuse of other CSP services

Properties: Correct Complete Normalizing Set-based Variable name independent Monotonic (falsity preserving) Projecting Weakly projecting

Page 23: Constraint Solving: Problems, Domains and Search Methods

Constraint Solvers PropertiesConstraint Solvers Properties

Correct: guaranteed to return only correct solutions Complete: guaranteed to return all existing solutions

Possible only for small instances of CSP over specific domains Most CSP are NP-Hard, some are semi-decidable or even undecidable Satisfiable service returns “unknown” when it can neither conclude

that the input constraint is satisfiable nor that it is unsatisfiable Normalizing: return results in solved form

Directly legible, usable result No need for simplification or projection post-processing

Set-based: returns same solution for two equivalent compound constraints differing only in primitive constraint order and/or repetitions

Variable-name independent: returns same solution for two equivalent compound constraints different only in terms of variable names

Monotonic: C1,C2 satisfies(C1) = false satisfies(C1 C2) = false

Page 24: Constraint Solving: Problems, Domains and Search Methods

Soft ConstraintsSoft Constraints

Define preference order over valuations consistent with hard constraints

Hard constraint example: a professor cannot teach two courses with overlapping time slots

Soft constraint example: a professor prefers its undergraduate and graduate course to be scheduled on the same day

Most satisfiability problems with hard and soft constraints can be transformed into optimization problems: The preference defined by the soft constraints is captured by the

cost function to optimize

Page 25: Constraint Solving: Problems, Domains and Search Methods

Primitive Constraint ArityPrimitive Constraint Arity

Arity: primitive constraint argument number Zero-ary: true, false Unary: boolean negation, =, , , , , with one variable and one

constant Binary: =, , , , , with two variables Primitive high-order FD constraints:

Alldiff(V1 D, ... , Vn D), no pair of variables from {V1, ... , Vn} can share the same value in finite domain D

Atmost(TD,V1 D, ... , Vn D), T V1 +, ... , + Vn

Element(I {1, ... ,n}, [V1, ... , Vn], X), if I = i, then X = Vi

Any primitive high-order FD constraints can be converted to an equivalent conjunction of binary primitive FD constraints by the introduction of additional, auxiliary variables

But, special-purpose propagation techniques handle primitive high-order FD constraints far more efficiently than general purpose propagation techniques can handle their conversion as a conjunction of binary constraints

Page 26: Constraint Solving: Problems, Domains and Search Methods

CSP DomainsCSP Domainsand Algorithmsand Algorithms

Constraint Domain (CD)

Symbolic FD

Nominal FD

Symbolic CD Numeric CD Finite CD Infinite CD

Real Equations Inequalities

Real Polynomial Equations Inequalities

Real Linear Equations Inequalities

Integer Linear Equations Inequalities

Ordinal FD

Boolean CDInfinite

Symbolic CD

String CD RationalTrees CD

Integer FDLinear

Equations Inequalities

Local Propagation

Unification

Real Linear Equations

Gauss-Jordan Elimination

Real Linear Inequalities

Fourier Elimination

Simplex Optimization

• Chronological Backtracking (CBT)• Simple, w/ Forward Checking

• Conflict-Directed Backjunping (CDBJ)• Simple, w/ Forward Checking

• k-Consistency Propagation• CBT w/ k-Consistency Propagation• CDBJ w/ k-Consistency Propagation• Min-Conflict

Interval FD

• Bounds Consistency Propagation (BCP)• CBT w/ BCP• CDBJ w/ BCP

Page 27: Constraint Solving: Problems, Domains and Search Methods

FD Constraint Satisfaction as SearchFD Constraint Satisfaction as Search

FD CSP: D = {v1, ... , vm} X1 D ... Xn D Cs

where Cs = c1(Xi1,Xj

1) ... cp(Xip,Xj

p)

Finite domain allows solving by enumeration of possible valuations (search)

Formulation as incremental search: Initial state: no variable assigned, i.e., X1 D ... Xn D Cs

Successor function: add Xi = vj to current valuation Xk = vl ... Xq = vr such that Xk = vl ... Xq = vr Xi = vj Cs satisfiable

Goal test: X1 = vi1 ... Xn = vi

n Cs satisfiable Path cost: 1 per step

Formulation as complete-state search: Initial state: all variables randomly assigned,

i.e., X1 = vi1 ... Xk = vi

k ... Xn = vin

Successor function: change assignment of one variable in current valuation resulting in X1 = vi

1 ... Xk = vil X1 = vi

1 ... Xn = vin

where vil vi

k.

Goal test: same as incremental search

Page 28: Constraint Solving: Problems, Domains and Search Methods

General Problem-Solving SearchGeneral Problem-Solving Searchvs. FD CSP Searchvs. FD CSP Search

General problem-solving General problem-solving search:search:

State representation: Problem-specific Black-box data structure

Successor function: Problem-specific Arbitrary black-box

Goal test function: Problem-specific Arbitrary black-box

Heuristic functions: All domain-specific

FD CSP search:FD CSP search: State representation:

Standard for all CSP Compositional logical knowledge

representation language Successor function:

Standard for all CSP Instantiation of one piece of

intentional knowledge into extensional knowledge

Goal test function: Standard for all CSP Satisfaction of all instantiated

primitive constraints Heuristic functions:

Standard for all CSP Some domain-independent!

Page 29: Constraint Solving: Problems, Domains and Search Methods

FD CSP GraphsFD CSP Graphs

Summarize dependencies between variables through constraints

Node: variable, or constraint

Arc: constraint, or constraint argument

Useful for: Computing FD CSP

search heuristic functions

Complexity analysis of FD CSP search algorithm

Page 30: Constraint Solving: Problems, Domains and Search Methods

Backtracking Search for FD CSPBacktracking Search for FD CSP

General algorithm: At each step, choose one variable to assign one value to it and

choose that value from the variable’s associated domain If the resulting partial valuation satisfies all the primitive

constraints, recur to choose next variable-value assignment pair Otherwise, backtrack to a earlier assignment pair choice, choose

an alternative pair and resume forward search from that point Notes:

Path to solution state irrelevant Base, uninformed version:

Chooses variable to assign randomly among remaining options Chooses value to assign randomly among remaining options Always backtracks to last choice point (chronological backtracking) Does not perform any pruning of future options based on the

propagation of the consequences of its last assignment Xi = vi to the domains of variables adjacent to Xi in the constraint graph

Page 31: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

(X1=r X1=b X1=g) (X2=b X2=g) (X3=r X3=b) (X4=r X4=b) (X5=b X5=g) (X6=r X6=g X6=t) (X7=r X7=b) (X1=X2) (X1=X3) (X1=X4) (X1=X7) (X2=X6) (X3=X7) (X4=X5) (X4=X7) (X5=X6) (X5=X7)

Page 32: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 33: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 34: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 35: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 36: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 37: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 38: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

Page 39: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

Page 40: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

xbt

Page 41: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

xbt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btx

Page 42: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btx

Page 43: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

x

Page 44: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

Page 45: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 46: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 47: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 48: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 49: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

Page 50: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

x

Page 51: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

Page 52: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt

Page 53: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

btX2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

x

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bt ... X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bx x

Page 54: Constraint Solving: Problems, Domains and Search Methods

Chronological Backtracking ExampleChronological Backtracking Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

...

Page 55: Constraint Solving: Problems, Domains and Search Methods

Heuristic Improvements of Heuristic Improvements of Backtracking Search for FD CSPBacktracking Search for FD CSP

How to choose next variable to assign at each forward step? How to choose next value to assign to that variable? Where to backtrack when current valuation fails? What to record when current valuation fails to avoid repeating

following such unsuccessful path in the future? Domain-independent, general-purpose heuristics for each

decision Whether or not to combine it with consistency-based constraint

propagation to prune the domains of the values Such propagation can be done either as a pre-processing step Or after each variable assignment

Page 56: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT SearchForward Phase HeuristicsForward Phase Heuristics

Next variable choice: Most constrained by current partial valuation

a.k.a., MRV (Minimum Remaining Values) heuristic Why? Speed-ups failure detection, avoids BT in hopeless search space

regions Most constrained with currently unassigned variables

a.k.a., Highest Degree (HD) heuristic Why? Reduces future effective branching factor

Common combination: HD as tie breaker for MRV Next value choice:

Least Constraining Value (LCV) Why? Leaves options open, avoids BT triggered by early commitment

with insufficient knowledge Instance of general AI heuristic of “least-commitment”

Page 57: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT SearchForward Phase Heuristics ExamplesForward Phase Heuristics Examples

Next variable choice: most constrained by current partial valuation

Next variable choice: most constrained with currently unassigned variables

Next value choice: least constraining value

Improves scalability from25-Queens for uninformed BTto 1000-Queens

Page 58: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT Searchwith Forward Checkingwith Forward Checking

In forward phase After each new variable assignment Xi = vi

Add step to delete vi from the domains of adjacent(Xi) in the constraint graph

Page 59: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT Searchwith Forward Checkingwith Forward Checking

In forward phase After each new variable assignment Xi =

vi

Add step to delete vi from the domains of adjacent(Xi) in the constraint graph

Page 60: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT Searchwith Forward Checkingwith Forward Checking

In forward phase After each new variable assignment Xi =

vi

Add step to delete vi from the domains of adjacent(Xi) in the constraint graph

Page 61: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT Searchwith Forward Checkingwith Forward Checking

In forward phase After each new variable assignment Xi =

vi

Add step to delete vi from the domains of adjacent(Xi) in the constraint graph

Page 62: Constraint Solving: Problems, Domains and Search Methods

FD CSP BT SearchFD CSP BT Searchwith Forward Checkingwith Forward Checking

Forward checking does not provide early detection for all failures

After 3 steps, domains of adjacent variablesNT and SA are both reduced to {blue} which leads to failure

Systematic early detection requires multi-step constraint propagation after each assignment

Page 63: Constraint Solving: Problems, Domains and Search Methods

k-Consistencyk-Consistency

CSP P1 = (D = {v1, ... , vm} X1 D ... Xn D Cs) where Cs is a compound constraint on X1 ... Xn

CSP P2 is a sub-problem of P1 iff it is of the form: D = {v1, ... , vm} X1 D ... Xn-1 D Cs

k-Consistency: An FD CSP is k-consistent iff any consistent partial valuation involving k-1

variables can be extended into a consistent valuation assigning anyone of the remaining unassigned variables

1-Consistency a.k.a. Node Consistency Every variable has a consistent assignment in any non-empty sub-domain of

D 2-Consistency a.k.a. Arc Consistency

Every consistent single variable assignment can be extended into a consistent variable assignment pair for any other variable

3-Consistency a.ka. Path Consistency Every consistent variable assignment pair can be extended into a consistent

variable assignment triple for any third variable Strong k-Consistency:

An FD CSP is strongly k-consistent iff it is k-consistent, k-1 consistent, ... path-consistent, arc-consistent and node-consistent

Page 64: Constraint Solving: Problems, Domains and Search Methods

k-Consistency Examplesk-Consistency Examples

CSP1: X Y Y Z Z 2 X D Y D Z D D = {1,2,3,4} is not node consistent Primitive constraint Z 2 rules out any consistent assignment for

Z over sub-domain {3,4} CSP2: X Y Y Z Z 2 X D Y D Z D

D = {1,2} is node consistent CSP2 is not arc-consistent

Y = 1 X Y X {1,2} is unsatisfiable Australia map coloring problem with two colors is not globally

satisfiable but still arc-consistent

Page 65: Constraint Solving: Problems, Domains and Search Methods

Node and Arc-Consistency Node and Arc-Consistency PropagationPropagation

Node consistency: For each unary constraints U(X)

Delete all the values from Domain(X) that violate U

Arc-consistency: For each binary constraint B(X,Y)

Delete all the values from Domain(X) and Domain(Y) that violates the arc-consistency of the CSP

Page 66: Constraint Solving: Problems, Domains and Search Methods

Node and Arc Consistency ExampleNode and Arc Consistency Example

Colouring Australia: with constraints

WA NT WA SA NT SA

NT Q SA Q SA NSW

SA V Q NSW NSW V

purpleNTredWA

WA NT SA Q NSW V T

Node consistency

Page 67: Constraint Solving: Problems, Domains and Search Methods

Colouring Australia: with constraints

WA NT WA SA NT SA

NT Q SA Q SA NSW

SA V Q NSW NSW V

purpleNTredWA

WA NT SA Q NSW V T

Arc consistency

Node and Arc Consistency ExampleNode and Arc Consistency Example

Page 68: Constraint Solving: Problems, Domains and Search Methods

Colouring Australia: with constraints

WA NT WA SA NT SA

NT Q SA Q SA NSW

SA V Q NSW NSW V

purpleNTredWA

WA NT SA Q NSW V T

Arc consistency

Node and Arc Consistency ExampleNode and Arc Consistency Example

Page 69: Constraint Solving: Problems, Domains and Search Methods

Colouring Australia: with constraints

WA NT WA SA NT SA

NT Q SA Q SA NSW

SA V Q NSW NSW V

purpleNTredWA

WA NT SA Q NSW V T

Arc consistency

Node and Arc Consistency ExampleNode and Arc Consistency Example

Page 70: Constraint Solving: Problems, Domains and Search Methods

BackjumpingBackjumping

Backjumping or dependency-directed backtracking algorithms: improve on chronological backtracking: by attempting to backtrack directly to the deep cause of the failure

up the proof tree. Cache and update additional constraint dependency

information derived from constraint graph and current partial valuation; during both the forward and backward phases of the search.

Page 71: Constraint Solving: Problems, Domains and Search Methods

Conflict SetsConflict Sets

Given constraint graph G, a partial valuation A is a conflict set for variable X if VDom(X), CG, A X=V C |= false, i.e., all domain values of X are ruled out by some

constraint involving A e.g., valuation: X1=r X2=b X3=b X4=b X5=g X6=r

is a conflict set for X7 since X7=r conflicts with X1=r X1=X7

and X7=b conflicts with X3=b X3=X7 and with X4=b X4=X7

A conflict set is minimal if it does not contain any conflict subset

e.g., valuations X1=r X3=b and X1=r X4=b

are minimal conflict sets for X7

X1=r X3=b is the Earliest Minimal Conflict Set (EMCS) for X7 with variable ordering [X1, …, X7]

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2 X6

X3 X4 X5

X1 X7

r b

X2 X6

X3 X4 X5

X1 X7

r b

X2 X6

X3 X4 X5

X1 X7

r b

Page 72: Constraint Solving: Problems, Domains and Search Methods

Dead-end VariablesDead-end Variablesand Jump-back Setsand Jump-back Sets

A dead-end valuation is partial valuation X1=r … Xi=b that is a conflict set

for the dead-end variable Xi+1

The jump-back set of a dead-end variable is its EMCS with the current variable ordering

When failure occurs at a dead-end variable, Conflict-Directed Back-Jumping (CDBJ) backtracks directly (or jumps back)

to the latest variable of its jump-back set with the current variable ordering

Jump-Back Sets are Accumulated (AJBS) during the forward search phase as follow:

When choosing Xi=Vk add it to the conflict sets of all variables

Xjs such that C(…, Xi,…, Xj,…)G and Xi=Vk C |= false

Jump-Back Sets are Updated (UJBS) during the backtracking phase as follows:

After jumping back from Xd to Xb,

UJBS(Xb) = UJBS(Xb) (AJBS(Xd) – {Xb=Vb})

Page 73: Constraint Solving: Problems, Domains and Search Methods

Simple CDBJ Run ExampleSimple CDBJ Run Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1 X1

X2b g X6 r g t

X3

r b

X4

r b

X5 b g

X1

r b g

X7

r b

X1 X1

backjump

X3

backjump

X2b g X6 r g t

X3

r b

X4

r b

X5 b g

X1

r b g

X7

r b

X1

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1 X1

dead-end

X1 X3 X4

X4

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1 X1 X4

Page 74: Constraint Solving: Problems, Domains and Search Methods

Simple CDBJ Run ExampleSimple CDBJ Run Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X2b g X6 r g t

X3

r b

X4

r b

X5 b g

X1

r b g

X7

r b

backjump

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

xx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

xx xx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

xx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

xx X1 X3

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

dead-end

X4 X5xx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

backjump

X1 X3 X4

xx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxx

Page 75: Constraint Solving: Problems, Domains and Search Methods

Simple CDBJ Run ExampleSimple CDBJ Run Example

X2b g X6 r g t

X3

r b

X4

r b

X5 b g

X1

r b g

X7

r b

X1

bj

X1

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X1

bj

X1 X3

xx xx

X2b g X6 r g t

X3

r b

X4

r b

X5 b g

X1

r b g

X7

r bxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bxxxx

Page 76: Constraint Solving: Problems, Domains and Search Methods

Simple CDBJ Run ExampleSimple CDBJ Run Example

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

dead-end

X3 X4 X5xxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

backjump

X3 X4

xxxx

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b X3 X4

Page 77: Constraint Solving: Problems, Domains and Search Methods

CDBJ with Forward CheckingCDBJ with Forward Checking

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

bj

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X X

X

X1 X1

X1

X2b g X6r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X X

X

X1 X1

X1

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X X

XXdead-end

X1 X1

X1 X3

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X X

X

XX1

X1 X1

X1X

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X

XXdead-end

X1

X1 X3

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X X

X

X1 X2

X

X1X1

X1

X

X

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X X

X

X1

X1 X1

X

X

dead-end

X1 X3

X1

X

X

Page 78: Constraint Solving: Problems, Domains and Search Methods

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

XX1

X1 X1

X

X

CDBJ with Forward CheckingCDBJ with Forward Checking

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r bX

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X

XX

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

XX

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

XXX X3

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

XXX X3 X4

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

X Xdead-end

X3 X4 X5XX

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

X3X X4

X3 X4

XX

backjump

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

X3X X4

X3 X4

X

X5

X

Page 79: Constraint Solving: Problems, Domains and Search Methods

CDBJ with Forward CheckingCDBJ with Forward Checking

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

X3X X4

X3 X4

X

X5

X X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X

X3X X4

X3 X4

X

X5

X

Page 80: Constraint Solving: Problems, Domains and Search Methods

CDBJ with Forward Checking,CDBJ with Forward Checking,HD and LCV HeuristicsHD and LCV Heuristics

Variable ordering tie-breaker: domain with least potentially conflicting value e.g., X1 before X7 because gdom(X1) can only conflict with X2 = g,

whereas all values of dom(X7) may conflict with values of 3 or 4 variables

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X7 X7

X

X X

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

XX1

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X7 X7

X

X X

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X7 X7

X

X X

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X7 X7

X

X X

Page 81: Constraint Solving: Problems, Domains and Search Methods

CDBJ with Forward Checking,CDBJ with Forward Checking,HD and LCV HeuristicsHD and LCV Heuristics

Variable ordering tie-breaker: domain with least potentially conflicting value e.g., X1 before X7 because gdom(X1) can only conflict with X2 = g,

whereas all values of dom(X7) may conflict with values of 3 or 4 variables

No need to backtrack! Variable and value ordering heuristics and forward checking eliminate the

need to backtrack for many problem instances

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X7 X7

X

X X

X2b g X6 r g t

X3

r b

X4

r b

X5

b g

X1

r b g

X7

r b

X1

X7 X7

X

X X

Page 82: Constraint Solving: Problems, Domains and Search Methods

Min-Conflict ExampleMin-Conflict Example

States: 4 queens in 4 columns (44 = 256 states). Actions: move queen in column. Goal test: no attacks. Evaluation: h(n) = number of attacks Given random initial state, can solve n-queens in almost

constant time for arbitrary n with high probability (e.g., n = 10,000,000)

Page 83: Constraint Solving: Problems, Domains and Search Methods

Performance ExperimentsPerformance Experiments

Problem Backtracking

BT+MRV ForwardChecking

FC+MRV Minimum

Conflicts

USA(4-colors)

(>1.000K) (>1.000K)

2K 60 64

n-Queens(2 < n < 50)

(>40.000K) 13.500K (>40000K)

817K 4K

Zebra(ex. 5.13)

3.859K 1K 35K 0.5K 2K

Random 1 415K 3K 26K 2K Not run

Random 2 942K 27K 77K 15K Not run