10/9/2015COSC-4301-01, Lecture 51 Real-Time Systems, COSC-4301-01, Lecture 5 Stefan Andrei.

Slides:



Advertisements
Similar presentations
NP-Completeness.
Advertisements

Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
The Theory of NP-Completeness
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
Methods of Proof Chapter 7, second half.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Hardness Results for Problems
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP.
9/17/2015COSC , Lecture 131 Real-Time Systems, COSC , Lecture 13 Stefan Andrei.
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.
Boolean Satisfiability and SAT Solvers
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Solving Linear Programming Problems: The Simplex Method
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module Logic Representations.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
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.
12/19/2015COSC , Lecture 31 Real-Time Systems, COSC , Lecture 3 Stefan Andrei.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
Tommy Messelis * Stefaan Haspeslagh Patrick De Causmaecker *
Finding Models for Blocked 3-SAT Problems in Linear Time by Systematical Refinement of a Sub- Model Gábor Kusper Eszterházy Károly.
Saleem Sabbagh & Najeeb Darawshy Supervisors: Mony Orbach, Technion & Ilia Averbouch, IBM Started at: Spring 2012 Duration: Semester.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 9: Test Generation from Models.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Solving the Logic Satisfiability problem Solving the Logic Satisfiability problem Jesus De Loera.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
Custom Computing Machines for the Set Covering Problem Paper Written By: Christian Plessl and Marco Platzner Swiss Federal Institute of Technology, 2002.
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.
SAT Encodings for Sudoku Bug Catching in 2006 Fall Sep. 26, 2006 Gi-Hwon Kwon.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The NP class. NP-completeness
Chapter 10 NP-Complete Problems.
Hard Problems Some problems are hard to solve.
Richard Anderson Lecture 26 NP-Completeness
Computability and Complexity
Richard Anderson Lecture 26 NP-Completeness
ICS 353: Design and Analysis of Algorithms
Complexity 6-1 The Class P Complexity Andrei Bulatov.
Objective of This Course
Richard Anderson Lecture 25 NP-Completeness
SAT-Based Area Recovery in Technology Mapping
Propositional Equivalences
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Methods of Proof Chapter 7, second half.
Presentation transcript:

10/9/2015COSC , Lecture 51 Real-Time Systems, COSC , Lecture 5 Stefan Andrei

10/9/2015 COSC , Lecture 5 2 Reminder of the last lecture Multiprocessor Scheduling Available scheduling tools Available real-time operating systems

10/9/2015 COSC , Lecture 5 3 Overview of This Lecture A Satisfiability Approach for the Scheduling Problem

10/9/2015 COSC , Lecture 5 4 Introduction Most of the existing scheduling problems are NP-hard. Researchers have been putting many efforts in finding good heuristics for solving scheduling problem in polynomial time. However, there still exist classes of task sets that are feasible and most traditional schedulers (e.g. RM, EDF, LL) fail to solve the scheduling problem. Existing SAT encodings could not be adopted for the given scheduling problem.

10/9/2015 COSC , Lecture 5 5 The main idea We present a new satisfiability (SAT) based approach to the scheduling problem. We transform time constraints into a satisfiability problem. The obtained clauses are converted to the DIMACS format and passed as input to a SAT solver, such as Zchaff. We conclude that our satisfiability-based approach is a promising technique for scheduling.

10/9/2015 COSC , Lecture 5 6 Related work At first glance it seems to be an obvious translation of scheduling problems into SAT:  Create variables to represent the start times of the operations and create clauses to represent the necessary inequalities.  However the search space in SAT problems so generated turns out to be much larger than necessary.  Previous SAT encodings approaches like those expressed in [Memik, Fallah; 2002] and [Crawford, Baker; 1994] could not be applied either because they do not consider the exact time relations [Crawford, Baker; 1994] or they are too large [Memik, Fallah; 2002].

10/9/2015 COSC , Lecture 5 7 References [Memik, Fallah; 2002] S.O.Memik, F.Fallah: “Accelerated SAT-based scheduling of control/data flow graphs”, Computer Design: VLSI in Computers and processors, Proceedings, 2002 [Crawford, Baker; 1994] J.M.Crawford, A.B.Baker: Experimental Results on the Application of Satisfiability Algorithms to Scheduling Problems, The 12th National Conference on Artificial Intelligence, 1994.

