Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
ClauseDatabaseBufferPerEntity.hpp
1#pragma once
2
3#include "containers/ClauseBuffer.hpp"
4#include "containers/ClauseDatabase.hpp"
5#include <memory>
6#include <shared_mutex>
7#include <unordered_map>
8#include <vector>
9
26{
27 public:
32
37 explicit ClauseDatabaseBufferPerEntity(int maxClauseSize);
38
42 ~ClauseDatabaseBufferPerEntity() override = default;
43
50 bool addClause(ClauseExchangePtr clause) override;
51
59 size_t giveSelection(std::vector<ClauseExchangePtr>& selectedCls, unsigned int literalCountLimit) override;
60
66 void getClauses(std::vector<ClauseExchangePtr>& v_cls) override;
67
74 bool getOneClause(ClauseExchangePtr& cls) override;
75
81 size_t getSize() const override;
82
87 void clearDatabase() override;
88
93 size_t shrinkDatabase() override
94 {
95 LOGDEBUG3("This does nothing!");
96 return (size_t)-1;
97 };
98
99 private:
103 std::unordered_map<int, std::unique_ptr<ClauseBuffer>> entityDatabases;
104
111 mutable std::shared_mutex dbmutex;
112
117 unsigned int maxClauseSize;
118};
#define LOGDEBUG3(...)
Log a debug message with verbosity level 4 and magenta color.
Definition Logger.hpp:229
A clause database that maintain separate buffers for each entity, mimicing old painless default behav...
Definition ClauseDatabaseBufferPerEntity.hpp:26
void getClauses(std::vector< ClauseExchangePtr > &v_cls) override
Retrieves all clauses from all entity buffers.
ClauseDatabaseBufferPerEntity()=delete
Default constructor deleted to enforce use of parameterized constructor.
size_t shrinkDatabase() override
Does nothing in this implementation.
Definition ClauseDatabaseBufferPerEntity.hpp:93
bool addClause(ClauseExchangePtr clause) override
Adds a clause to the appropriate entity's buffer.
~ClauseDatabaseBufferPerEntity() override=default
Virtual destructor.
ClauseDatabaseBufferPerEntity(int maxClauseSize)
Constructor with a specified maximum clause size.
void clearDatabase() override
Clears all export buffers.
bool getOneClause(ClauseExchangePtr &cls) override
Retrieves a single clause from any entity buffer.
size_t getSize() const override
Gets the total number of clauses across all entity buffers.
size_t giveSelection(std::vector< ClauseExchangePtr > &selectedCls, unsigned int literalCountLimit) override
Selects clauses up to a specified total size.
Abstract base class defining the interface for clause storage and management.
Definition ClauseDatabase.hpp:27