Skip to content

Commit

Permalink
Fix a bug where only positive assumptions were accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkschumacher committed Mar 4, 2018
1 parent 2243675 commit ea4f8c2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const isValidAssumptions = (assumptions, nvars) => {
// TODO: check for duplicates
return Array.isArray(assumptions) &&
assumptions.every(Number.isInteger) &&
assumptions.every(x => x >= 1 && x <= nvars)
assumptions.map(Math.abs).every(x => x >= 1 && x <= nvars)
}

const picosat_sat = (formula, assumptions) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "picosat",
"version": "1.0.1",
"version": "1.0.2",
"description": "picosat SAT solver",
"main": "index.js",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ test("it solves a simple problem", (t) => {

test("it supports assumptions", (t) => {
const formula = [[1, 2], [-1, 2]]
const assumptions = [1, 2]
const assumptions = [-1, 2]
const result = picosat_sat(formula, assumptions)
t.equal(result.satisfiable, true)
t.equal(result.solution.length, 2)
t.equal(result.solution[0], 1)
t.equal(result.solution[0], -1)
t.equal(result.solution[1], 2)
t.end()
})
Expand Down

0 comments on commit ea4f8c2

Please sign in to comment.