Sat solving maximization and minimization problems
-
Upload
henry-barlow -
Category
Documents
-
view
53 -
download
4
description
Transcript of Sat solving maximization and minimization problems
SAT SOLVING MAXIMIZATION AND MINIMIZATION PROBLEMS
Student: Victoria Kravchenko
Supervisors: Prof. Yoram Moses
Liat Atsmon
The Project GoalStudy and evaluate the approach of solving optimization problems through SAT reduction, and using SAT solvers to solve the reduced problems.
SAT Boolean satisfiability problem
(x1+x5’+x4) (x1’+x5+x3+x4) (x3’+x4’) NP-Complete CNF (Conjunctive Normal Form) – “AND
of ORs”
MiniSat Developed at 2003 by
Niklas Eén and Niklas Sörensson
Advantages: open-source, successful, small.
The MiniSat input formFor: (x1+x5’+x4) (x1’+x5+x3+x4) (x3’+x4’)
p cnf 5 3 → p cnf number_of_variables number_of_clauses
1 -5 4 0 → 0 is the end of the clause
-1 5 3 4 0
-3 -4 0
The Project PART 1: Equation Checker
PART 2: SAT with Optimization
PART 3: Maximal Acyclic Subgraph
The equation checker Input: X, Y, Z – decimal numbers Output: whether X+Y=Z or not
Calculates the binary form
of the numbers The program prepares
the input for MiniSatusing the table:
1
0 0 0 0 0
0 1 0 1 0
1 1 0 0 1
0 0 1 1 0
0 1 1 0 1
1 1 1 1 1
i i i i iX Y C Z C
For the LSB bit:
The equation checker
0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Z
Z X Y X Y X Y
f X Y X Y Z X Y X Y Z
X Y X Y Z X Y X Y Z
X Y Z X Y Z X Y Z X Y Z
0
0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Z
Z
f X Y Z X Y Z X Y Z X Y Z
f X Y Z X Y Z X Y Z X Y Z
00 0 0
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0
ZX Y Z f
The equation checker
0
0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0C
C X Y
f X Y C X Y C X Y C X Y C X Y C X C Y C
00 0 0
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
CX Y C f
0
0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
C
C
f X Y C X Y C X Y C X Y C
f X Y C X Y C
X Y C X Y C
SAT with Optimization Input: Vec – x0,x1,x2,…
Phi – CNF expression Output: maximal value of Vec (as a
binary number) which satisfies Phi
SAT with Optimization Versions:
I. Bit by Bit:
II. MiniSat condition:
MSB1?1 1?0 1?
? ? ?? ?
?1
1 0 01 0
1
0 11 1
Maximal Acyclic Subgraph Input: graph name
nodes – [node_number],[node_weight]
edges – [node_from],[node_to]
For example: ex1 1,2-2,2-3,1 1,2-2,3-3,1
1 (2)
3 (1)
2 (2)
Maximal Acyclic Subgraph Output: maximal acyclic subgraph
1 (2)
3 (1)
2 (2)
Example 11
(1)
3 (2)
2 (2)
5 (3)
4 (3)
lsg ex1 1,1-2,2-3,2-4,3-5,3 1,2-1,3-2,3-2,4-4,5-5,3
P
Example 21
(1)
3 (2)
2 (2)
5 (3)
4 (3)
lsg ex2 1,1-2,2-3,2-4,3-5,3 1,2-3,1-2,3-2,4-4,5-5,3
Example 31
(2)
3 (2)
2 (1)
5 (3)
4 (3)
lsg ex3 1,2-2,1-3,2-4,3-5,3 1,2-3,1-2,3-2,4-4,5-5,3
Example 41
(1)
3 (2)
2 (2)
5 (3)
4 (3)
lsg ex4 1,1-2,2-3,2-4,3-5,3 1,2-3,1-2,3-2,4-4,5-5,2-5,3
Example 51
(1)
3 (2)
2 (4)
5 (1)
4 (3)
lsg ex5 1,1-2,4-3,2-4,3-5,1 1,2-3,1-2,3-2,4-4,5-5,2-5,3
How Does It Work?For each edge: Define: [node_from] > [node_to]
Condition: Translate the condition to CNF using a tree
(reduction to 3-SAT)
0 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 2 2 ...
X Y
x y x y x y x y x y x y x y x y x y
X Y X Y
How Does It Work?Building the weighted sum: [node] x [weight]:
Y1[m vars] ↔ X1[node number] x W1[m vars]
Y2[m vars] ↔ X2[node number] x W2[m vars]
Sum the intermediate variables as in the Equation Checker: Z1[m vars] ↔ Y1[m vars] + Y2[m vars]
Continue summing: Z2[m vars] ↔ Z1[m vars] + Y3[m vars]
Save the last intermediate variables representing the accumulated sum: Z(n-1) [m vars] ↔ Z(n-2) [m vars] + Yn[m vars]
Zfinal ↔ X1*W1 + X2*W2 + … + Xn*Wn
How Does It Work?
Get a result from the MiniSat using only the edges conditions and extract the weight Wres
Demand a new result with a greater weight s.t. Zfinal > Wres
Continue until the conditions can not be saturated
Results
50 100 150 200 250 300 350 400 450 500 550 60012:00:00 AM
12:00:43 AM
12:01:26 AM
12:02:09 AM
12:02:52 AM
12:03:36 AM
12:04:19 AM
12:05:02 AM
12:05:45 AM
12:06:28 AM
12:00:10 AM12:00:16 AM12:00:28 AM
12:00:40 AM12:00:50 AM
12:01:08 AM
12:01:46 AM
12:02:24 AM
12:03:02 AM
12:03:39 AM
12:04:47 AM
12:05:55 AM
Run Time vs. Number of Edges (50 Nodes)
Run Time
Poly (order 4)
Exp
Edges
Tim
e
Results
50 100 150 200 250 30000:00:00
00:01:26
00:02:52
00:04:19
00:05:45
00:07:12
00:08:38
00:10:04
00:11:31
00:03:4800:04:09
00:05:56
00:07:25
00:08:30
00:10:31
Run Time vs. Number of Edges (200 Nodes)
Run Time
Poly (order 4)
Exp
Edges
Tim
e
Results
50 100 150 200 250 30000:00:00
00:01:26
00:02:52
00:04:19
00:05:45
00:07:12
00:08:38
00:10:04
00:11:31
00:12:57
00:00:1000:00:41
00:02:19
00:03:25
00:06:39
00:11:10
Run Time vs. Number of Nodes (50 Edges)
Run Time
Poly (order 3)
Exp
Nodes
Tim
e
Results
50 100 150 200 250 30000:00:00
00:02:52
00:05:45
00:08:38
00:11:31
00:14:24
00:17:16
00:20:09
00:00:40
00:02:01
00:05:05
00:07:25
00:11:39
00:17:12
Run Time vs. Number of Nodes (200 Edges)
Run Time
Poly (order 2)
Exp
Nodes
Tim
e
Conclusions The graphs are polynomial and not
exponential although the problem in NP complete – success!
Nodes have a stronger effect on the run time.
Thank you for your attention!