ravensat 1.0.8 → 1.0.9
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/and_node.rb +2 -0
- data/lib/ravensat/ast/initial_node.rb +4 -0
- data/lib/ravensat/ast/nil_node.rb +17 -0
- data/lib/ravensat/ast/node.rb +4 -0
- data/lib/ravensat/ast/or_node.rb +2 -0
- data/lib/ravensat/ast.rb +1 -0
- data/lib/ravensat/claw.rb +5 -5
- data/lib/ravensat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b668d5f3c3a44e355f1cab471199b0ab4124a504e38081c40b33348b8d1611d
|
4
|
+
data.tar.gz: 9c622647b2a9bc34881178cbd546f332f882a07e8b2242c3c37e3f94e437c2c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 986c50547e5026650eef971aaa706a8d7515e5a6e861d3c027ce6b273b56094448c62fcd796b6f9dd2734d96f10cde2e5ba7bd0ac58ac389e16ad5404a0cd623
|
7
|
+
data.tar.gz: 3a29d33a8761a862c8bf04ce69aa8b64c8241a64f867c1ee337eedf311eeafad2ffee899db6e1f3c544a0cec5df17ce554b24b16c125ca1181b1cb7b260ad099
|
@@ -2,11 +2,15 @@ module Ravensat
|
|
2
2
|
class InitialNode < Node
|
3
3
|
def &(object)
|
4
4
|
raise TypeError.new("#{object.class} can't be coerced into Ravensat::Node") unless object.is_a? Node
|
5
|
+
return self if object.is_a? NilNode
|
6
|
+
|
5
7
|
object
|
6
8
|
end
|
7
9
|
|
8
10
|
def |(object)
|
9
11
|
raise TypeError.new("#{object.class} can't be coerced into Ravensat::Node") unless object.is_a? Node
|
12
|
+
return self if object.is_a? NilNode
|
13
|
+
|
10
14
|
object
|
11
15
|
end
|
12
16
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Ravensat
|
2
|
+
class NilNode < Node
|
3
|
+
def initialize
|
4
|
+
@children = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def &(object)
|
8
|
+
raise TypeError.new("#{object.class} can't be coerced into Ravensat::Node") unless object.is_a? Node
|
9
|
+
object
|
10
|
+
end
|
11
|
+
|
12
|
+
def |(object)
|
13
|
+
raise TypeError.new("#{object.class} can't be coerced into Ravensat::Node") unless object.is_a? Node
|
14
|
+
object
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/ravensat/ast/node.rb
CHANGED
@@ -64,11 +64,15 @@ module Ravensat
|
|
64
64
|
|
65
65
|
def &(object)
|
66
66
|
raise TypeError.new("#{object.class} can't be coerced into Ravensat::Node") unless object.is_a? Node
|
67
|
+
return self if object.is_a? NilNode
|
68
|
+
|
67
69
|
AndNode.new(self, object)
|
68
70
|
end
|
69
71
|
|
70
72
|
def |(object)
|
71
73
|
raise TypeError.new("#{object.class} can't be coerced into Ravensat::Node") unless object.is_a? Node
|
74
|
+
return self if object.is_a? NilNode
|
75
|
+
|
72
76
|
OrNode.new(self, object)
|
73
77
|
end
|
74
78
|
|
data/lib/ravensat/ast/or_node.rb
CHANGED
data/lib/ravensat/ast.rb
CHANGED
data/lib/ravensat/claw.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
module Ravensat
|
2
2
|
module Claw
|
3
3
|
def self.alo(bool_vars)
|
4
|
-
return
|
4
|
+
return Ravensat::NilNode.new if bool_vars.size == 1
|
5
5
|
bool_vars.reduce(:|)
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.at_most_k(bool_vars, k)
|
9
|
-
return
|
9
|
+
return Ravensat::NilNode.new if bool_vars.size == 1
|
10
10
|
bool_vars.combination(k+1).map do |e|
|
11
11
|
e.map(&:~@).reduce(:|)
|
12
12
|
end.reduce(:&)
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.at_least_k(bool_vars, k)
|
16
|
-
return
|
16
|
+
return Ravensat::NilNode.new if bool_vars.size == 1
|
17
17
|
bool_vars.combination(k-1).map do |e|
|
18
18
|
alo(bool_vars - e)
|
19
19
|
end.reduce(:&)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.pairwise_amo(bool_vars)
|
23
|
-
return
|
23
|
+
return Ravensat::NilNode.new if bool_vars.size == 1
|
24
24
|
bool_vars.combination(2).map do |e|
|
25
25
|
e.map(&:~@).reduce(:|)
|
26
26
|
end.reduce(:&)
|
@@ -28,7 +28,7 @@ module Ravensat
|
|
28
28
|
|
29
29
|
# NOTE: Klieber, W. and Kwon, G.: Efficient CNF Encoding for Selecting 1 from N Objects (2007).
|
30
30
|
def self.commander_amo(bool_vars)
|
31
|
-
return
|
31
|
+
return Ravensat::NilNode.new if bool_vars.size == 1
|
32
32
|
# XXX: Operator unknown if bool_vars.size is very small.
|
33
33
|
m = bool_vars.size / 2
|
34
34
|
commander_variables = []
|
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.9
|
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-08-
|
11
|
+
date: 2022-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/ravensat/ast.rb
|
71
71
|
- lib/ravensat/ast/and_node.rb
|
72
72
|
- lib/ravensat/ast/initial_node.rb
|
73
|
+
- lib/ravensat/ast/nil_node.rb
|
73
74
|
- lib/ravensat/ast/node.rb
|
74
75
|
- lib/ravensat/ast/not_node.rb
|
75
76
|
- lib/ravensat/ast/opr_node.rb
|