Universe::IUniverseSolver class

The IUniverseSolver interface is the root interface defining the base contract for all solvers.

Derived classes

class IUniverseSatSolver virtual
class UniverseJavaSolver virtual

Constructors, destructors, conversion operators

~IUniverseSolver() defaulted virtual

Public functions

void reset() pure virtual
auto nVariables() -> int pure virtual
auto getVariablesMapping() -> const std::map<std::string, Universe::IUniverseVariable*>& pure virtual
auto getAuxiliaryVariables() -> const std::vector<std::string>& pure virtual
auto getConstraints() -> const std::vector<IUniverseConstraint*>& pure virtual
void decisionVariables(const std::vector<std::string>& variables) pure virtual
void valueHeuristicStatic(const std::vector<std::string>& variables, const std::vector<Universe::BigInteger>& orderedValues) pure virtual
auto nConstraints() -> int pure virtual
auto isOptimization() -> bool pure virtual
void setTimeout(long seconds) pure virtual
void setTimeoutMs(long mseconds) pure virtual
void setVerbosity(int level) pure virtual
void addSearchListener(Universe::IUniverseSearchListener* listener) virtual
void removeSearchListener(Universe::IUniverseSearchListener* listener) virtual
void setLogFile(const std::string& filename) pure virtual
void setLogStream(std::ostream& stream) pure virtual
void loadInstance(const std::string& filename) pure virtual
auto solve() -> UniverseSolverResult pure virtual
auto solve(const std::string& filename) -> UniverseSolverResult pure virtual
auto solve(const std::vector<Universe::UniverseAssumption<Universe::BigInteger>>& assumptions) -> UniverseSolverResult pure virtual
void interrupt() pure virtual
auto solution() -> std::vector<Universe::BigInteger> pure virtual
auto mapSolution() -> std::map<std::string, Universe::BigInteger> pure virtual
auto mapSolution(bool excludeAux) -> std::map<std::string, Universe::BigInteger> pure virtual
auto checkSolution() -> bool pure virtual
auto checkSolution(const std::map<std::string, Universe::BigInteger>& assignment) -> bool pure virtual
auto toOptimizationSolver() -> Universe::IOptimizationSolver* virtual

Function documentation

Universe::IUniverseSolver::~IUniverseSolver() virtual defaulted

Destroys this solver.

void Universe::IUniverseSolver::reset() pure virtual

Resets this solver in its original state.

int Universe::IUniverseSolver::nVariables() pure virtual

Returns The number of variables.

Gives the number of variables defined in this solver.

const std::map<std::string, Universe::IUniverseVariable*>& Universe::IUniverseSolver::getVariablesMapping() pure virtual

Returns The mapping of the variables.

Gives the mapping of the variables in this solver.

const std::vector<std::string>& Universe::IUniverseSolver::getAuxiliaryVariables() pure virtual

Returns The list of the auxiliary variables, given by their name.

Gives the vector of the auxiliary variables used by the solver. These variables are those that the solver defines to help it represent the problem (for instance, to reify constraints).

const std::vector<IUniverseConstraint*>& Universe::IUniverseSolver::getConstraints() pure virtual

Returns The list of the constraints.

Gives the list of the constraints in this solver.

void Universe::IUniverseSolver::decisionVariables(const std::vector<std::string>& variables) pure virtual

Parameters
variables The variables on which to make decisions.

Advises this solver to focus on some variables to make decisions.

void Universe::IUniverseSolver::valueHeuristicStatic(const std::vector<std::string>& variables, const std::vector<Universe::BigInteger>& orderedValues) pure virtual

Parameters
variables The variables for which a static order is set.
orderedValues The values to try for the specified variables, in the desired order.

Forces a static order on the values to try for some variables.

int Universe::IUniverseSolver::nConstraints() pure virtual

Returns The number of constraints.

Gives the number of constraints defined in this solver.

bool Universe::IUniverseSolver::isOptimization() pure virtual

Returns Whether the problem is an optimization problem.

