Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
KissatINCSolver.hpp
1#pragma once
2
3#include "containers/ClauseBuffer.hpp"
4#include "containers/ClauseDatabase.hpp"
5#include "containers/ClauseUtils.hpp"
6#include "utils/Threading.hpp"
7#include <fstream>
8#include <iostream>
9#include <unordered_map>
10
11#include "KissatFamily.hpp"
12#include "SolverCdclInterface.hpp"
13
14#define KISSAT_INC_
15
16// KissatINCSolver includes
17extern "C"
18{
19#include "kissat-inc/src/kissat.h"
20}
21
22// Wrapping struct
23typedef struct kissat kissat_mab;
24
28{
29 public:
30 void setBumpVar(int v);
31
33 void loadFormula(const char* filename);
34
36 unsigned int getVariablesCount();
37
40
42 void setPhase(const unsigned int var, const bool phase);
43
45 void bumpVariableActivity(const int var, const int times);
46
49
52
54 SatResult solve(const std::vector<int>& cube);
55
57 void addClause(ClauseExchangePtr clause);
58
60 void addClauses(const std::vector<ClauseExchangePtr>& clauses);
61
63 void addInitialClauses(const std::vector<simpleClause>& clauses, unsigned int nbVars) override;
64
66 bool importClause(const ClauseExchangePtr& clause) override;
67
69 void importClauses(const std::vector<ClauseExchangePtr>& clauses) override;
70
73
74 void printWinningLog() override;
75
76 void setFamily(KissatFamily family) { this->family = family; };
77
79 std::vector<int> getModel();
80
82 void diversify(const SeedGenerator& getSeed) override;
83
85 KissatINCSolver(int id, const std::shared_ptr<ClauseDatabase>& clauseDB);
86
89
90 std::vector<int> getFinalAnalysis();
91
92 std::vector<int> getSatAssumptions();
93
94 protected:
95 int bump_var;
96
98 kissat_mab* solver;
99
100 KissatFamily family;
101
104
106 std::atomic<bool> stopSolver;
107
109 friend char KissatIncImportClause(void*, kissat*);
110 friend char KissatIncExportClause(void*, kissat*);
111};
Wrapper for boost::lockfree::queue to manage ClauseExchange objects.
Definition ClauseBuffer.hpp:26
Instance of a KissatINCSolver solver.
Definition KissatINCSolver.hpp:28
void unsetSolverInterrupt()
Remove the SAT solving interrupt request.
virtual ~KissatINCSolver()
Destructor.
void bumpVariableActivity(const int var, const int times)
Bump activity of a given variable.
void diversify(const SeedGenerator &getSeed) override
Native diversification.
friend char KissatIncImportClause(void *, kissat *)
Callback to export/import clauses used by real kissat.
void printWinningLog() override
Print the winning log.
void setPhase(const unsigned int var, const bool phase)
Set initial phase for a given variable.
std::vector< int > getSatAssumptions()
Get current assumptions.
void importClauses(const std::vector< ClauseExchangePtr > &clauses) override
Add a list of learned clauses to the formula.
std::atomic< bool > stopSolver
Used to stop or continue the resolution.
Definition KissatINCSolver.hpp:106
void addClauses(const std::vector< ClauseExchangePtr > &clauses)
Add a list of permanent clauses to the formula.
void loadFormula(const char *filename)
Load formula from a given dimacs file, return false if failed.
void printStatistics()
Get solver statistics.
std::vector< int > getModel()
Return the model in case of SAT result.
kissat_mab * solver
Pointer to a KissatINCSolver solver.
Definition KissatINCSolver.hpp:98
void addInitialClauses(const std::vector< simpleClause > &clauses, unsigned int nbVars) override
Add a list of initial clauses to the formula.
bool importClause(const ClauseExchangePtr &clause) override
Add a learned clause to the formula.
unsigned int getVariablesCount()
Get the number of variables of the current resolution.
ClauseBuffer clausesToAdd
Buffer used to add permanent clauses.
Definition KissatINCSolver.hpp:103
void addClause(ClauseExchangePtr clause)
Add a permanent clause to the formula.
KissatINCSolver(int id, const std::shared_ptr< ClauseDatabase > &clauseDB)
Constructor.
SatResult solve(const std::vector< int > &cube)
Solve the formula with a given cube.
std::vector< int > getFinalAnalysis()
Get the final analysis in case of UNSAT result.
int getDivisionVariable()
Get a variable suitable for search splitting.
void setSolverInterrupt()
Interrupt resolution, solving cannot continue until interrupt is unset.
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