Pairwise Cardinality Networks Michael Codish and Moshe Zazon-Ivry Department of Computer Science B en-Gurion University.

Slides:



Advertisements
Similar presentations
The Complexity of Linear Dependence Problems in Vector Spaces David Woodruff IBM Almaden Joint work with Arnab Bhattacharyya, Piotr Indyk, and Ning Xie.
Advertisements

Boolean Satisfiability The most fundamental NP-complete problem, and now a powerful technology for solving many real world problems.
Programming with Boolean Satisfaction Michael Codish Department of Computer Science Ben Gurion University Beer-Sheva, Israel CP meets CAV Joint.
Max Cut Problem Daniel Natapov.
Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
Lecture 3: Parallel Algorithm Design
Batcher’s merging network Efficient Parallel Algorithms COMP308.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
Graphs 4/16/2017 8:41 PM NP-Completeness.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
VLSI Arithmetic. Multiplication A = a n-1 a n-2 … a 1 a 0 B = b n-1 b n-2 … b 1 b 0  eg)  Shift.
A New Algorithm for Optimal 2-Constraint Satisfaction and Its Implications Ryan Williams Computer Science Department, Carnegie Mellon University Presented.
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
SAT Algorithms in EDA Applications Mukul R. Prasad Dept. of Electrical Engineering & Computer Sciences University of California-Berkeley EE219B Seminar.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary.
Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.
Propositional Calculus Math Foundations of Computer Science.
Farzan Fallah Srinivas Devadas Laboratory for Computer Science MIT Farzan Fallah Srinivas Devadas Laboratory for Computer Science MIT Functional Vector.
CPSC 171 Introduction to Computer Science Boolean Logic, Gates, & Circuits.
Combinational Logic Design
Chapter 4 The Building Blocks: Binary Numbers, Boolean Logic, and Gates.
BOOLEAN ALGEBRA Saras M. Srivastava PGT (Computer Science)
Bold Stroke January 13, 2003 Advanced Algorithms CS 539/441 OR In Search Of Efficient General Solutions Joe Hoffert
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Computer Architecture I: Digital Design Dr. Robert D. Kent Logic Design Medium Scale Integration and Programmable Logic Devices Part I.
Problem (hard) Solution CNF Satisfied assignment Encoding FINITE DOMAIN PROBLEM SOLVING Model Constraint Model Direct Constraint / Bits relation lost.
Efficient and Scalable Computation of the Energy and Makespan Pareto Front for Heterogeneous Computing Systems Kyle M. Tarplee 1, Ryan Friese 1, Anthony.
Outline  introduction  Sorting Networks  Bubble Sort and its Variants 2.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
EXAMPLE 2 Use the power of quotient property x3x3 y3y3 = a.a. x y 3 (– 7) 2 x 2 = b.b. 7 x – 2 – 7 x 2 = 49 x 2 =
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Comparison Networks Sorting Sorting binary values
Digital Logic Problems (II) Prof. Sin-Min Lee Department of Mathematics and Computer Science.
BoolTool: A Tool for Manipulation of Boolean Functions Petr Fišer, David Toman Czech Technical University in Prague Dept. of Computer Science and Engineering.
Parallelizing MiniSat I-Ting Angelina Lee Justin Zhang May 05, Final Project Presentation.
Computer Science 101 Circuit Design - Examples. Sum of Products Algorithm Identify each row of the output that has a 1. Identify each row of the output.
A Reconfigurable Low-power High-Performance Matrix Multiplier Architecture With Borrow Parallel Counters Counters : Rong Lin SUNY at Geneseo
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Weikang Qian. Outline Intersection Pattern and the Problem Motivation Solution 2.
1 Outline:  Optimization of Timed Systems  TA-Modeling of Scheduling Tasks  Transformation of TA into Mixed-Integer Programs  Tree Search for TA using.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
Lecture 4 Sorting Networks. Comparator comparator.
Computer Science 101 More Devices: Arithmetic. From 1-Bit Equality to N-Bit Equality = A B A = B Two bit strings.
Finding Models for Blocked 3-SAT Problems in Linear Time by Systematical Refinement of a Sub- Model Gábor Kusper Eszterházy Károly.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
1 Sorting Networks Sorting.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
Solve a two-step equation by combining like terms EXAMPLE 2 Solve 7x – 4x = 21 7x – 4x = 21 Write original equation. 3x = 21 Combine like terms. Divide.
© 2012 IBM Corporation Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012.
Recursive Algorithms Section 5.4.
Lecture 4 Sorting Networks
Chih-Fan Lai1, J.-H. Roland Jiang1, and Kuo-Hua Wang2
Sorting Networks Characteristics The basic unit: a comparator
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
SORTING NETWORKS.
Advanced Design and Analysis Techniques
A Boolean Paradigm in Multi-Valued Logic Synthesis
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Merge sort merge sort: Repeatedly divides the data in half, sorts each half, and combines the sorted halves into a sorted whole. The algorithm: Divide.
SAT-Based Area Recovery in Technology Mapping
Comparison Networks Sorting Sorting binary values
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Synthesis and Verification of Finite State Machines
Lecture 6 Algorithm Analysis
Merge sort merge sort: Repeatedly divides the data in half, sorts each half, and combines the sorted halves into a sorted whole. The algorithm: Divide.
Presentation transcript:

