ravensat 1.0.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ravensat/ast/node.rb +10 -3
- data/lib/ravensat/claw.rb +3 -0
- data/lib/ravensat/solver.rb +4 -2
- data/lib/ravensat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53ca35aa21cc9c623de888c201c19d54146d586c34a549db7dab634e16ad3d6
|
4
|
+
data.tar.gz: bf87c8b08b9be42c7c9fbf7b1bddbfc88293ad266a8f190e1d8479e7131e1277
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1e524ea817f9f6ab63892e9c608b6aea58d7b499dc0db5275d9634206680de45a1e2a22c0e19f78b6efaff5fd5e972a164dded7e19d1ffde10785e60e2c5156
|
7
|
+
data.tar.gz: 06a06b8914d6d654c127b4b36e94afe84cfbfe322f50717d3d3cbbfb1598e8726c05155ecf624b21fc765ac3e32b003ab0374f806555255499b31778c674a7b1
|
data/lib/ravensat/ast/node.rb
CHANGED
@@ -14,6 +14,8 @@ module Ravensat
|
|
14
14
|
current_parent, current_children = node_stack.pop
|
15
15
|
current_node = current_children.shift
|
16
16
|
|
17
|
+
and_node_obj = AndNode.new
|
18
|
+
|
17
19
|
case current_node
|
18
20
|
when AndNode
|
19
21
|
node_stack.push [current_parent, current_children.clone]
|
@@ -26,7 +28,7 @@ module Ravensat
|
|
26
28
|
yield(current_node.children.first)
|
27
29
|
|
28
30
|
if current_children.empty?
|
29
|
-
yield(
|
31
|
+
yield(and_node_obj)
|
30
32
|
else
|
31
33
|
yield(current_parent)
|
32
34
|
node_stack.push [current_parent, current_children.clone]
|
@@ -35,7 +37,7 @@ module Ravensat
|
|
35
37
|
yield(current_node)
|
36
38
|
|
37
39
|
if current_children.empty?
|
38
|
-
yield(
|
40
|
+
yield(and_node_obj)
|
39
41
|
else
|
40
42
|
yield(current_parent)
|
41
43
|
node_stack.push [current_parent, current_children.clone]
|
@@ -88,7 +90,12 @@ module Ravensat
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def clauses_size
|
91
|
-
|
93
|
+
cnt = 0
|
94
|
+
self.each_by_descriptive do |node|
|
95
|
+
cnt+=1 if node.is_a? AndNode
|
96
|
+
end
|
97
|
+
cnt
|
98
|
+
# self.count{|node| node.is_a? AndNode} + 1
|
92
99
|
end
|
93
100
|
end
|
94
101
|
end
|
data/lib/ravensat/claw.rb
CHANGED
@@ -5,6 +5,7 @@ module Ravensat
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.pairwise_amo(bool_vars)
|
8
|
+
return bool_vars.first if bool_vars.size == 1
|
8
9
|
bool_vars.combination(2).map do |e|
|
9
10
|
e.map(&:~@).reduce(:|)
|
10
11
|
end.reduce(:&)
|
@@ -12,6 +13,8 @@ module Ravensat
|
|
12
13
|
|
13
14
|
# NOTE: Klieber, W. and Kwon, G.: Efficient CNF Encoding for Selecting 1 from N Objects (2007).
|
14
15
|
def self.commander_amo(bool_vars)
|
16
|
+
return bool_vars.first if bool_vars.size == 1
|
17
|
+
# XXX: Operator unknown if bool_vars.size is very small.
|
15
18
|
m = bool_vars.size / 2
|
16
19
|
commander_variables = []
|
17
20
|
formula = Ravensat::InitialNode.new
|
data/lib/ravensat/solver.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
module Ravensat
|
4
5
|
class Solver
|
@@ -7,7 +8,7 @@ module Ravensat
|
|
7
8
|
@name = default_solver_name
|
8
9
|
end
|
9
10
|
|
10
|
-
def solve( cnf )
|
11
|
+
def solve( cnf , solver_log: false)
|
11
12
|
encoder = DimacsEncoder.new
|
12
13
|
@input_file = Tempfile.open(["ravensat",".cnf"])
|
13
14
|
@output_file = Tempfile.open(["ravensat",".mdl"])
|
@@ -19,7 +20,8 @@ module Ravensat
|
|
19
20
|
when "arcteryx"
|
20
21
|
Arcteryx.solve(@input_file.to_path, @output_file.to_path)
|
21
22
|
else
|
22
|
-
|
23
|
+
result, err, status = Open3.capture3("#{@name} #{@input_file.to_path} #{@output_file.to_path}")
|
24
|
+
puts result if solver_log
|
23
25
|
end
|
24
26
|
|
25
27
|
decoder = DimacsDecoder.new
|
data/lib/ravensat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ravensat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rikuto matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|