8#include "containers/ClauseExchange.hpp"
9#include "containers/ClauseUtils.hpp"
19#include <unordered_map>
108 virtual void addClauses(
const std::vector<ClauseExchangePtr>& clauses) = 0;
115 virtual void addInitialClauses(
const std::vector<simpleClause>& clauses,
unsigned int nbVars) = 0;
216 template<
typename Derived>
219 auto [it, inserted] =
s_instanceCounts.try_emplace(std::type_index(
typeid(Derived)), 0);
220 return it->second.fetch_add(1);
231 template<
typename Derived>
247 static inline std::unordered_map<std::type_index, std::atomic<unsigned int>>
s_instanceCounts;
Defines logging functions and macros for the SAT solver.
#define LOGDEBUG1(...)
Log a debug message with verbosity level 1 and blue color.
Definition Logger.hpp:213
Interface for a SAT solver with standard features.
Definition SolverInterface.hpp:62
virtual ~SolverInterface()
Virtual destructor for SolverInterface.
SolverInterface(SolverAlgorithmType algoType, int solverId)
Constructor for SolverInterface.
std::atomic< bool > m_initialized
Definition SolverInterface.hpp:240
virtual void addClauses(const std::vector< ClauseExchangePtr > &clauses)=0
Add a list of permanent clauses to the formula.
virtual void loadFormula(const char *filename)=0
Load formula from a given dimacs file.
static std::unordered_map< std::type_index, std::atomic< unsigned int > > s_instanceCounts
Number of existing instances of derived classes.
Definition SolverInterface.hpp:247
virtual void printStatistics()
Print solver statistics.
unsigned int getSolverTypeCount() const
Get the current count of instances of this object's most-derived type.
Definition SolverInterface.hpp:191
virtual void setSolverInterrupt()=0
Interrupt resolution, solving cannot continue until interrupt is unset.
virtual int getDivisionVariable()=0
Get a variable suitable for search splitting.
bool isInitialized()
Check if the solver is initialized.
Definition SolverInterface.hpp:148
virtual void addInitialClauses(const std::vector< simpleClause > &clauses, unsigned int nbVars)=0
Add a list of initial clauses to the formula.
void setSolverTypeId(unsigned int typeId)
Set the solver type ID.
Definition SolverInterface.hpp:172
unsigned int getSolverTypeId()
Get the solver type ID.
Definition SolverInterface.hpp:166
SolverAlgorithmType m_algoType
Definition SolverInterface.hpp:239
void setSolverId(unsigned int id)
Set the solver ID.
Definition SolverInterface.hpp:184
virtual unsigned int getVariablesCount()=0
Get the current number of variables.
void initializeTypeId()
Initialize the type ID for a derived class.
Definition SolverInterface.hpp:232
virtual void printWinningLog()
Print the winning log.
void setInitialized(bool value)
Set the initialization status of the solver.
Definition SolverInterface.hpp:154
unsigned int getSolverId()
Get the solver ID.
Definition SolverInterface.hpp:178
virtual void addClause(ClauseExchangePtr clause)=0
Add a permanent clause to the formula.
virtual void printParameters()
Print the parameters set for a solver.
int m_solverId
Definition SolverInterface.hpp:242
unsigned int m_solverTypeId
Definition SolverInterface.hpp:241
virtual std::vector< int > getModel()=0
Return the model in case of SAT result.
virtual SatResult solve(const std::vector< int > &cube)=0
Solve the formula with a given cube.
virtual void diversify(const SeedGenerator &getSeed=[](SolverInterface *s) { return s->getSolverId();})=0
Perform native diversification. The Default lambda returns the solver ID.
virtual void unsetSolverInterrupt()=0
Remove the SAT solving interrupt request.
SolverAlgorithmType getAlgoType()
Get the algorithm type of the solver.
Definition SolverInterface.hpp:160
static unsigned int getAndIncrementTypeCount()
Get and increment the instance count for a specific derived type.
Definition SolverInterface.hpp:217
SatResult
Enumeration for SAT solver results.
Definition SolverInterface.hpp:39
SolverAlgorithmType
Enumeration for types of solver algorithms.
Definition SolverInterface.hpp:50