Pairwise Cardinality Networks Michael Codish and Moshe Zazon-Ivry Department of Computer Science B en-Gurion University

Cardinality constraints in a nutshell Satisfiability problems of the form: - conjunction of clauses - conjunction of constraints of the form is one of Typically Applications: optimization problems, Max-Sat, scheduling problems, and more. How to solve? Dedicated solvers (SMT solvers) Sat encoding BDD-like structure Sorting networks (unary ) Networks of adders (binary)

Focus for this talk x1x1 x2x2 x3x3 x4x4 x8x8 y1y1 y2y2 y3y3 Sorter 0 Encoding Cardinality Constraints to SAT, using sorting networks MiniSAT+, Barcelogic (and others) adapt this approach applying Batcher's Odd Even Sorting Network (from the 60’s) We propose an alternative choice of Sorting Network InputOutput x5x5 x6x6 x7x7 y5y5 y6y6 y7y7 y8y8

Outline of the talk Sorting networks Batcher’s Odd-Even (OE) Network An Alternative - Parberry's Pairwise (PW) Network Why an Alternative (I) - constraint propagation Understanding OE vs. PW Why an Alternative (II) - partial evaluation Conclusion

Sorting networks A Comparator is a device with two inputs, a and b, and two outputs, c and d comparator a b c=max(a,b) d=min(a,b) A Sorting network is a composition of wires and comparators that sorts its inputs b1b1 a1a1 a2a2 b2b2 b3b3 a3a3 a4a4 b4b4

Sorting networks There are “handcrafted” sorting networks And there are sorting networks based on your favorite sorting algorithm x1x1 x2x2 x3x3 x4x4 x8x8 y1y1 y2y2 y3y3 x5x5 x6x6 x7x7 y5y5 y6y6 y7y7 y8y8 x9x9 y9y9 Custom sorting network, n=9 x1x1 x2x2 x3x3 x4x4 y1y1 y2y2 y3y3 x5x5 x6x6 y5y5 y6y6 y4y4 y4y4 “Bubble sort” network

Sat encoding - comparators The SAT encoding of a comparator comparator(a, b, c, d) is: c d a b

Sat encoding – sorting networks b1b1 a1a1 t1t1 t2t2 t3t3 t4t4 t6t6 t5t5 a2a2 a3a3 a4a4 b2b2 b3b3 b4b4 The SAT encoding of a sorting network is the conjunction of the encodings of its comparators.

Sat encoding – cardinality constraints x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 0 Sorter(8) Given a cardinality constraint x 1 + x 2 +…+ x n < k Set the k’th output variable to zero.

x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 y4y4 y5y5 y6y6 y7y7 y8y8 Sorter(n) The odd-even (OE) sorting network Sorter(n/2) OE-Merger(n) Sorter(n/4 ) OE- Merger(n/2) Sorter(n/4 )

OE-Merger(4) It’s all in the (OE) merger x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 y5y5 y6y6 y7y7 y8y8 y4y4 Given two sorted input sequences sorted Merge the odd input sequences Merge the even input sequences OE Merger(8) OE-Merger(4)

It’s all in the (OE) merger x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 y5y5 y6y6 y7y7 y8y8 y4y4 Given two sorted input sequences sorted Merge the odd input sequences Merge the even input sequences Combine the outputs into a sorted output OE-Merger(4)

