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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fe48515db2ce222168fac2854fcab5b2057c84336195e129e6c532ab519082e
4
- data.tar.gz: bc265a79298a55684d1bb1c83a196e0530b4670515c22d4388f65bdf7b872c67
3
+ metadata.gz: e53ca35aa21cc9c623de888c201c19d54146d586c34a549db7dab634e16ad3d6
4
+ data.tar.gz: bf87c8b08b9be42c7c9fbf7b1bddbfc88293ad266a8f190e1d8479e7131e1277
5
5
  SHA512:
6
- metadata.gz: 7d715763470fe222f0ba71c998e27a43f8e40c04ae50cadceae48b324a962eaa75ceef92f02154cc74f9e04edbae47de1f36eb6e3c655019c0f3fedd72aae448
7
- data.tar.gz: d2178778880fa55127ef5bd0b2b5d76fa5431452d20f06b0672374a99f9a718a881c01c1c055b11579c86e063decc607416c0f3450213f460dac756e28cc201c
6
+ metadata.gz: b1e524ea817f9f6ab63892e9c608b6aea58d7b499dc0db5275d9634206680de45a1e2a22c0e19f78b6efaff5fd5e972a164dded7e19d1ffde10785e60e2c5156
7
+ data.tar.gz: 06a06b8914d6d654c127b4b36e94afe84cfbfe322f50717d3d3cbbfb1598e8726c05155ecf624b21fc765ac3e32b003ab0374f806555255499b31778c674a7b1
@@ -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
@@ -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
@@ -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
- system("#{@name} #{@input_file.to_path} #{@output_file.to_path}")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ravensat
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.4"
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.1
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-07-22 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: