mirror of https://github.com/YosysHQ/yosys.git
ezsat add propagation budget api.
This commit is contained in:
parent
b35b6706f8
commit
b148993f7b
|
|
@ -104,6 +104,8 @@ bool ezMiniSAT::solver(const std::vector<int> &modelExpressions, std::vector<boo
|
||||||
preSolverCallback();
|
preSolverCallback();
|
||||||
|
|
||||||
solverTimeoutStatus = false;
|
solverTimeoutStatus = false;
|
||||||
|
solverPropLimitStatus = false;
|
||||||
|
solverProps = 0;
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
contradiction:
|
contradiction:
|
||||||
|
|
@ -201,7 +203,21 @@ contradiction:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool foundSolution = minisatSolver->solve(assumps);
|
uint64_t solverPropsBefore = minisatSolver->propagations;
|
||||||
|
bool foundSolution;
|
||||||
|
|
||||||
|
if (solverPropLimit > 0) {
|
||||||
|
minisatSolver->setPropBudget(solverPropLimit);
|
||||||
|
Minisat::lbool res = minisatSolver->solveLimited(assumps);
|
||||||
|
minisatSolver->budgetOff();
|
||||||
|
if (Minisat::toInt(res) == 2) // l_Undef: propagation budget exhausted
|
||||||
|
solverPropLimitStatus = true;
|
||||||
|
foundSolution = (Minisat::toInt(res) == 0); // l_True
|
||||||
|
} else {
|
||||||
|
foundSolution = minisatSolver->solve(assumps);
|
||||||
|
}
|
||||||
|
|
||||||
|
solverProps = minisatSolver->propagations - solverPropsBefore;
|
||||||
|
|
||||||
#if defined(HAS_ALARM)
|
#if defined(HAS_ALARM)
|
||||||
if (solverTimeout > 0) {
|
if (solverTimeout > 0) {
|
||||||
|
|
@ -210,6 +226,7 @@ contradiction:
|
||||||
alarm(0);
|
alarm(0);
|
||||||
sigaction(SIGALRM, &old_sig_action, NULL);
|
sigaction(SIGALRM, &old_sig_action, NULL);
|
||||||
alarm(old_alarm_timeout);
|
alarm(old_alarm_timeout);
|
||||||
|
minisatSolver->clearInterrupt();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ ezSAT::ezSAT()
|
||||||
|
|
||||||
solverTimeout = 0;
|
solverTimeout = 0;
|
||||||
solverTimeoutStatus = false;
|
solverTimeoutStatus = false;
|
||||||
|
solverPropLimit = 0;
|
||||||
|
solverPropLimitStatus = false;
|
||||||
|
solverProps = 0;
|
||||||
|
|
||||||
literal("CONST_TRUE");
|
literal("CONST_TRUE");
|
||||||
literal("CONST_FALSE");
|
literal("CONST_FALSE");
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ protected:
|
||||||
public:
|
public:
|
||||||
int solverTimeout;
|
int solverTimeout;
|
||||||
bool solverTimeoutStatus;
|
bool solverTimeoutStatus;
|
||||||
|
int64_t solverPropLimit;
|
||||||
|
bool solverPropLimitStatus;
|
||||||
|
int64_t solverProps;
|
||||||
|
|
||||||
ezSAT();
|
ezSAT();
|
||||||
virtual ~ezSAT();
|
virtual ~ezSAT();
|
||||||
|
|
@ -157,6 +160,19 @@ public:
|
||||||
return solverTimeoutStatus;
|
return solverTimeoutStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSolverPropLimit(int64_t newPropLimit) {
|
||||||
|
solverPropLimit = newPropLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getSolverPropLimitStatus() {
|
||||||
|
return solverPropLimitStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
// propagations spent by the most recent solve() call
|
||||||
|
int64_t getSolverProps() {
|
||||||
|
return solverProps;
|
||||||
|
}
|
||||||
|
|
||||||
// manage CNF (usually only accessed by SAT solvers)
|
// manage CNF (usually only accessed by SAT solvers)
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue