10 likes | 156 Views
Order encoding. Binary. Unary. Direct encoding. x i ↔ ( X ≥ i ) (X = 3) = [1,1,1,0,0]. Number X with a domain {0,1,2, …, d} will be represented using n = Boolean variables. x i ↔ ( X = i ) (X = 3) = [0,0,0,1,0,0 ]. b=c. e=f=g. Problems:
E N D
Order encoding Binary Unary Direct encoding xi ↔ (X ≥ i) (X = 3) = [1,1,1,0,0] Number Xwith a domain {0,1,2, …, d} will be represented using n=Boolean variables. xi ↔ (X = i) (X = 3) = [0,0,0,1,0,0] b=c e=f=g • Problems: • Constraint / Bits connection lost • Large CNF Optimized SAT Encoding Finite DomainProblem Solving Modeling Finite Domain CSP a b d c e f g representing numbers (integers) Constraint Model Encoding CNF Problem (hard) Constraint Model 1 a a 1 a a c a 1 b b f a b b c b c b c c c c CNF Model Encoding a b c d e f g CNF’ Simplified Model Encoding Partial Evaluation Direct CSP solving SAT solving CNF’’ Simplified Model’ Encoding Partial Evaluationusing Equi-Propagation CNF preprocessors such: SatELite, ReVivAl Based on Unit Propagation and Resolution. Solution Model Solution Satisfied assignment Decoding Translate Simplified CNF Our Approach Equi-Propagation • good for representing ranges Constraint ( C2, φ2 ) Constraint ( C3, φ3 ) Constraint ( Cn, φn ) Constraint ( C1, φ1 ) Equi-propagation is the process of inferring new equational consequencesfrom a single constraint in the model (and other existing equational information). • When inferring such equational consequence, x can be removed from the model by replacing x with its equivalent in all the constraints in the model. … M = X Boolean Equi-Propagation for Optimized SAT EncodingAmitMetodi, Michael Codish, Vitaly Lagoon, and Peter J. Stuckey 1 0 Simplify X ≥ i X < j i j x= -y, x=y, x=0, x=1 • good for arbitrary sets Boolean techniques CSP techniques Equi-Propagation X v u Constraint ( C1, φ1 ) Constraint ( C2, φ2 ) Constraint ( C’3, φ‘3 ) Constraint ( C’n, φ’n) … M’ = i Encoding Standard encodings • good for arithmetic operations with constants: + 3 = φ1 φ'3 φ'n … φ = * 3 = div 3 = Equi-Propagation Example • When encoding CSP model to SAT holding both representation for each constraint gives the ability to apply simplify techniques from both worlds on each constraint. • A complete equi-propagator for a constraint can be implemented using binary decision diagrams (BDDs) and can be evaluate in polynomial time. • When C(X1,…,Xk) a constraint about (fixed) “k” integers with n bits each, the BDD representing it is of size O(n^k). • Global constraints (such as allDiff) implemented using Ad-Hoc rules. • There is a strong connection between Simplify and Encoding because Simplify done on the “encoding bits” and might change the encoding accordingly. • By using the Equi-Propagation technique we generates a small optimized CNF. … … … M = Constraints diff(U1={ 0..4 }=[x1,x2,x3,x4] , U2={ 0..4 }=[y1,y2,y3,y4]) sumBits(a,d,b,x3,y2,c,y4)=3 Constraints Simplify U1 < 4 , U1 > 0 , U1 ≠ 3 (x1=1 , x2=x3 , x4=0) U1 < 4 , U1 > 0 , U1 ≠ 3 (x1=1 , x2=x3 , x4=0) d=1 … … … Constraints diff(U1={ 1,3 }=[1,x2,x2,0] , U2={ 1,3 }=[1,y2,y2,0]) sumBits(a,1,b,x2,y2,c,0)=3 Constraints U1 ≠ U2 (y2= -x2) … … … Constraints diff(U1={ 1,3 }=[1,x2,x2,0] , U2={ 1,3 }=[1,-x2,-x2,0]) sumBits(a,1,b,x2,-x2,c,0)=3 Constraints … … … M’ = Constraints diff(U1={ 1,3 }=[1,x2,x2,0] , U2={ 1,3 }=[1,-x2,-x2,0]) sumBits(a,b,c)=1 Constraints Experiments Balanced Incomplete Block Designs Definition: a 5-tuple of positive integers <v, b, r, k, l>and require to partition v distinct objects into b blocks such that each block contains k different objects, exactly r objects occur in each block, and every two distinct objects occur in exactly l blocks. Variables: B11, …, Bbv Domains:Bijϵ{0,1} Constraints: each row constraint: sum(Bi1,…,Biv) = r each column constraint: sum(B1i,…,Bbi) = k • each two rows constraint: sum(Bi1*Bj1, …,Biv*Bjv)=l BIBD <6,10,5,3,2> Nonograms Definition: an nXm board of cells to color black or white and given clues per row and column of a board. A clue is a number sequence indicating blocks of cells to be colored black. Variables: B11, …, Bnm R11,…R1k,…,Rm1,…Rmp C11,…C1q,…,Cn1,…,Cnr Domains:Bijϵ{0,1} Rmoϵ{0,..,n} Cnoϵ{0,..,m} Constraints: block constraint: block(Rij,Rij+<ij size>,[B1i,…,Bni]) • space constraint: block(Rij+<ij size>,Rij+1,[-B1i,…,-Bni]) • no overlap constraint: leq(Rij+<ij size>+1, Rij+1) • There are dedicates solvers such as • Jan Wolter'spbnsolve (http://webpbn.com/pbnsolve.html) • Ben-Gurion University Solver (http://www.cs.bgu.ac.il/~benr/nonograms/) • BEE is faster than the dedicated solvers on the hard puzzles. Selected human puzzles 5,000 random 30x30 puzzles