ravensat 1.0.2 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78a4fe449b52b526589311a1d8bd4203e121e0d490ff86a870f08833328bda05
4
- data.tar.gz: f7dfe20367b98c416ed30cdbf4061b1662268181007f188942d6f393d0aff687
3
+ metadata.gz: 56180e12d568856b7aecc556c6351157b35214ee2b8baccfbdf7069db9f87f11
4
+ data.tar.gz: 61d38033566cc2c5683300765589938e45e2a8140b9fc74646ca7cb9f838818a
5
5
  SHA512:
6
- metadata.gz: c7a341443b901bb3d3717a380af641956d7d9552d217e88250c6146f5fa9f1c0dd81fef9db5f5f38b37dca40f092030c6c99ef967ba534816e7a160b3525074e
7
- data.tar.gz: 4d994c5983f2d66d988140aec41385533039dac96e62c6952416604efa2ecf9ede311241a6e4c5eb322da8396128f44ff6b5fcf3f8a55e36ea4ce5d8a0ea6be2
6
+ metadata.gz: 6ad53a3be42a987284db8d89f5e3fa4da21097e6c019c82e3fb34f49718b2907de49f9235922dd1892e318d94f193fba2b899b5317e5da780fceb1894cddbfb9
7
+ data.tar.gz: 38439434b8b7e40492743a7ee5b8815ffe71adfe8894ec678761c041af0e49db0f81e8ea684d5d3e4aef5288a68ff46796c871ccab9e9b349c424da3d0cdc500
@@ -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(node_stack.last.first)
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(node_stack.last.first)
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
- self.count{|node| node.is_a? AndNode} + 1
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
@@ -4,7 +4,20 @@ module Ravensat
4
4
  bool_vars.reduce(:|)
5
5
  end
6
6
 
7
+ def self.at_most_k(bool_vars, k)
8
+ bool_vars.combination(k+1).map do |e|
9
+ e.map(&:~@).reduce(:|)
10
+ end.reduce(:&)
11
+ end
12
+
13
+ def self.at_least_k(bool_vars, k)
14
+ bool_vars.combination(k-1).map do |e|
15
+ alo(bool_vars - e)
16
+ end.reduce(:&)
17
+ end
18
+
7
19
  def self.pairwise_amo(bool_vars)
20
+ return bool_vars.first if bool_vars.size == 1
8
21
  bool_vars.combination(2).map do |e|
9
22
  e.map(&:~@).reduce(:|)
10
23
  end.reduce(:&)
@@ -12,6 +25,8 @@ module Ravensat
12
25
 
13
26
  # NOTE: Klieber, W. and Kwon, G.: Efficient CNF Encoding for Selecting 1 from N Objects (2007).
14
27
  def self.commander_amo(bool_vars)
28
+ return bool_vars.first if bool_vars.size == 1
29
+ # XXX: Operator unknown if bool_vars.size is very small.
15
30
  m = bool_vars.size / 2
16
31
  commander_variables = []
17
32
  formula = Ravensat::InitialNode.new
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ravensat
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.5"
5
5
  end
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.2
4
+ version: 1.0.5
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-07-29 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: