Soft constraint processing Thomas Schiex Javier Larrosa Pedro Meseguer

Download Report

Transcript Soft constraint processing Thomas Schiex Javier Larrosa Pedro Meseguer

Soft constraint processing

Thomas Schiex

INRA – Toulouse France

Pedro Meseguer

CSIC – IIIA – Barcelona Spain Special thanks to:

Javier Larrosa

UPC – Barcelona Spain

Overview

  

Introduction and definitions

 Why soft constraints and dedicated algorithms?

 Generic and specific models

Solving soft constraint problems

 By search (systematic and local)  By complete inference… and search  By incomplete inference… and search

Existing implementations

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-2

Why soft constraints?

  CSP framework: for

decision

problems Many problems are

optimization

problems  Economics (combinatorial auctions)   Given a set G of goods and a set B of bids…  Bid ( B i , V i ), B i requested goods, V i value … find the best subset of compatible bids  Best = maximize revenue (sum) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-3

Why soft constraints?

 Satellite scheduling    Spot 5 is an earth observation satellite It has 3 on-board cameras Given a set of requested pictures (of different importance)…  Resources, data-bus bandwidth, setup-times, orbiting  …select a subset of compatible pictures with max. importance (sum) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-4

Why soft constraints

 Multiple sequence alignment (DNA,AA)  Given k  homologous sequences… AATAATGTTATTGGTGGATCGATGA  ATGTTGTTCGCGAAGGATCGATAA  … find the best alignment (sum)  AATAATGTTATTGGTG---GATCGATGATTA  ----ATGTTGTTCGCGAAGGATCGATAA-- August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-5

Why soft constraints?

 Probabilistic inference (bayesian nets)   Given a probability distribution defined by a DAG of conditional probability tables And some evidence  …find the most probable evidence (product) explanation for the August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-6

Why soft constraints?

 Ressource allocation (frequency assignment)   Given a telecommunication network …find the best frequency for each communication link  Best can be:   Minimize the maximum frequency (max) Minimize the global interference (sum) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-7

Why soft constraints

 Even in decision problems, the user may have

preferences

among solutions.

 It happens in most real problems.

Experiment: give users a few solutions and they will find reasons to prefer some of them.

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-8

Overview

  

Introduction and definitions

 Why soft constraints and dedicated algorithms?

 Generic and specific models

Solving soft constraint problems

   By search (systematic and local) By complete inference… and search By incomplete inference… and search

Existing implementations

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-9

Soft constraints

 Two new difficulties:   How to express preferences in the model?

How to solve the resulting optimization problem?

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-10

Solving soft constraints as a CSP

  Using a global criteria constraint   New constraint S k on all X S k (X) = criteria value must be more than  Number of variables having value blue k n -ary constraint Inefficient!!

k := n Repeat Apply: solve the original problem  k := k -1; Until solution S k (X) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-11

Combined local preferences

  Constraints are local

cost functions Costs

 combine with a dedicated max : priorities

operator

Fuzzy/min-max CSP  +: additive costs Weighted CSP  *: factorized probabilities… Probabilistic CSP, BN   Goal: find an assignment with the optimal combined cost August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-12

Soft constraint network

    ( X , D , C )    X={ x 1 ,..., x n } variables D ={ D 1 ,..., D n } finite domains C ={ c 1 ,..., c e } cost functions  var( c i ) scope  c i ( t ):  annihilator E (ordered cost domain, T,  ) identity Obj. Function: F ( X )=  c i Solution: F ( t )  T Soft CN: find minimal (X) cost solution • commutative • associative • monotonic August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-13

Valued CSP and Semiring CSP

Semiring CSP Valued CSP (total order) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-14

Specific frameworks

    E = {

t

,

f

} E = [0,1]   E = N   E = [0,1]  = and = max = + = * classical CSP  fuzzy CSP weighted CSP bayesian net Lexicographic CSP, probabilistic CSP… August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-15

Weighted CSP example (

= +)

F ( X x 1 x x x 3 2 5 x 4 For each vertex

x i c(x i )

): number of non blue vertices b g r 0 1 1 For each edge:

x i

b b b g r r g g r

x j

b

c(x i ,x j ) T

g r b g r g r b 0 0 0

T

0 0 0

T

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-16

