Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
SolverFactory.hpp
1#pragma once
2
3#include "solvers/CDCL/SolverCdclInterface.hpp"
4#include "solvers/LocalSearch/LocalSearchInterface.hpp"
5
6#include <atomic>
7#include <vector>
8
9using IDScaler = std::function<unsigned(const std::shared_ptr<SolverInterface>&)>;
10
16{
17 public:
27 char importDbType,
28 std::shared_ptr<SolverInterface>& createdSolver);
29
39 char importDBType,
40 std::vector<std::shared_ptr<SolverCdclInterface>>& cdclSolvers,
41 std::vector<std::shared_ptr<LocalSearchInterface>>& localSolvers);
42
51 static void createSolvers(int count,
52 char importDBType,
53 std::string portfolio,
54 std::vector<std::shared_ptr<SolverCdclInterface>>& cdclSolvers,
55 std::vector<std::shared_ptr<LocalSearchInterface>>& localSolvers);
56
62 static void printStats(const std::vector<std::shared_ptr<SolverCdclInterface>>& cdclSolvers,
63 const std::vector<std::shared_ptr<LocalSearchInterface>>& localSolvers);
64
72 static void diversification(
73 const std::vector<std::shared_ptr<SolverCdclInterface>>& cdclSolvers,
74 const std::vector<std::shared_ptr<LocalSearchInterface>>& localSolvers,
75 const IDScaler& generalIdScaler =
76 [](const std::shared_ptr<SolverInterface>& solver) { return solver->getSolverId(); },
77 const IDScaler& typeIdScaler =
78 [](const std::shared_ptr<SolverInterface>& solver) { return solver->getSolverTypeId(); });
79
80 public:
84 static std::atomic<int> currentIdSolver;
85};
Factory class for creating and managing SAT solvers.
Definition SolverFactory.hpp:16
static void diversification(const std::vector< std::shared_ptr< SolverCdclInterface > > &cdclSolvers, const std::vector< std::shared_ptr< LocalSearchInterface > > &localSolvers, const IDScaler &generalIdScaler=[](const std::shared_ptr< SolverInterface > &solver) { return solver->getSolverId();}, const IDScaler &typeIdScaler=[](const std::shared_ptr< SolverInterface > &solver) { return solver->getSolverTypeId();})
Applies diversification to a group of solvers.
static void printStats(const std::vector< std::shared_ptr< SolverCdclInterface > > &cdclSolvers, const std::vector< std::shared_ptr< LocalSearchInterface > > &localSolvers)
Prints statistics for a group of solvers.
static SolverAlgorithmType createSolver(char type, char importDBType, std::vector< std::shared_ptr< SolverCdclInterface > > &cdclSolvers, std::vector< std::shared_ptr< LocalSearchInterface > > &localSolvers)
Creates a solver of the specified type and adds it to the appropriate vector.
static std::atomic< int > currentIdSolver
Atomic counter for assigning unique IDs to solvers.
Definition SolverFactory.hpp:84
static SolverAlgorithmType createSolver(char type, char importDbType, std::shared_ptr< SolverInterface > &createdSolver)
Creates a solver of the specified type.
static void createSolvers(int count, char importDBType, std::string portfolio, std::vector< std::shared_ptr< SolverCdclInterface > > &cdclSolvers, std::vector< std::shared_ptr< LocalSearchInterface > > &localSolvers)
Creates multiple solvers based on a portfolio.
SolverAlgorithmType
Enumeration for types of solver algorithms.
Definition SolverInterface.hpp:50