Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
PortfolioPRS.hpp
1#pragma once
2
3#include "utils/Parameters.hpp"
4#include "working/WorkingStrategy.hpp"
5
6#include "preprocessors/PreprocessorInterface.hpp"
7
8#include "sharing/Sharer.hpp"
9#include "sharing/SharingStrategy.hpp"
10
11#include <condition_variable>
12#include <mutex>
13#include <unordered_map>
14
15enum class PRSGroups
16{
17 SAT = 0,
18 UNSAT = 1,
19 MAPLE = 2,
20 LGL = 3,
21 DEFAULT = 4
22};
23
35{
36 public:
38
40
41 void solve(const std::vector<int>& cube) override;
42
43 void join(WorkingStrategy* strat, SatResult res, const std::vector<int>& model) override;
44
45 void setSolverInterrupt() override;
46
47 void unsetSolverInterrupt() override;
48
49 void waitInterrupt() override;
50
51 protected:
52 void restoreModelDist(std::vector<int>& model);
53
54 void computeNodeGroup(int worldSize, int myRank);
55
56 std::atomic<bool> strategyEnding;
57
58 // PRS Portfolio
59 // -------------
60 PRSGroups nodeGroup; /* each group share clauses only between themselves */
61 std::string solversPortfolio;
62 std::unordered_map<PRSGroups, uint> sizePerGroup;
63 unsigned rankInMyGroup;
64 int right_neighbor;
65 int left_neighbor;
66
67 // Workers
68 //--------
69 std::vector<std::shared_ptr<PreprocessorInterface>> preprocessors; /* kept for model restoration*/
70 std::mutex preprocLock;
71 std::condition_variable preprocSignal;
72
73 // Sharing
74 //--------
75
76 /* Use weak_ptr instead of shared_ptr ? */
77 std::vector<std::shared_ptr<SharingStrategy>> strategies;
78 std::vector<std::unique_ptr<Sharer>> sharers;
79};
An Implementation of WorkingStrategy that mimics the strategy used in the PRS-Distributed solver from...
Definition PortfolioPRS.hpp:35
Base Interface for Working Strategies.
Definition WorkingStrategy.hpp:18
SatResult
Enumeration for SAT solver results.
Definition SolverInterface.hpp:39