Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.

Slides:



Advertisements
Similar presentations
Hybrid BDD and All-SAT Method for Model Checking Orna Grumberg Joint work with Assaf Schuster and Avi Yadgar Technion – Israel Institute of Technology.
Advertisements

NP-Hard Nattee Niparnan.
PERMUTATION CIRCUITS Presented by Wooyoung Kim, 1/28/2009 CSc 8530 Parallel Algorithms, Spring 2009 Dr. Sushil K. Prasad.
Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according.
Batcher’s merging network Efficient Parallel Algorithms COMP308.
The Theory of NP-Completeness
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
Pairwise Cardinality Networks Michael Codish and Moshe Zazon-Ivry Department of Computer Science B en-Gurion University.
1.2 Row Reduction and Echelon Forms
Linear Equations in Linear Algebra
Advanced Topics in Algorithms and Data Structures Lecture 6.1 – pg 1 An overview of lecture 6 A parallel search algorithm A parallel merging algorithm.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Computability and Complexity 24-1 Computability and Complexity Andrei Bulatov Approximation.
Chapter 11: Limitations of Algorithmic Power
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
Induction and recursion
Introduction Information in science, business, and mathematics is often organized into rows and columns to form rectangular arrays called “matrices” (plural.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
HOW TO SOLVE IT? Algorithms. An Algorithm An algorithm is any well-defined (computational) procedure that takes some value, or set of values, as input.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
CSCE350 Algorithms and Data Structure
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Combinatorial Algorithms Unate Covering Binate Covering Graph Coloring Maximum Clique.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
1 Recurrences Algorithms Jay Urbain, PhD Credits: Discrete Mathematics and Its Applications, by Kenneth Rosen The Design and Analysis of.
1 Section 5.5 Solving Recurrences Any recursively defined function ƒ with domain N that computes numbers is called a recurrence or recurrence relation.
Order Statistics. Order statistics Given an input of n values and an integer i, we wish to find the i’th largest value. There are i-1 elements smaller.
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
Lecture 4 Sorting Networks. Comparator comparator.
Linear Program Set Cover. Given a universe U of n elements, a collection of subsets of U, S = {S 1,…, S k }, and a cost function c: S → Q +. Find a minimum.
ALGORITHMS.
Planning as Satisfiability (SAT-Plan). SAT-Plan Translate the planning problem into a satisfiability problem for length n of Plan garb 0 (proposition)present.
Linear Systems Dinesh A.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
1 Sorting Networks Sorting.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 1.2 Linear Equations in Linear Algebra Row Reduction and Echelon Forms © 2016 Pearson Education, Ltd.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean Logic.
Chapter 10 NP-Complete Problems.
Lecture 4 Sorting Networks
Hybrid BDD and All-SAT Method for Model Checking
Sorting Networks Characteristics The basic unit: a comparator
SORTING NETWORKS.
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Linear Equations in Linear Algebra
Bitonic and Merging sorting networks
Chapter 11 Limitations of Algorithm Power
CS200: Algorithms Analysis
Lecture 6 Algorithm Analysis
Applied Discrete Mathematics Week 9: Integer Properties
Synthesis and Verification of Finite State Machines
Lecture 6 Algorithm Analysis
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Flow Feasibility Problems
CSE 589 Applied Algorithms Spring 1999
Linear Equations in Linear Algebra
Divide and Conquer Merge sort and quick sort Binary search
Presentation transcript:

Cardinality & Sorting Networks

Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat problem. Has the form: where the symbol is one of, variables are boolean.

Cardinality constraint As an example, the car sequencing problem (from last week) defines the number of cars to be manufactured, per model. If we agree that a Boolean variable is true iff the i‘th car of the resulting sequence belongs to some model M, then the constraint enforces the existence of k cars from that model to be in the sequence (where the sequence size is n).

Cardinality constraint Each Boolean variable below the sequence is 1 iff a “yellow” model appears in the corresponding position. car sequence instance:

Cardinality constraint In the Max-Sat problem we seek an assignment which satisfies the maximal number of clauses in a propositional formula One approach to solve the problem is to add “fresh” blocking variables to each clause, giving. We then search for a minimal k such that is satisfied.

Cardinality constraint There are several ways to encode a cardinality constraint as propositional formula. In this presentation we consider encoding which is based on sorting networks.

Sorting networks A (Boolean) sorting network is a circuit that receives n Boolean inputs and permutes them to obtain the sorted outputs. The network is composed of “wired” comparators. Each comparator has two inputs and two outputs. The upper output,, receives the maximal input value, where the lower output,, receives the minimal input value. The network computation is performed in parallel.

The 0-1 principle Theorem: If a sorting network sorts every sequence of 0's and 1's, then it sorts every arbitrary sequence of values.

Sorting networks

0101 Is it a sorting network ? 1010 No it’s not!

Sorting network encoding A comparator can be encoded into CNF by the following 6 clauses: Given a set of comparators of any sorting network, it is straightforward to construct a CNF which is a conjunction of the encoded comparators.

Sorting network encoding For any assignment on the sequence input, a complete satisfying assignment of the CNF, yields a sorted output assignment. We can use this property to check whether a given network is a sorting network. This could be done by adding constraint which is satisfied only if the output is not sorted. A satisfying assignment for the CNF and the above constraint means that the network does not sort.

Cardinality constraint encoding The cardinality constraint, over the input sequence is obtained by setting the k’th largest output to 0. It implies that all outputs from position k are zero. Hence, there are less than k ones amongst the input values. If the propositional formula describes the relation between the input and the output of a sorting network, we search a satisfying assignment for

Sorter(8) Cardinality constraint encoding

Sorter(8) Cardinality constraint encoding

Sorter(8) Cardinality constraint encoding

The odd-even sorting network Batcher’s odd-even network is a classic sorting network. It was devised back in 68’. It uses the divide and conquer design. The approach is similar to the merge-sort algorithm: for sorting a list of 2n inputs, partition the list into two sub lists, with n values each. Recursively sort these two lists, and finally merge them. Network’s size:, depth:.

The odd-even sorting network Sorter(2n)

Sorter(n) Merger(2n) The odd-even sorting network

Sorter(n/2) Merger(2n) Sorter(n/2) Merger(n) The odd-even sorting network

The odd-even merger The odd even merger uses the divide and conquer design, as well. It is assumed that its two input sequences: and are already sorted. The procedure divides each input into odd and even sequences, namely: and for the a’s. and for the b’s. The even and the odd sequences are merged recursively. The merged sequences are combined by comparing each in the result outcome

The odd-even merger Merger(n)

The odd-even merger Merger(n/2)

The odd-even merger Merger(n/2)

The odd-even merger Merger(n/2)

The odd-even merger Merger(n/2)

Unit Propagation If a set of propositional clauses contains a unit clause l, the other clauses are simplified. This process is called unit propagation. For a comparator : If the cardinality constraint parameter k is known a priory, we can use the above process in order to design a simplified network.

Odd-Even sorting network properties If there are p input variables that are set to 1, then by unit propagation the first p output variables are set to 1, as well. If there are p input variables that are set to 1, and the output variable in the p+1 position is set to 0, then by unit propagation the reminder of the input variables are set to 0.

Sorter(8) Odd-Even sorting network properties

Sorter(8) Odd-Even sorting network properties 1 1

Sorter(8) Odd-Even sorting network properties

Sorter(8) Odd-Even sorting network properties

The pairwise sorting network Devised in 94’ by Ian Parberry Takes a different form of the odd-even sorting network.

The pairwise sorting network Has the same size, depth and properties of the odd- even sorting network. Better unit propagation. The simplified CNF of the corresponding cardinality network is significantly smaller. Simple recursive definition of the corresponding cardinality network when k is known a priory. Experiments have shown better performance for structured problems.

Cardinality (0,1) matrix constraint A cardinality (0,1) matrix constraint is a constraint C defined on a Matrix M=x[i,j] of boolean variables. Every row i is associated with two positive integers lr[i] and ur[i], such that lr[i] ≤ ur[i]. Every column j is associated with two positive integers lc[j] and uc[j], such that lc[j] ≤ uc[j]. Each row and column of variables in the matrix M is constrained by:

Cardinality (0,1) matrix constraint The following Boolean martix is a solution instance for the cardinality (0,1) matrix, where each sum of row and column is bounded by 3 from bottom, and by 4 from top.

Exercise You are required to solve n cardinality (0,1) matrix constraint instances. The boolean matrix size for each problem instance is n×n, choose significant size n. For each problem instance i  [1..n] the sum of each row and column is exactly i. Use a sorting network for the cardinality encoding. Measure the solving time of each problem instance. Explain your results.