Checks whether the associated problem is an optimization problem.

void Universe::IUniverseSolver::setTimeout(long seconds) pure virtual

Parameters
seconds The time limit to set (in seconds).

Sets the time limit before interrupting the search.

void Universe::IUniverseSolver::setTimeoutMs(long mseconds) pure virtual

Sets the time limit before interrupting the search.

void Universe::IUniverseSolver::setVerbosity(int level) pure virtual

Parameters
level The verbosity level to set.

Sets the verbosity level of the solver. Extreme values (outside the range expected by the underlying solver) should be handled silently as the minimum or maximum value supported by the solver.

void Universe::IUniverseSolver::addSearchListener(Universe::IUniverseSearchListener* listener) virtual

Parameters
listener The listener to add.

Adds a listener to this solver, which listens to the events occurring in the solver during the search.

void Universe::IUniverseSolver::removeSearchListener(Universe::IUniverseSearchListener* listener) virtual

Parameters
listener The listener to remove.

Removes a listener from this solver, so that the listener does not listen to the events occurring in the solver during the search anymore.

void Universe::IUniverseSolver::setLogFile(const std::string& filename) pure virtual

Parameters
filename The name of the log file.

Sets the log file to be used by the solver.

void Universe::IUniverseSolver::setLogStream(std::ostream& stream) pure virtual

Parameters
stream The logging output stream.

Sets the output stream to be used by the solver for logging.

void Universe::IUniverseSolver::loadInstance(const std::string& filename) pure virtual

Parameters
filename The name of the file containing the problem to solve.

Loads a problem stored in the given file. The solver is expected to parse the problem itself.

UniverseSolverResult Universe::IUniverseSolver::solve() pure virtual

Returns The outcome of the search conducted by the solver.

Solves the problem associated to this solver.

UniverseSolverResult Universe::IUniverseSolver::solve(const std::string& filename) pure virtual

Parameters
filename The name of the file containing the problem to solve.
Returns The outcome of the search conducted by the solver.

Solves the problem stored in the given file. The solver is expected to parse the problem itself.

UniverseSolverResult Universe::IUniverseSolver::solve(const std::vector<Universe::UniverseAssumption<Universe::BigInteger>>& assumptions) pure virtual

Parameters
assumptions The assumptions to consider when solving.
Returns The outcome of the search conducted by the solver.

Solves the problem associated to this solver.

void Universe::IUniverseSolver::interrupt() pure virtual

Interrupts (asynchronously) the search currently performed by this solver.

std::vector<Universe::BigInteger> Universe::IUniverseSolver::solution() pure virtual

Returns The solution found by this solver.

Gives the solution found by this solver (if any).

std::map<std::string, Universe::BigInteger> Universe::IUniverseSolver::mapSolution() pure virtual

Returns The solution found by this solver.

Gives the mapping between the names of the variables and the assignment found by this solver (if any).

std::map<std::string, Universe::BigInteger> Universe::IUniverseSolver::mapSolution(bool excludeAux) pure virtual

Parameters
excludeAux Whether auxiliary variables should be excluded from the solution.
Returns The solution found by this solver.

Gives the mapping between the names of the variables and the assignment found by this solver (if any).

bool Universe::IUniverseSolver::checkSolution() pure virtual

Returns Whether the last solution is correct.

Checks the last solution that has been computed by the solver. Said differently, this method ensures that the last solution satisfies all the constraints of the problem solved by the solver.

bool Universe::IUniverseSolver::checkSolution(const std::map<std::string, Universe::BigInteger>& assignment) pure virtual

Parameters
assignment The assignment to check as a solution.
Returns Whether the given assignment is a solution of the problem.

Checks whether the given assignment is a solution of the problem. Said differently, this method ensures that the given assignment satisfies all the constraints of the problem solved by the solver.

Universe::IOptimizationSolver* Universe::IUniverseSolver::toOptimizationSolver() virtual

Returns The casted optimization solver.

Casts this solver into an IOptimizationSolver.