Answer Set Programming vs CSP: Power of Constraint Propagation Compared Jia-Huai You ( 犹嘉槐 )...

44
Answer Set Programming vs CSP: Power of Constraint Propagation Compared Jia-Huai You ( 犹犹犹 ) University of Alberta Canada
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    229
  • download

    0

Transcript of Answer Set Programming vs CSP: Power of Constraint Propagation Compared Jia-Huai You ( 犹嘉槐 )...

Answer Set Programming vs CSP:

Power of Constraint Propagation Compared

Jia-Huai You ( 犹嘉槐 )University of Alberta

Canada

Constraint Programming Studies computational models for solving

problems that can be expressed as constraints Applications: -NP-hard problems -Optimization -Planning (PSPACE-complete), logistics,

scheduling -Combinatorial problems

Approaches to Constraint Programming- Constraint Satisfaction Problem (CSP) (Maybe embedded in a programming

language such as Constraint Logic Programming)

- Propositional satisfiability (SAT)

- Answer set programming (ASP)

Blocks World PlanningBlocks World Planning

A B

C

TABLE

Planning Example: Logistics World

There are two types of vehicles : trucks and airplanes. Trucks are used to transport packages within a city, and airplanes to transport packages between airports.

The problem in this domain starts with a collection of packages at various locations in various cities, and the goal is to redistribute these packages to their destinations.

Example: 8-QueensExample: 8-Queens

Generate-and-test, 88 combinations

Example: Map ColoringExample: Map Coloring

WA

NT

SA

Q

NSWV

T

WA

NT

SA

Q

NSWV

T

Cryptarithmetic puzzles

The problem is to assign distinct (decimal) digits to letters so that adding two words yields the third. E.g.

S E N D + M O R E = M O N E Y D O N A L D + G E R A L D = R O B E R T

Approaches to Constraint Programming

Constraint Satisfaction Problem (CSP)

Systems: Constraint Logic Programming

Propositional Satisfiability (SAT) Systems: SAT solvers Answer Set Programming (ASP) Systems: Smodels, …

Graph Coloring in SAT (or ASP)

Write clauses (or rules in ASP) that express the constraints:

Any region must be colored with exactly one (but any) color.

No model (or answer set in case of ASP) may have two (distinct) adjacent regions colored with the same color.

Graph Coloring in ASP

coloring(N,C) node(N),color(C), not other_color(N,C). other_color(N,C) node(N),color(C), color(C’), C\=C’, coloring(N,C’).

hasColor(N) coloring(N,C), color(C).

node(N),node(N’),color(C), edge(N,N’), coloring(N,C), coloring(N’,C).

Contents Motivation Maintaining local consistencies in

CSP Lookahead in ASP Pruning power comparison Relationships between encodings Conclusions

Motivation Constraint Satisfaction

Problem(CSP) Maintaining local consistency

SAT solver or answer set programming Unit propagation, lookahead

Pruning power comparison

Structure Motivation Maintaining local consistencies in

CSP Lookahead in ASP Pruning power comparison Relationships between encodings Conclusions

Constraint Satisfaction Problem(CSP) CSP

Variable set Domain set Constraint set

