ravensat 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -13
  3. data/docs/Arcteryx/CNF.html +827 -0
  4. data/docs/Arcteryx.html +309 -0
  5. data/docs/Ravensat/AndNode.html +159 -0
  6. data/docs/Ravensat/Claw.html +338 -0
  7. data/docs/Ravensat/DimacsDecoder.html +224 -0
  8. data/docs/Ravensat/DimacsEncoder.html +425 -0
  9. data/docs/Ravensat/Extension/BooleanVariable.html +229 -0
  10. data/docs/Ravensat/Extension/Domain.html +319 -0
  11. data/docs/Ravensat/Extension/IntegerVariable.html +589 -0
  12. data/docs/Ravensat/Extension/UndefinedVariable.html +236 -0
  13. data/docs/Ravensat/Extension/Variable.html +443 -0
  14. data/docs/Ravensat/Extension.html +141 -0
  15. data/docs/Ravensat/InitialNode.html +267 -0
  16. data/docs/Ravensat/Node.html +780 -0
  17. data/docs/Ravensat/NotNode.html +159 -0
  18. data/docs/Ravensat/OprNode.html +226 -0
  19. data/docs/Ravensat/OrNode.html +252 -0
  20. data/docs/Ravensat/Solver.html +373 -0
  21. data/docs/Ravensat/VarNode.html +488 -0
  22. data/docs/Ravensat.html +135 -0
  23. data/docs/_index.html +329 -0
  24. data/docs/class_list.html +51 -0
  25. data/docs/css/common.css +1 -0
  26. data/docs/css/full_list.css +58 -0
  27. data/docs/css/style.css +497 -0
  28. data/docs/file.README.html +233 -0
  29. data/docs/file_list.html +56 -0
  30. data/docs/frames.html +17 -0
  31. data/docs/index.html +233 -0
  32. data/docs/js/app.js +314 -0
  33. data/docs/js/full_list.js +216 -0
  34. data/docs/js/jquery.js +4 -0
  35. data/docs/method_list.html +523 -0
  36. data/docs/top-level-namespace.html +110 -0
  37. data/lib/ravensat/ast/node.rb +10 -10
  38. data/lib/ravensat/ast/not_node.rb +3 -0
  39. data/lib/ravensat/claw.rb +44 -0
  40. data/lib/ravensat/dimacs/dimacs_encoder.rb +1 -1
  41. data/lib/ravensat/extension/variable/integer_variable.rb +3 -3
  42. data/lib/ravensat/version.rb +1 -1
  43. data/lib/ravensat.rb +1 -1
  44. metadata +37 -3
  45. data/lib/ravensat/ravenclaw.rb +0 -19
@@ -0,0 +1,44 @@
1
+ module Ravensat
2
+ module Claw
3
+ def self.alo(bool_vars)
4
+ bool_vars.reduce(:|)
5
+ end
6
+
7
+ def self.pairwise_amo(bool_vars)
8
+ bool_vars.combination(2).map do |e|
9
+ e.map(&:~@).reduce(:|)
10
+ end.reduce(:&)
11
+ end
12
+
13
+ def self.commander_amo(bool_vars)
14
+ m = bool_vars.size / 2
15
+ introductory_variables = []
16
+ formula = Ravensat::InitialNode.new
17
+ bool_vars.each_slice(2) do |e|
18
+ c = Ravensat::VarNode.new
19
+ subset = e << ~c
20
+ formula &= pairwise_amo(subset)
21
+ formula &= alo(subset)
22
+ introductory_variables << c
23
+ end
24
+
25
+ if m < 6
26
+ formula &= pairwise_amo(introductory_variables)
27
+ else
28
+ formula &= commander_amo(introductory_variables)
29
+ end
30
+ end
31
+
32
+ def self.all_different(*int_vars)
33
+ int_vars.combination(2).map do |int_var|
34
+ int_var.reduce(:!=)
35
+ end.reduce(:&)
36
+ end
37
+
38
+ def self.all_only_one(*int_vars)
39
+ int_vars.map(&:only_one).reduce(:&)
40
+ end
41
+
42
+ # alias :amo :pairwise_amo
43
+ end
44
+ end
@@ -11,7 +11,7 @@ module Ravensat
11
11
  dimacs_header = "p cnf #{formula.vars_size} #{formula.clauses_size}\n"
12
12
  dimacs_body = ""
13
13
  create_table(formula)
14
- formula.each_with_clause do |node|
14
+ formula.each do |node|
15
15
  case node
16
16
  when AndNode then dimacs_body << " 0\n"
17
17
  when OrNode then dimacs_body << " "
@@ -18,7 +18,7 @@ module Ravensat
18
18
  duplicated_keys = self.var_nodes.keys & object.var_nodes.keys
19
19
 
20
20
  [self.var_nodes, object.var_nodes].repeated_permutation(duplicated_keys.size) do |var_nodes|