And Then There Was … Ian Parberry devised the pairwise (PW) sorting network in 1992 Ian Parberry It has the exact same size & depth as the OE sorting network, but it is not isomorphic,… “The value of the pairwise sorting network is not that it is superior to the odd-even sorting network in any sense, but that it is the first serious rival to appear in over 20 years”

The pairwise sorting network x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 y4y4 y5y5 y6y6 y7y7 y8y8 A pairwise split is placed before the recursive calls and divides the network into “upper” and “lower” sub networks. “upper” Sorter(4) “upper” Sorter(4) “lower” Sorter(4) “lower” Sorter(4) OE-Merger(8) The inputs to the merger from the “upper” network have more (or equal) ones than those from the “lower” network. a1a1 a2a2 a3a3 a4a4 b1b1 b2b2 b3b3 b4b4 Starting from the OE sorting network This property enables Parberry to simplify the specification of the merger aiai bibi Splitter(8) PW-Merger(8)

And More! When the k’th merger output is set to zero, then the k/2 ‘th output from the “lower“ network is also set to zero. “upper” Sorter(n/2) “upper” Sorter(n/2) “lower” Sorter(n/2) “lower” Sorter(n/2) PW-Merger(n) Splitter(n) k 0 0 Constraint propagation k/2 Because

The pairwise (PW) sorting network Parberry’s sorting network unfolds to a network of splitters followed by simplified mergers Sorter(n/2) PW-Merger(n) Splitter(n)

What is the pairwise merger? x1x1 x2x2 x3x3 x4x4 y1y1 y2y2 y3y3 x5x5 x6x6 x7x7 y5y5 y6y6 y7y7 y4y4 x9x9 x 10 x 11 x 12 y9y9 y 10 y 11 x 13 x 14 x 15 y 13 y 14 y 15 y 12 x8x8 x 16 y8y8 y 16 The pairwise merger is constructed by layers of comparators Each layer reduces the “amplitude” of the sequence by half Check the Parberry paper, it’s a bit technical

Our take on the pairwise merger We observe that the oe-merger is exactly the composition of a splitter and a pw-merger Sorter(n/2) PW-Merger(n) Splitter(n) Sorter(n/2) OE- Merger(n) Splitter PW-Merger(n) Sorter(n/2) OE-Merger(n)

PW vs. OE sorting network OE-Sorting Network x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 y4y4 y5y5 y6y6 y7y7 y8y8 PW-Sorting Network x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 y1y1 y2y2 y3y3 y4y4 y5y5 y6y6 y7y7 y8y8 Both sorting networks are composed from the same components In the PW network splitters precede pw mergers. In the OE network splitters and pw mergers alternate

Pairwise Cardinality Network c=max(a,b) d=min(a,b) a b 0 Advance knowledge of comparator’s input/output facilitates partial evaluation Comparators may become obsolete 0 Splitters before mergers gives more partial evaluation

x1x1 x2x2 x3x3 x4x4 y1y1 y2y2 y3y3 x5x5 x6x6 x7x7 x9x9 x 10 x 11 x 12 x 13 x 14 x 15 x8x8 x Partial evaluation propagates through the network. Pairwise Cardinality Network Sorter(8) Splitter(16) Sorter(8) Sorter(4) Splitter(8) PW-Merger(8) k=4 k=2 k=1 The simplified network is of size. It can be constructed directly.

Comapring potential for P.E. PW cardinality network n=128,k=8 OE cardinality network n=128,k=8 massive reduction of comparators in the “lower” halves

Pairwise Cardinality Network Number of comparators after partial evaluation Before p.e. In the worst case no big difference.

Experiments ongoing... In the cardinality matrix problem the sum of each row and column is restricted between k 1 and k Boolean Matrix M n=5, k 1 =1 & k 2 =4 3= =2=2

Experiments For a Boolean Matrix with n=100 Cardinality Network proposed by Asin etal [1]

Conclusion Propose cardinality networks based on pairwise sorting networks instead of odd-even networks Better constraint propagation Better partial evaluation Improve understanding on the relation between pairwise and odd-even networ ks Pairwise Networks are better for cardinality constraints and should be considered in tools (MiniSAT+, etc).