10/9/2015 COSC , Lecture 5 8 Scheduling A task T is characterized by the following parameters:  S: start (also called release, ready, or arrival) time.  c: (maximum) computation time.  d: relative deadline (deadline relative to the task's start time)  p: period (how often the tasks are supposed to be executed)  D: absolute deadline (wall clock time deadline) e.g., D = S + d.

10/9/2015 COSC , Lecture 5 9 The propositional satisfiability problem The SAT problem: “Given a set of clauses C (disjunction of literals – also known as CNF: Conjunctive Normal Form) on a finite set U of variables, find a truth assignment for U that satisfies all the clauses in C”. The SAT problem is solved by the SAT solvers. Example: Given U = {A, B, C} the set of variables and F = (A   B    C)  (        C)  (       C  a propositional formula, then a truth assignment for F is A = false, B = false, C = false.

10/9/2015 COSC , Lecture 5 10 Encoding Scheduling problems as SAT problems For each operation i executing between time t and t+1 there exists a boolean variable e i,t. We have considered this encoding for solving many types of problems which are elaborated as follows, such as:  Scheduling unit computation tasks in uniprocessor environment  Scheduling preemptive non-unit tasks for uniprocessor environment  Scheduling non-preemptive tasks in uniprocessor environment

10/9/2015 COSC , Lecture 5 11 Scheduling unit computation tasks in uniprocessor environment Consider T={T 1,.., T n } a task set with T i = (S i, c i, d i, p i ). For simplicity, we assume p i =d i. If task T i can execute one time unit between times t, t+1, …, t+c i, then the corresponding SAT clause is e i,t V e i,t+1 V... V e i,t+ci-2 V e i,t+ci-1. Given tasks T i and T j for time between t and t+1, only either T i or T j is executing between t and t+1. Hence, there exists a clause  e i,t V  e j,t (this is equivalent to: e i,t   e j,t and e j,t   e i,t ). The SAT encoding has to be done from 0 to LCM(p 1, p 2, …, p n ).

Scheduling unit computation tasks in uniprocessor environment. Example T 1 : s 1 = 0, c 1 = 1, d 1 = p 1 = 2 T 2 : s 2 = 0, c 2 = 1, d 2 = p 2 = 3 The SAT encoding has to be done by LCM(d 1, d 2 ), that is, 6:  e 1,0 V e 1,1  e 1,2 V e 1,3  e 1,4 V e 1,5  e 2,0 V e 2,1 V e 2,2  e 2,3 V e 2,4 V e 2,5 10/9/2015 COSC , Lecture 5 12   e 1,0 V  e 2,0   e 1,1 V  e 2,1   e 1,2 V  e 2,2   e 1,3 V  e 2,3   e 1,4 V  e 2,4   e 1,5 V  e 2,5

10/9/2015 COSC , Lecture 5 13 Scheduling preemptive non-unit tasks for uniprocessor environment Solution:  Divide each non unit-time task into tasks with unit computation time, then apply the previous SAT encoding.  The starting time and deadline for the subsequent tasks are incremented.  Precedence constraints are introduces between the sub-tasks created.  Consider sub-task j with less precedence than sub- task i then at any time t, sub-task i will not occur after sub-task j is executing, that is,  e j,t V  e i,z where z > t.

Scheduling preemptive non-unit tasks for uniprocessor environment. Example T 1 : s 1 = 0, c 1 = 2, d 1 = p 1 = 4 T 2 : s 2 = 0, c 2 = 2, d 2 = p 2 = 4 The task set is converted to unit computation time:  T 1 =T 1,1 : s 1,1 = 0, c 1,1 = 1, d 1,1 = 3, p 1,1 = 4  T 2 =T 1,2 : s 1,2 = 1, c 1,2 = 1, d 1,2 = 4, p 1,2 = 4  T 3 =T 2,1 : s 2,1 = 0, c 2,1 = 1, d 2,1 = 3, p 2,1 = 4  T 4 =T 2,2 : s 2,2 = 1, c 2,2 = 1, d 2,2 = 4, p 2,2 = 4  The precedence constraints: T 1  T 2, T 3  T 4 10/9/2015 COSC , Lecture 5 14

Scheduling preemptive non-unit tasks for uniprocessor environment. Example  e 1,0 V e 1,1 V e 1,2  e 2,1 V e 2,2 V e 2,3  e 3,0 V e 3,1 V e 3,2  e 4,1 V e 4,2 V e 4,3   e 1,0 V  e 3,0   e 1,1 V  e 2,1   e 1,1 V  e 3,1 10/9/2015 COSC , Lecture 5 15   e 1,1 V  e 4,1   e 1,2 V  e 2,2   e 1,2 V  e 3,2   e 1,2 V  e 4,2  d 1 = 3   e 1,3  s 2 = 1   e 2,0  d 3 = 3   e 3,3  s 4 = 1   e 4,0

10/9/2015 COSC , Lecture 5 16  The precedence constraints:   e 2,1 V  e 1,2   e 4,1 V  e 3,2

10/9/2015 COSC , Lecture 5 17 Scheduling non-preemptive tasks in uniprocessor environment A non-preemptable task is the one that once started cannot be stopped by any other process or task. In practice tasks may contain critical sections that cannot be interrupted. These critical sections are needed to access and modify shared variables or use shared resources. The non-preemptable condition can be obtained by grouping together executing constraints from starting time to deadline with size equal to that of computation time.

10/9/2015 COSC , Lecture 5 18 Scheduling with non-preemption for uniprocessor environment - cont So, a non-preemptable task i is allowed to execute for a computation time c starting at time t until deadline d. Since a non-preemptive task T=(s, c, d, p) cannot not be interrupted, the conversion to the SAT problem should contain all possible solutions for task T to be scheduled in the intervals [s, c], [s + 1,c + 1],..., [d - c, d].

10/9/2015 COSC , Lecture 5 19 Example with two non-preemptive tasks T 1 : s 1 = 0, c 1 = 2, d 1 = 4 T 2 : s 2 = 0, c 2 = 2, d 2 = 4 The SAT encoding is:  T 1 : (e 1,0 Λ e 1,1 Λ  e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ e 1,1 Λ e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ  e 1,1 Λ e 1,2 Λ e 1,3 )  T 2 : (e 2,0 Λ e 2,1 Λ  e 2,2 Λ  e 2,3 ) V  (  e 1,0 Λ e 2,1 Λ e 1,2 Λ  e 2,3 ) V  (  e 1,0 Λ  e 1,1 Λ e 1,2 Λ e 1,3 )

10/9/2015 COSC , Lecture 5 20 Example with two non-preemptive tasks The following are the clauses corresponding to the fact that the processor is busy with at most one task at a given time:   e 1,0 V  e 2,0   e 1,1 V  e 2,1   e 1,2 V  e 2,2   e 1,3 V  e 2,3 Problem: the sub-formula from previous slide is not expressed in CNF, but in DNF (Disjunctive Normal Form).

10/9/2015 COSC , Lecture 5 21 DNF to CNF conversion Some the above clauses are in Disjunctive Normal Form (DNF). They have to be converted into Conjunctive Normal Form (CNF). Once the whole formula is expressed in CNF, it has to be converted into DIMACS format as an input for SAT solvers.

DNF to CNF conversion. Example New variables are introduced for each clause. Example: F = (A 1  A 2  A 3  A 4 )  (A 5  A 6  A 7  A 8 ) is converted to the following CNF formula (X 1 and X 2 are new propositional variables):  (  X 1  A 1 )  (  X 1  A 2 )  (  X 1  A 3 )  (  X 1  A 4 )  (  A 1   A 2   A 3   A 4  X 1 )  (  X 2  A 5 )  (  X 2  A 6 )  (  X 2  A 7 )  (  X 2  A 8 )  (  A 5   A 6   A 7   A 8  X 2 )  X 1  X 2 10/9/2015 COSC , Lecture 5 22

Complexity of this translation The traditional approach for converting a general DNF formula needs an exponential space and time complexity:  (A 1,1  A 1,2  …  A 1,n1 )  …  (A k,1  A k,2  …  A k,nk ) leads to a propositional formula with n 1 * … * n k CNF clauses. The approach from previous slide needs only n 1 + … + n k + k + 1 CNF clauses and k new propositional clauses. 10/9/2015 COSC , Lecture 5 23

DNF to CNF conversion. Example Coming back to the example from slide 18:  T 1 : (e 1,0 Λ e 1,1 Λ  e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ e 1,1 Λ e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ  e 1,1 Λ e 1,2 Λ e 1,3 ) we get the following CNF formula:  (  X 1  e 1,0 )  (  X 1  e 1,1 )  (  X 1   e 1,2 )  (  X 1   e 1,3 )  (  e 1,0   e 1,1  e 1,2  e 1,3  X 1 )  (  X 1   e 1,0 )  (  X 1  e 1,1 )  (  X 1  e 1,2 )  (  X 1   e 1,3 )  (e 1,0   e 1,1   e 1,2  e 1,3  X 1 )  (  X 1   e 1,0 )  (  X 1   e 1,1 )  (  X 1  e 1,2 )  (  X 1  e 1,3 )  (e 1,0  e 1,1   e 1,2   e 1,3  X 1 )  X 1  X 2  X 3 10/9/2015 COSC , Lecture 5 24

10/9/2015 COSC , Lecture 5 25 Some state-of-the-art SAT solvers Siege - zChaff - Cachet - SharpSAT - berlin.de/~thurley/sharpSAT/index.htmlhttp://www2.informatik.hu- berlin.de/~thurley/sharpSAT/index.html Others: If the answer provided by this SAT solver or #SAT solver is ‘Unsatisfiable’, then the corresponding propositional formula is unsatisfiable.

10/9/2015 COSC , Lecture 5 26 The zChaff SAT Solver It is a state-of-the-art SAT solver designed for robustness and efficiency. It features a highly optimized deduction engine. zChaff is designed with performance and capacity in mind. zChaff has been tested on Solaris/Linux/Cygwin machines with g++ as the compiler. It can also be compiled with Visual Studio Net under Windows. zChaff can be compiled into a linkable library for integration purpose so that the users do not need to export instance into intermediate files to use zChaff.

10/9/2015 COSC , Lecture 5 27 DIMACS CNF Format In the format the number of variables and the number of clauses is defined by the line “p cnf VARIABLES CLAUSES”. The variables are assumed to be numbered from 1 up to VARIABLES. It is not necessary that every variable appears in an instance. Each clause will be represented by a sequence of integers, which are separated by a space, a tab, or a new line character. The non-negated version of the variable i is represented by i; the negated version is represented by -i. Each clause is terminated by a value 0.

10/9/2015 COSC , Lecture 5 28 Example The boolean formula F = (v 1 V  v 3 ) Λ (  v 1 V v 2 V v 3 ) has the following DIMACS format: p cnf

10/9/2015 COSC , Lecture 5 29 Tool Description The input of our tool is the number of tasks which are to be scheduled. For each of the tasks it asks for its starting time, computation time and deadline. It develops various clauses using the SAT encoding described in above part. Based on the encoding it passes the DIMACS CNF format file to zChaff SAT Solver which gives whether it is either SAT solvable or not. The output of zChaff also gives the variables which are true, using this variables we can schedule the tasks.

10/9/2015 COSC , Lecture 5 30 Running the Code Compile the zChaff code obtained from the Internet using the make command in C++ compiler and keep it inside a folder zchaff. Inside the zchaff folder create a folder called Translate. Add all the Java source code in this folder. Compile the java source code using javac *.java in J2SE. Then run the Main class file from zchaff folder using java Translate/Main

10/9/2015 COSC , Lecture 5 31 Experimental Results

10/9/2015 COSC , Lecture 5 32 The experimental results - comments The number of tasks in the original column are converted into unit computation time tasks and thus increasing the number of tasks in the for preemption column. The increase in the number of tasks increases the size of SAT and thus affects the performance of the SAT solver. It can be seen from the above results that the performance is faster if there are fewer tasks.

10/9/2015 COSC , Lecture 5 33 Conclusion We have explored the potential of satisfiability to be used as a tool for modeling and solving scheduling problems. We have also researched on the earlier work and proven that we need to consider computation time so as to make it suitable for real time systems. We have presented experimental results on the performance of SAT solver zChaff. The performance of the SAT decreases as the number of tasks increases. We have demonstrated that a SAT solver presents a competitive alternative as a tool to find optimal solutions to the NP-complete time constrained scheduling problem.

10/9/2015 COSC , Lecture 5 34 Future work We would like to consider the other categories of tasks set constraints. Also adding resourses constraints would make the system more suitable for real time systems. Minimize the number of preemptions (selects the solution provided by the SAT solver that has the minimum number of preemptions). Assuming there are new tasks added to the initial specification, design an incremental conversion to SAT without repeating the time spend for the initial tasks set).

10/9/2015 COSC , Lecture 5 35 Summary A Satisfiability Approach for the Scheduling Problem

10/9/2015 COSC , Lecture 5 36 Reading suggestions Research papers  Ştefan Andrei: Schedulability Analysis

10/9/2015 COSC , Lecture 5 37 Coming up next An Efficient Power-Aware Scheduling Algorithm for the Multiprocessor Platform

10/9/2015 COSC , Lecture 5 38 Thank you for your attention! Questions?