ravensat 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -13
- data/docs/Arcteryx/CNF.html +827 -0
- data/docs/Arcteryx.html +309 -0
- data/docs/Ravensat/AndNode.html +159 -0
- data/docs/Ravensat/Claw.html +338 -0
- data/docs/Ravensat/DimacsDecoder.html +224 -0
- data/docs/Ravensat/DimacsEncoder.html +425 -0
- data/docs/Ravensat/Extension/BooleanVariable.html +229 -0
- data/docs/Ravensat/Extension/Domain.html +319 -0
- data/docs/Ravensat/Extension/IntegerVariable.html +589 -0
- data/docs/Ravensat/Extension/UndefinedVariable.html +236 -0
- data/docs/Ravensat/Extension/Variable.html +443 -0
- data/docs/Ravensat/Extension.html +141 -0
- data/docs/Ravensat/InitialNode.html +267 -0
- data/docs/Ravensat/Node.html +780 -0
- data/docs/Ravensat/NotNode.html +159 -0
- data/docs/Ravensat/OprNode.html +226 -0
- data/docs/Ravensat/OrNode.html +252 -0
- data/docs/Ravensat/Solver.html +373 -0
- data/docs/Ravensat/VarNode.html +488 -0
- data/docs/Ravensat.html +135 -0
- data/docs/_index.html +329 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +497 -0
- data/docs/file.README.html +233 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +233 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +523 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/ravensat/ast/node.rb +10 -10
- data/lib/ravensat/ast/not_node.rb +3 -0
- data/lib/ravensat/claw.rb +44 -0
- data/lib/ravensat/dimacs/dimacs_encoder.rb +1 -1
- data/lib/ravensat/extension/variable/integer_variable.rb +3 -3
- data/lib/ravensat/version.rb +1 -1
- data/lib/ravensat.rb +1 -1
- metadata +37 -3
- data/lib/ravensat/ravenclaw.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f369c1036cde3ea2ff754109809d5b4ce62f826a2ab409e9ec19fdd07ff341dc
|
4
|
+
data.tar.gz: 76df72fb98e5140fcd1b2b394643f23de5218ea47f4ec03f450dc0a05074f801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b59a47f2b7a899e49d506f839c892178523ea3920e611278e0f31399dc1c0e5c868bb8f8a74adab5a848f26f2d2efb8779f6391a20ec566ec177a1fdacfb4565
|
7
|
+
data.tar.gz: 9ed85ceb8abc589197c9241679bb5c5486ce525e427d91f84568dcc4b4ab7a58b0d110688cba999d78dacc9fd0e067d6e4f3908ef87d2d3851ed7c30331d22ca
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Ravensat
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![GitHub Actions](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml/badge.svg)](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/ravensat.svg)](https://badge.fury.io/rb/ravensat)
|
5
5
|
[![LICENSE](https://img.shields.io/github/license/matsuda0528/ravensat)](https://opensource.org/licenses/MIT)
|
6
6
|
|
7
|
+
[![GitHub Pages](https://img.shields.io/badge/GitHub%20Pages--brightgreen.svg?logo=github&style=social)](https://matsuda0528.github.io/ravensat/)
|
8
|
+
|
7
9
|
Ravensat is an interface to SAT solver in Ruby.
|
8
10
|
|
9
11
|
In order to use Ravensat, you need to install SAT solver.
|
@@ -14,9 +16,8 @@ About [SAT](https://en.wikipedia.org/wiki/Boolean_satisfiability_problem), [SAT
|
|
14
16
|
## Description
|
15
17
|
To solve SAT, we usually use SAT solver.
|
16
18
|
Now, let's solve the following SAT with SAT solver.
|
17
|
-
|
18
|
-
|
19
|
-
</p>
|
19
|
+
|
20
|
+
$$(p_{1} \lor \lnot p_{5} \lor p_{4}) \land (\lnot p_{1} \lor p_{5} \lor p_{3} \lor p_{4}) \land (\lnot p_{3} \lor \lnot p_{4})$$
|
20
21
|
|
21
22
|
Most SAT solvers are input in [DIMACS Format](https://www.cs.utexas.edu/users/moore/acl2/manuals/current/manual/index-seo.php/SATLINK____DIMACS).
|
22
23
|
Converting the example SAT to DIMACS Format yields the following.
|
@@ -27,6 +28,7 @@ p cnf 5 3
|
|
27
28
|
-1 5 3 4 0
|
28
29
|
-3 -4 0
|
29
30
|
```
|
31
|
+
|
30
32
|
DIMACS Format is widely distributed as an I/O format for SAT solver.
|
31
33
|
However, when solving a large SAT, the following problems occur.
|
32
34
|
- Need to create a file with thousands of lines.
|
@@ -34,16 +36,18 @@ However, when solving a large SAT, the following problems occur.
|
|
34
36
|
|
35
37
|
To solve these problems, Ravensat can be used.
|
36
38
|
Using Ravensat, propositional variables can be defined as local variables in Ruby.
|
39
|
+
|
37
40
|
```ruby
|
38
41
|
fuji_is_the_highest_mountain_in_japan = Ravensat::VarNode.new
|
39
42
|
```
|
43
|
+
|
40
44
|
In addition, you can write logical expressions intuitively.
|
45
|
+
|
41
46
|
```ruby
|
42
47
|
x = Ravensat::VarNode.new
|
43
48
|
y = Ravensat::VarNode.new
|
44
49
|
|
45
|
-
# (x or y) and (not x or y)
|
46
|
-
(x | y) & (~x | y)
|
50
|
+
(x | y) & (~x | y) # (x or y) and (not x or y)
|
47
51
|
```
|
48
52
|
|
49
53
|
|
@@ -66,34 +70,32 @@ Or install it yourself as:
|
|
66
70
|
## Usage
|
67
71
|
### Basic Usage
|
68
72
|
This is a basic usage example of the library.
|
73
|
+
|
69
74
|
```ruby
|
70
75
|
require 'ravensat'
|
71
76
|
|
72
|
-
# Define propositional variables
|
73
77
|
a = Ravensat::VarNode.new
|
74
78
|
b = Ravensat::VarNode.new
|
75
79
|
|
76
80
|
a.result #=> nil
|
77
81
|
b.result #=> nil
|
78
82
|
|
79
|
-
# Generate logical expressions as CNF
|
80
83
|
logic = (a | b) & (~a | b) & (a | ~b)
|
81
84
|
|
82
|
-
# Launch SAT solver
|
83
85
|
solver = Ravensat::Solver.new
|
84
86
|
solver.solve logic #=> true(SAT)
|
85
87
|
|
86
|
-
# Refer to the satisfiability
|
87
88
|
a.result #=> true
|
88
89
|
b.result #=> true
|
89
90
|
```
|
90
91
|
|
91
92
|
If you have SAT solver installed, you can write:
|
93
|
+
|
92
94
|
```ruby
|
93
|
-
# Launch SAT solver
|
94
95
|
solver = Ravensat::Solver.new("<solver_name>")
|
95
96
|
solver.solve logic
|
96
97
|
```
|
98
|
+
|
97
99
|
The available solvers are assumed to be those that can be I/O in the DIMACS Format.
|
98
100
|
At least, we have confirmed that it works properly with [MiniSat](https://github.com/niklasso/minisat).
|
99
101
|
|
@@ -124,6 +126,7 @@ end
|
|
124
126
|
|
125
127
|
### Extension Usage(CSP; Constraint Satisfaction Problem)
|
126
128
|
It is possible to define integer variables and to describe some integer constraints.
|
129
|
+
|
127
130
|
```ruby
|
128
131
|
require 'ravensat'
|
129
132
|
|
@@ -147,10 +150,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
147
150
|
|
148
151
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
149
152
|
|
153
|
+
## License
|
154
|
+
|
155
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
156
|
+
|
150
157
|
## Contributing
|
151
158
|
|
152
159
|
Bug reports and pull requests are welcome on GitHub at https://github.com/matsuda0528/ravensat.
|
153
160
|
|
154
|
-
|
161
|
+
```
|
162
|
+
____ _
|
163
|
+
| _ \ __ ___ _____ _ __ ___ __ _| |_
|
164
|
+
| |_) / _` \ \ / / _ \ '_ \/ __|/ _` | __|
|
165
|
+
| _ < (_| |\ V / __/ | | \__ \ (_| | |_
|
166
|
+
|_| \_\__,_| \_/ \___|_| |_|___/\__,_|\__|
|
167
|
+
|
168
|
+
```
|
155
169
|
|
156
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|