Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
GlucoseSyrup.hpp
1#pragma once
2
3#include "SolverCdclInterface.hpp"
4#include "containers/ClauseBuffer.hpp"
5#include "containers/ClauseDatabase.hpp"
6#include "containers/ClauseUtils.hpp"
7#include "utils/Threading.hpp"
8
9#define GLUCOSE_
10
11// Some forward declatarations for Glucose
12namespace Glucose {
13class ParallelSolver;
14class Lit;
15template<class T>
16class vec;
17class Clause;
18}
19
23{
24 public:
26 void loadFormula(const char* filename);
27
29 unsigned int getVariablesCount();
30
33
35 void setPhase(const unsigned int var, const bool phase);
36
38 void bumpVariableActivity(const int var, const int times);
39
42
45
47 SatResult solve(const std::vector<int>& cube);
48
50 void addClause(ClauseExchangePtr clause);
51
53 void addClauses(const std::vector<ClauseExchangePtr>& clauses);
54
56 void addInitialClauses(const std::vector<simpleClause>& clauses, unsigned int nbVars) override;
57
59 bool importClause(const ClauseExchangePtr& clause);
60
62 void importClauses(const std::vector<ClauseExchangePtr>& clauses);
63
66
67 void printWinningLog() override;
68
70 std::vector<int> getModel();
71
73 void diversify(const SeedGenerator& getSeed) override;
74
75 void getHeuristicData(std::vector<int>** flipActivity,
76 std::vector<int>** nbPropagations,
77 std::vector<int>** nbDecisionVar);
78
79 void setHeuristicData(std::vector<int>* flipActivity,
80 std::vector<int>* nbPropagations,
81 std::vector<int>* nbDecisionVar);
82
83 std::vector<int> getFinalAnalysis();
84
85 std::vector<int> getSatAssumptions();
86
89 const std::shared_ptr<ClauseDatabase>& clauseDB);
90
93 int id,
94 const std::shared_ptr<ClauseDatabase>& clauseDB);
95
97 virtual ~GlucoseSyrup();
98
99 protected:
101 Glucose::ParallelSolver* solver;
102
104 std::unique_ptr<ClauseDatabase> unitsToImport;
105
108
110 friend void glucoseExportUnary(void*, Glucose::Lit&);
111
113 friend void glucoseExportClause(void*, Glucose::Clause&);
114
116 friend Glucose::Lit glucoseImportUnary(void*);
117
120
121 public:
122 ;
123};
Wrapper for boost::lockfree::queue to manage ClauseExchange objects.
Definition ClauseBuffer.hpp:26
Instance of a Glucose solver.
Definition GlucoseSyrup.hpp:23
std::vector< int > getFinalAnalysis()
Get the final analysis in case of UNSAT result.
ClauseBuffer clausesToAdd
Buffer used to add permanent clauses.
Definition GlucoseSyrup.hpp:107
void setSolverInterrupt()
Interrupt resolution, solving cannot continue until interrupt is unset.
friend void glucoseExportClause(void *, Glucose::Clause &)
Callback to export clauses.
friend bool glucoseImportClause(void *, int *, Glucose::vec< Glucose::Lit > &)
Callback to import clauses.
virtual ~GlucoseSyrup()
Destructor.
void addInitialClauses(const std::vector< simpleClause > &clauses, unsigned int nbVars) override
Add a list of initial clauses to the formula.
friend Glucose::Lit glucoseImportUnary(void *)
Callback to import unit clauses.
void addClauses(const std::vector< ClauseExchangePtr > &clauses)
Add a list of permanent clauses to the formula.
void unsetSolverInterrupt()
Remove the SAT solving interrupt request.
void printWinningLog() override
Print the winning log.
void printStatistics()
Get solver statistics.
std::vector< int > getModel()
Return the model in case of SAT result.
void bumpVariableActivity(const int var, const int times)
Bump activity of a given variable.
std::unique_ptr< ClauseDatabase > unitsToImport
Database used to import units. (TODO use a lockfree queue as in lingeling)
Definition GlucoseSyrup.hpp:104
std::vector< int > getSatAssumptions()
Get current assumptions.
GlucoseSyrup(int id, const std::shared_ptr< ClauseDatabase > &clauseDB)
Constructor.
int getDivisionVariable()
Get a variable suitable for search splitting.
friend void glucoseExportUnary(void *, Glucose::Lit &)
Callback to export unit clauses.
unsigned int getVariablesCount()
Get the number of variables of the current resolution.
void importClauses(const std::vector< ClauseExchangePtr > &clauses)
Add a list of learned clauses to the formula.
void setPhase(const unsigned int var, const bool phase)
Set initial phase for a given variable.
SatResult solve(const std::vector< int > &cube)
Solve the formula with a given cube.
void addClause(ClauseExchangePtr clause)
Add a permanent clause to the formula.
GlucoseSyrup(const GlucoseSyrup &other, int id, const std::shared_ptr< ClauseDatabase > &clauseDB)
Copy constructor.
void diversify(const SeedGenerator &getSeed) override
Native diversification.
bool importClause(const ClauseExchangePtr &clause)
Add a learned clause to the formula.
void loadFormula(const char *filename)
Load formula from a given dimacs file, return false if failed.
Glucose::ParallelSolver * solver
Pointer to a Glucose solver.
Definition GlucoseSyrup.hpp:101
Definition GlucoseSyrup.hpp:16
Interface for CDCL (Conflict-Driven Clause Learning) solvers This class provides a common interface f...
Definition SolverCdclInterface.hpp:58
SatResult
Enumeration for SAT solver results.
Definition SolverInterface.hpp:39