ricosat 1.0.1 → 1.0.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 +12 -0
- data/ext/ricosat/ricosat.c +18 -0
- data/lib/ricosat.rb +1 -1
- data/test/test_ricosat.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18466f49c48ecd6df13bcb70bad7d70f7f50bbef
|
4
|
+
data.tar.gz: 6905a43219223e91de5f13fd1ad594671ebdfcbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b92044058db7ac4788d8e009b24c01db42378ef149edcf03b2c8453f9aaf0493e86a88619613cec9e59f9a3c47681e3864361279b8576f45e0f1cc2f4b4db4a7
|
7
|
+
data.tar.gz: f473dc63d684deb3c79477ea9fe66d8fc8af66f7116ae4f8136d0edd29e926aeac773ce7ae38bd22af7574835bed30465346809baee71f247a9e065f2173b77f
|
data/README.md
CHANGED
@@ -11,6 +11,18 @@ you use the PicoSAT solver from Ruby!
|
|
11
11
|
|
12
12
|
* It's a SAT solver! Not SAT like the tests, but the [Boolean satisfiability problem](https://en.wikipedia.org/wiki/Boolean_satisfiability_problem)
|
13
13
|
|
14
|
+
## INSTALLATION:
|
15
|
+
|
16
|
+
PicoSAT depends on [gmp](https://gmplib.org) and
|
17
|
+
[gperftools](https://github.com/gperftools/gperftools). On a Mac, these can be
|
18
|
+
installed in one shot with homebrew via `brew install gmp gperftools`.
|
19
|
+
|
20
|
+
Once you have those:
|
21
|
+
|
22
|
+
``` ruby
|
23
|
+
$ gem install ricosat
|
24
|
+
```
|
25
|
+
|
14
26
|
## SYNOPSIS:
|
15
27
|
|
16
28
|
Solve the problem (A and NOT B):
|
data/ext/ricosat/ricosat.c
CHANGED
@@ -166,6 +166,22 @@ static VALUE set_global_default_phase(VALUE self, VALUE val)
|
|
166
166
|
return self;
|
167
167
|
}
|
168
168
|
|
169
|
+
static VALUE reset_phases(VALUE self)
|
170
|
+
{
|
171
|
+
PicoSAT * sat;
|
172
|
+
TypedData_Get_Struct(self, PicoSAT, &RicoSatType, sat);
|
173
|
+
picosat_reset_phases(sat);
|
174
|
+
return self;
|
175
|
+
}
|
176
|
+
|
177
|
+
static VALUE reset_scores(VALUE self)
|
178
|
+
{
|
179
|
+
PicoSAT * sat;
|
180
|
+
TypedData_Get_Struct(self, PicoSAT, &RicoSatType, sat);
|
181
|
+
picosat_reset_scores(sat);
|
182
|
+
return self;
|
183
|
+
}
|
184
|
+
|
169
185
|
void error_cb(const char *m) {
|
170
186
|
rb_raise(rb_eRuntimeError, "%s", m);
|
171
187
|
}
|
@@ -197,6 +213,8 @@ void Init_ricosat() {
|
|
197
213
|
rb_define_method(cRicoSat, "coreclause", coreclause, 1);
|
198
214
|
rb_define_method(cRicoSat, "added_original_clauses", added_original_clauses, 0);
|
199
215
|
rb_define_method(cRicoSat, "global_default_phase=", set_global_default_phase, 1);
|
216
|
+
rb_define_method(cRicoSat, "reset_phases", reset_phases, 0);
|
217
|
+
rb_define_method(cRicoSat, "reset_scores", reset_scores, 0);
|
200
218
|
}
|
201
219
|
|
202
220
|
/* vim: set sws=4 noet: */
|
data/lib/ricosat.rb
CHANGED
data/test/test_ricosat.rb
CHANGED
@@ -143,4 +143,16 @@ class TestRicosat < MiniTest::Test
|
|
143
143
|
sat.add(1); sat.add(0)
|
144
144
|
assert sat.set_default_phase 1, 1
|
145
145
|
end
|
146
|
+
|
147
|
+
def test_reset_phases
|
148
|
+
sat = RicoSAT.new
|
149
|
+
sat.add(1); sat.add(0)
|
150
|
+
assert sat.reset_phases
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_reset_scores
|
154
|
+
sat = RicoSAT.new
|
155
|
+
sat.add(1); sat.add(0)
|
156
|
+
assert sat.reset_scores
|
157
|
+
end
|
146
158
|
end
|