Instantiation

),,( CDXA

},...,{1 nxx DDD

}...,1|{111 ,...,,..., kkk xxxxxx DDcnkcC

},...,{ 1 nxxX

A CSP

},,{ zyxX

}2,1,0{ zyx DDD

yxcxy :

zycyz :

012

x y

z

012

012

support

consistent

yxzcxyz 2:

i-consistency A CSP is i-consistent iff given any

consistent assignment of any i-1 variables, there exists an assignment of any ith variable such that the i values taken together satisfy all of the constraints among the i variables. i=2 arc-consistency (AC) i=3 path-consistency (PC)

Maintaining AC

},,{ zyxX

}2,1,0{ zyx DDD

}0{xD }1{yD }2{zD

012

x y

z

012

012

\

\

\\

\\

yxcxy :

zycyz :

Structure Motivation Maintaining local consistencies in

CSP Lookahead in Smodels Pruning power comparison Relationships between encodings Conclusions

Lookahead in Smodels

nm cnotcnotbba ,..., ,,..., 11

Answer set program

P

Stable model (answer set) of

where, of modelleast theis iff

program of model stable a is M atoms ofset A MPM

P

}],..1[ and

,..., ,,...,|,...,{ 111

Mcni

PcnotcnotbbabbaP

i

nmm

M

P

Lookahead

)}(),...,({ 11 kk axaxA

)(by

Expand ( ) notbyA )},({

Expand ( ) notbynotA )},( {

conflict

)( bynot

Propagation rules

1. Adds the head of a rule to A if the body is true in A.

2. If there is no rule with h as the head whose body is not false w.r.t A, then add not h to A.

Propagation rules

3. If h belongs to A, the only rule with h as the head must have its body true.

4. If the head of a rule is false in A, the body must be false.

Structure Motivation Maintaining local consistencies in

CSP Lookahead in Smodels Pruning power comparison Relationships between encodings Conclusions

Direct Encoding Uniqueness rules

Denial rules

).( ),...( ),( ),...,( )( 111 djjj axnotaxnotaxnotaxnotax

},...,{ 1 dx aaD

).(),( byaxxycba ),(

Lookahead vs AC The solution of a CSP corresponds

to the stable model of the ASP.

Does Lookahead = AC?

Example

01

01

0 1

x y

z

).1(),0( :1 yxr ).0(),1( :2 yxr ).0(),0( :3 zyr

).1(),1( : zyrr ).1(),0( :5 xzr ).0(),1( :6 xzr

Enforcing AC cannot remove any value.

How about lookahead?

)0(x 61,rr )1( ynot)1( znot

)0(y)0(z

Uniqueness3r

.domain thefrom removed is 0 meanswhich

,solution in the included be will)0(

xD

xnot

Unique value propagation(UP) Generate an superset of

} with consistent

in only value theis s.t. |{

b

Dabyax x

}0{ x }1,0{ yx }2,1,0{ zyx

012

012

012

1: yxcxy zycyz :x y z

which is

Theorem 1

lookahead=AC+UP.

Propagation Arc-Consistency(PAC)

Theorem 2 (i-1)-lookahead i-consistency

Support Encoding Uniqueness rules

The same as direct encoding

).( ..., ),( ),( 1 kbynotbynotaxxykxy cbacba ),(,...,),( 1

Support rules

Under support encoding Does the pruning power of

lookahead equal to that of PAC?

)}3,3(),2,3(),3,2(),2,2(),1,1(),0,1(),1,0(),0,0{(xyc

)}3,3(),2,3(),3,2(),2,2(),1,1(),0,1(),1,0(),0,0{(yzc

)}1,3(),0,3(),1,2(),0,2(),3,1(),2,1(),3,0(),2,0{(zxc

}3,2,1,0{ zyx DDD

PAC Lookahead

Singleton arc-consistency(SAC)

domains.empty -non with

consistent-arc made be can

iff SAC is CSPA

}{|,,

),,,(

aDx x

ADaXx

CDXA

}.{}{| axDaDA x be to grestrictinby obtained CSP the is

Theorem 3 and 4 Lookahead=SAC SAC > PAC

Theorem 5 2-lookahead SRPC

Restricted path consistency(RPC) Check the “unique support” pair

Singleton RPC(SRPC) Restrict the domain to be a single value

Structure Motivation Maintaining local consistencies in

CSP Lookahead in Smodels Pruning power comparison Relationships between encodings Conclusions

Relationships Niemela’s encoding

Uniquness rules The same as direct encoding

Allowed rules

xycba ),(

).(),()( byaxcsat xy

Lookahead has the same pruning power under the direct encoding as under Niemela’s encoding

Relationships Performance of the direct and

support encodings. Problem set

10 variables Domain size of 30 20 constraints

Experiments

Structure Motivation Maintaining local consistencies in

CSP Lookahead in Smodels Pruning power comparison Relationships between encodings Conclusions

Conclusions When testing single literal, lookahead

has the same prunning power under the direct encoding as well as Niemela’s encoding.

When Testing (i-1)-tuples, lookahead captures i-consistency under direct encoding.

Conclusions Under the support encoding, lookahead

has the same pruning power as SAC.

Under support encoding, when testing pair of literals, lookahead captures SRPC.

Conclusions Lookahead performs more efficiently

under the support encoding than under the direct encoding.

Comments and Questions?