Fuzzy constraint network (

=max)

x 1 x x x 5 3 2 x 4 For each vertex

x i

b g r y

c(x i )

0.2

0.4

0.6

0.8

Connected vertices must have different colors F ( X ): highest color used (b

Some insight in unusual items

 T = maximum violation.   Can be set to a bounded max. violation k Solution: F(t) < k = Top  Empty scope soft constraint c   (a constant) Gives an obvious lower bound on the optimum  If you do not like it: c  =  August 24, 2004 Additional expression power ECAI 2004 Tutorial: Constraint processing B-18

Weighted CSP example (

= +)

F ( X x 1 x x x 3 2 5 c  = 0 x 4 For each edge: ): number of non blue vertices For each vertex

x i c(x i )

b g 0 1

x i

b

x j

b r 1 Optimal coloration with less than 3 non-blue g r b g r g r b b b g r r g g r

c(x i ,x j ) T

0 0 0

T

0 0 0

T

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-19

Microstructural graph

b g r 0 1 1 x 1 6 6 6 0 1 1 x 3 0 1 1 x 4 T=6 c  =0 August 24, 2004 0 1 1 0 1 1 x 5 ECAI 2004 Tutorial: Constraint processing x 2 B-20

Basic operations on cost functions

I.

Assignment (conditioning) II.

Combination (join) III.

Projection (elimination) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-22

Assignment (conditioning)

g r r r

x i

b b b g g

x j c(x i ,x j )

b g r b g r 0 T=6 0 0 0 T=6 Assign(c,

x i

,b)

f(x j )

Assign(f,

x j

,g) 0

h

 August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-23

Combination (join with

)

x i

b b g g

x j

b g b g

c(x i ,x j )

6 0 0 6

x i

b b b b g g g g

x j

b b g g b b g g

x k

b g b g b g b g 

f(x i ,x j ,x k )

12 6 0 6 6 0 6 12 = 0  6

x j

b b g g

x k

b g b g

c(x j ,x k )

6 0 0 6 August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-24

Projection (elimination)

g r r r

x i

b b b g g r b g r

x j

b g r b g

c(x i ,x j )

4 6 0 2 6 3 1 0 6 Min Elim(c,

x j

)

x i

b g r

f(x i )

0 2 0 Elim(f,

x i

)

h

 0 August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-25

Overview

  

Introduction and definitions

 Why soft constraints and dedicated algorithms?

 Generic and specific models

Solving soft constraint problems

   By search (systematic and local) By complete inference… and search By incomplete inference… and search

Existing implementations

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-26

Systematic search

Each node is a soft constraint subproblem

(LB) Lower Bound

= c  under estimation of the best solution in the sub-tree

LB

UB then prune (UB) Upper Bound

= best solution so far = T August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-27

Assigning

x 3

x 1 x 2 x 5 August 24, 2004 x 1 x 3 x 2 x 4 x 4 x 1 x 5 x 2 x 4 x 5 ECAI 2004 Tutorial: Constraint processing x 1 x 2 x 5 x 4 B-28

Assign g to

X

6 6 6 b 0 g 1 1 r x 1 0 x 2 T=6 c  = August 24, 2004 Backtrack 0 1 1 x 5 ECAI 2004 Tutorial: Constraint processing x 3 b g r x 4 B-29

Depth First Search (DFS)

BT(

X,D,C

) if (

X

=  ) then Top :=

c

 else

x

j := selectVar (

X

) forall a  D j  c  C s.t. xj do

c

 :=  c  C if (  var( c )

c

:=Assign(

c

,

x

j ,

a

) s.t. var( c )= 

c

Heuristics Improve LB LB

X

-{

x

j },

D

-{

D

j },

C

) Good UB ASAP August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-30

Improving the LB

  Assigned constraints (c  ) Original constraints Solve Optimal cost  c  • Gives a stronger LB • Can be solved beforehand August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-31

Russian Doll Search

X 1 X 2 X 3    static variable ordering solves increasingly large subproblems uses previous LB recursively X 4 August 24, 2004 X 5  May speedup search by several orders of magnitude ECAI 2004 Tutorial: Constraint processing B-32

Local search

Based on perturbation of solutions in a local neighborhood       Simulated annealing Tabu search Variable neighborhood search Greedy rand. adapt. search (GRASP) Evolutionary computation (GA) Ant colony optimization…  See: Blum & Roli, ACM comp. surveys, 35(3), 2003 August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-33

Boosting Systematic Search with Local Search

( X,D,C ) time limit

Local search

Sub-optimal solution   Do local search prior systematic search   Use best cost found as initial T If optimal, we just prove optimality In all cases, we may improve pruning August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-34

Boosting Systematic Search with Local Search

 Ex: Frequency assignment problem  Instance: CELAR6-sub4  #var: 22 , #val: 44 , Optimum: 3230  Solver: toolbar with default options  UB initialized to 100000  3 hours  UB initialized to 3230  1 hour  Local search can find the optimum in a few minutes August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-35

Overview

  

Introduction and definitions

 Why soft constraints and dedicated algorithms?

 Generic and specific models

Solving soft constraint problems

   By search (systematic and local) By complete inference… and search By incomplete inference… and search

Existing implementations

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-36

Variable elimination

(aka bucket elimination)

    Solves the problem by a sequence of

problem transformations

Each step yields an equivalent problem with one less variable When all variables have been eliminated, the problem is solved Optimal solutions of the original problem can be recomputed August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-37

Variable elimination

     

Select a variable X

i

Compute the set K

i

constraints that involves this variable of Add Elim( )

c

K i c

, 1

Remove variable and K

i

Time:

(exp(deg

i

+1)) Space:

(exp(deg

i

))

X 1 X 2 X 4

C 

X 3

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-38

Variable elimination

  Time: exponential in the size of the largest combination performed (1+induced width) Space: similar !

 Infeasible as a general method… August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-40

Boosting search with variable elimination: BB-VE(k)

 At each node   

Select an unassigned variable X i

If deg

i

≤ k then eliminate X

i

Else branch on the values of X

i

 Properties  BE-VE(-1) is BB   BE-VE(w*) is VE BE-VE(1) is like cycle-cutset August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-41

Example BB-VE(2)

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-42

Example BB-VE(2)

c  August 24, 2004 c  ECAI 2004 Tutorial: Constraint processing c  B-43

Boosting search with variable elimination

 Ex: still-life (academic problem)  Instance: n=14  #var:196 , #val:2  Ilog Solver  5 days  Variable Elimination  1 day  BB-VE(18)  2 seconds August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-44

Overview

  

Introduction and definitions

 Why soft constraints and dedicated algorithms?

 Generic and specific models

Solving soft constraint problems

   By search (systematic and local) By complete inference… and search By incomplete inference… and search

Existing implementations

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-45

Local consistency

  Local property enforceable in polynomial time yielding an equivalent and more explicit problem Massive local (incomplete) inference  Very useful in classical CSP   Node consistency Arc consistency… August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-46

Classical arc consistency (binary CSP)

 for any X i and c ij  f=Elim(c ij  c i  information on X i c j ,X j ) brings no new c ij  c i  c j v w i 0 T T j 0 0 v w X i X j c ij v v 0 v w 0 w v T w w T Elim x j X i v w f(X i ) 0 T August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-47

Arc consistency and soft constraints

 for any X i and c ij  f=Elim(c ij  c i  information on X i c j ,X j ) brings no new c ij  c i  c j v w i 0 2 1 j 0 0 v w X i X j c ij v v 0 v w 0 w v 2 w w 1 Elim x j X i v w

EQUIVALENCE LOST

… unless  idempotent (fuzzy CSP) f(X i ) 0 1 August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-48

A parenthesis… Why min-max (fuzzy) CSP is easy

 A new operation on soft constraints: 

The

-cut of a soft constraint c is the hard constraint c  that forbids t iff c(t) > 

x i

b b g g

x j

b g b g

c(x i ,x j )

0.6

0.3

0.1

0.5

Cut(c, 0.4)

x i

b b g g  Can be applied to a whole soft CN

x j

b g b g

c(x i ,x j )

T 0 0 T August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-49

Solving a min-max CSP by slicing

  Let S be the set of all optimal solutions of a min-max CN Let the   be the maximum -cut.

 s.t. the  -cut is consistent. Then S is the set of solutions of Binary search   A min-max (or fuzzy) CN can be solved in O(log(# different costs)) CSP.

Can be used to lift polynomial classes August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-50

Back to Weighted CSP and Arc consistency

 for any X i and c ij  f=Elim(c ij  c i  information on X i c j ,X j ) brings no new c ij  c i  c j v w i 0 2 1 j 0 0 v w X i X j c ij v v 0 v w 0 w v 2 w w 1 Elim x j X i v w

EQUIVALENCE LOST

… unless  idempotent (fuzzy CSP) f(X i ) 0 1 August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-51

A new operation on soft networks

 Projection of c ij on X i with compensation v w 0 0 1 0 0 v w 1    Can be reversed Requires the existence of a pseudo difference (a b)  b = a August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-52

Node Consistency (NC

*

)

 For all variable i   a , C    a, C i + C i (a)O( nd ) v w v w T = C  = 4 x 3 0 2 0 1 y 2 1 1 1 z v w August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-53

Arc Consistency (AC

*

)

 NC *  For all C ij   a  b C ij ( a,b )= 0  b is a support  complexity: O( n 2 d 3 ) x T=4 C  = v w w 0 2 1 1 1 z 0 0 y v w August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-54

Directional AC (DAC

*

)

 NC *  For all C ij   a  b C ij ( a,b ) + ( i < j ) C j ( b ) = 0  b is a full-support  complexity: O(

ed

2 ) x < y < z v w v w T=4 C  = x 2 0 2 z 1 2 1 1 1 0 y v w August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-55

Full AC (FAC

*

)

 NC *  For all C ij   a  b C ij ( a,b ) + (full support) C j ( b ) = 0 August 24, 2004 x v w 0 1 1 1 T=4 C  =0 z 0 v w That’s our starting point!

No termination !!!

ECAI 2004 Tutorial: Constraint processing B-56

Full DAC (FDAC

*

)

  NC * For all C ij   a  b ( i < j ) C ij ( a,b ) + (full support) C j ( b ) = 0   For all C ij   a  (support) ( i > j ) b , C ij ( a,b ) = 0 Complexity: O(end 3 ) x < y < z v w v w T=4 C  = x 2 0 2 z 2 1 1 1 0 y v w August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-57

Hierarchy

Special case: CSP (Top=1)

NC * O( nd )

NC

AC * O( n 2 d 3 ) August 24, 2004 DAC * O( ed 2 )

DAC

FDAC * O( end 3 )

AC

ECAI 2004 Tutorial: Constraint processing B-58

Boosting search with LC

BT( X,D,C ) if ( X =  ) then Top := c  else x j := selectVar( X ) forall a  D j  c  C s.t. xj do c  :=  c  C  var( c ) s.t. var( c :=Assgn( c , x j , a ) if (

LC

) then BT( c )=  X -{ x c j }, D -{ D j }, C ) August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-59

MFDAC MAC/MDAC MNC BT August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-60

Boosting Systematic Search with Local search

 Ex: Frequency assignment problem  Instance: CELAR6-sub4  #var: 22 , #val: 44 , Optimum: 3230  Solver: toolbar  MNC*  1 year (estimated)  MFDAC*  1 hour August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-61

  

Introduction and definitions

  Why soft constraints and dedicated algorithms?

Generic and specific models

Solving soft constraint problems

   By search (systematic and local) By complete inference… and search By incomplete inference… and search

Existing implementations

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-63

Known implementations

     Con'Flex: fuzzy CSP system with integer, symbolic and numerical constraints ( www.inra.fr/bia/T/conflex ).

clp(FD,S): semi-ring CLP ( pauillac.inria.fr/.georget/clp_fds/clp_fds.html

).

LVCSP: Common-Lisp library for Valued CSP with an emphasis on strictly monotonic operators ( ftp.cert.fr/pub/lemaitre/LVCSP ).

Choco: a claire library for CSP. Existing layers above Choco implements some WCSP algorithms ( www.choco-constraints.net

).

toolbar: C library for MaxCSP and related problems ( carlit.toulouse.inra.fr/cgi-bin/awki.cgi/ToolBarIntro ).

carlit.toulouse.inra.fr/cgi-bin/awki.cgi/SoftCSP

August 24, 2004 ECAI 2004 Tutorial: Constraint processing B-64