Skip to content

Commit

Permalink
Disabled incremental solving for CP solvers.
Browse files Browse the repository at this point in the history
  • Loading branch information
robama committed Aug 19, 2019
1 parent 86ec9fd commit b43d69d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 1 addition & 5 deletions lib/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@
default:
throw new Error(`invalid solver ${SOLVER}`);
}
if (solver.isCPSolver()) {
if (process.env.INCREMENTAL === "0")
console.error("Warning: incremental option disabled for CP solvers.");
}
else {
if (!solver.isCPSolver()) {
if (commandLog) {
solver.logCommands(commandLog);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/cp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const assert = require("assert");

const fs = require("fs");

const Type = require("./type");
Expand Down Expand Up @@ -183,7 +185,7 @@ exports.CPSolver = class CPSolver {
}

async solveSat(vars) {
// console.log(vars, this.model)
// console.log(vars, this.model)
const decls = this.declareVars(vars);
const n_props = this.model.N_IMPL_PROPS + this.model.N_EXPL_PROPS;
const mzn_model = (
Expand Down Expand Up @@ -321,6 +323,7 @@ exports.CPSolver = class CPSolver {
};

pop(n) {
assert (n == 1);
this.initModel();
}

Expand Down
14 changes: 9 additions & 5 deletions lib/dse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const _ = require("lodash");

const assert = require("assert");
const { BooleanConstraint, TypeConstraint } = require("./constraint");
const { SymbolicValue, Constant, Variable, Temporary } = require("./symbolic");
const { parseModel } = require("./model");
Expand Down Expand Up @@ -273,6 +273,7 @@ class ConstraintCollector {

if (idx < this._unsyncedIndex) {
if (this.incremental) {
assert (!this.solver.isCPSolver());
this.solver.pop(this._unsyncedIndex - idx);
this._unsyncedIndex = idx;
} else {
Expand Down Expand Up @@ -422,11 +423,11 @@ class ConstraintCollector {
break;
}
}
// console.log("popping ", i);
// console.log("popping ", i);
this.pop(this._constraintStack.length - i);
for (; i < prefixLength; i++) {
this.push(constraints[i]);
// console.log("pushing ", constraints[i]);
//console.log("pushing ", constraints[i]);
}
}

Expand All @@ -441,9 +442,8 @@ class ConstraintCollector {
}
else
status = await this.checkSat();
if (status !== "sat") {
if (status !== "sat")
return { status: status };
}
return { status: "sat", model: await this.getModel() };
}
}
Expand All @@ -456,6 +456,10 @@ class DSE {
coreCacheSize: 8
});
this._solver = solver;
if (options.incremental && solver.isCPSolver()) {
console.error("Warning: incremental option disabled for CP solvers.");
options.incremental = false;
}
this._collector = new ConstraintCollector(solver, options.incremental);
this._program = program;
this._inputs = [{model: {}, step: 0}];
Expand Down

0 comments on commit b43d69d

Please sign in to comment.