21
- result_formula &= Ravensat::RavenClaw.alo(var_nodes.zip(duplicated_keys).map{|arr| arr.first[arr.last]})
21
+ result_formula &= Ravensat::Claw.alo(var_nodes.zip(duplicated_keys).map{|arr| arr.first[arr.last]})
22
22
  end
23
23
  return result_formula
24
24
  else
@@ -45,8 +45,8 @@ module Ravensat
45
45
 
46
46
  def only_one
47
47
  result_formula = Ravensat::InitialNode.new
48
- result_formula &= Ravensat::RavenClaw.alo @var_nodes.values
49
- result_formula &= Ravensat::RavenClaw.amo @var_nodes.values
48
+ result_formula &= Ravensat::Claw.alo @var_nodes.values
49
+ result_formula &= Ravensat::Claw.amo @var_nodes.values
50
50
  result_formula
51
51
  end
52
52
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ravensat
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
data/lib/ravensat.rb CHANGED
@@ -11,7 +11,7 @@ module Ravensat
11
11
  require_relative ravensat + "/dimacs.rb"
12
12
 
13
13
  autoload :Solver, ravensat + '/solver.rb'
14
- autoload :RavenClaw, ravensat + '/ravenclaw.rb'
14
+ autoload :Claw, ravensat + '/claw.rb'
15
15
  autoload :Extension, ravensat + '/extension.rb'
16
16
 
17
17
  autoload :Arcteryx, arcteryx + '/arcteryx.rb'
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: 0.3.1
4
+ version: 0.3.2
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-05-24 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -29,6 +29,40 @@ files:
29
29
  - Rakefile
30
30
  - bin/console
31
31
  - bin/setup
32
+ - docs/Arcteryx.html
33
+ - docs/Arcteryx/CNF.html
34
+ - docs/Ravensat.html
35
+ - docs/Ravensat/AndNode.html
36
+ - docs/Ravensat/Claw.html
37
+ - docs/Ravensat/DimacsDecoder.html
38
+ - docs/Ravensat/DimacsEncoder.html
39
+ - docs/Ravensat/Extension.html
40
+ - docs/Ravensat/Extension/BooleanVariable.html
41
+ - docs/Ravensat/Extension/Domain.html
42
+ - docs/Ravensat/Extension/IntegerVariable.html
43
+ - docs/Ravensat/Extension/UndefinedVariable.html
44
+ - docs/Ravensat/Extension/Variable.html
45
+ - docs/Ravensat/InitialNode.html
46
+ - docs/Ravensat/Node.html
47
+ - docs/Ravensat/NotNode.html
48
+ - docs/Ravensat/OprNode.html
49
+ - docs/Ravensat/OrNode.html
50
+ - docs/Ravensat/Solver.html
51
+ - docs/Ravensat/VarNode.html
52
+ - docs/_index.html
53
+ - docs/class_list.html
54
+ - docs/css/common.css
55
+ - docs/css/full_list.css
56
+ - docs/css/style.css
57
+ - docs/file.README.html
58
+ - docs/file_list.html
59
+ - docs/frames.html
60
+ - docs/index.html
61
+ - docs/js/app.js
62
+ - docs/js/full_list.js
63
+ - docs/js/jquery.js
64
+ - docs/method_list.html
65
+ - docs/top-level-namespace.html
32
66
  - example/magic_square_3x3.rb
33
67
  - exe/ravensat
34
68
  - lib/arcteryx/arcteryx.rb
@@ -42,6 +76,7 @@ files:
42
76
  - lib/ravensat/ast/opr_node.rb
43
77
  - lib/ravensat/ast/or_node.rb
44
78
  - lib/ravensat/ast/var_node.rb
79
+ - lib/ravensat/claw.rb
45
80
  - lib/ravensat/dimacs.rb
46
81
  - lib/ravensat/dimacs/dimacs_decoder.rb
47
82
  - lib/ravensat/dimacs/dimacs_encoder.rb
@@ -51,7 +86,6 @@ files:
51
86
  - lib/ravensat/extension/variable/integer_variable.rb
52
87
  - lib/ravensat/extension/variable/undefined_variable.rb
53
88
  - lib/ravensat/extension/variable/variable.rb
54
- - lib/ravensat/ravenclaw.rb
55
89
  - lib/ravensat/solver.rb
56
90
  - lib/ravensat/version.rb
57
91
  - ravensat.gemspec
@@ -1,19 +0,0 @@
1
- module Ravensat
2
- module RavenClaw
3
- def self.alo(bool_vars)
4
- bool_vars.reduce(:|)
5
- end
6
-
7
- def self.amo(bool_vars)
8
- bool_vars.combination(2).map do |e|
9
- e.map(&:~@).reduce(:|)
10
- end.reduce(:&)
11
- end
12
-
13
- def self.all_different(*int_vars)
14
- int_vars.combination(2).map do |int_var|
15
- int_var.reduce(:!=)
16
- end.reduce(:&)
17
- end
18
- end
19
- end