class
#include <UniverseJavaSolver.hpp>
UniverseJavaSolver Contents
The UniverseJavaSolver class defines an adapter for an IUniverseSolver written in Java (and implementing the JUniverse interface). The solver is run through the Java Native Interface (JNI).
Base classes
- class IUniverseSolver virtual
Derived classes
- class UniverseJavaSatSolver virtual
Constructors, destructors, conversion operators
- UniverseJavaSolver(easyjni::JavaClass* interface, easyjni::JavaObject object) explicit
- ~UniverseJavaSolver() defaulted override
Public functions
- void reset() override
- auto nVariables() -> int override
-
auto getVariablesMapping() -> const std::map<std::string, Universe::
IUniverseVariable*>& override - auto getAuxiliaryVariables() -> const std::vector<std::string>& override
-
auto getConstraints() -> const std::vector<Universe::
IUniverseConstraint*>& override - void decisionVariables(const std::vector<std::string>& variables) override
-
void valueHeuristicStatic(const std::vector<std::string>& variables,
const std::vector<Universe::
BigInteger>& orderedValues) override - auto nConstraints() -> int override
- auto isOptimization() -> bool override
- void setTimeout(long seconds) override
- void setTimeoutMs(long mseconds) override
- void setVerbosity(int level) override
-
void addSearchListener(Universe::
IUniverseSearchListener* listener) override -
void removeSearchListener(Universe::
IUniverseSearchListener* listener) override - void setLogFile(const std::string& filename) override
- void setLogStream(std::ostream& stream) override
- void loadInstance(const std::string& filename) override
- auto solve() -> UniverseSolverResult override
- auto solve(const std::string& filename) -> UniverseSolverResult override
-
auto solve(const std::vector<UniverseAssumption<Universe::
BigInteger>>& assumptions) -> UniverseSolverResult override - void interrupt() override
-
auto solution() -> std::vector<Universe::
BigInteger> override -
auto mapSolution() -> std::map<std::string, Universe::
BigInteger> override -
auto mapSolution(bool excludeAux) -> std::map<std::string, Universe::
BigInteger> override - auto checkSolution() -> bool override
-
auto checkSolution(const std::map<std::string, Universe::
BigInteger>& assignment) -> bool override -
auto toOptimizationSolver() -> Universe::
IOptimizationSolver* override
Protected static functions
-
template<typename T>static auto toJavaAssumptions(std::vector<Universe::
UniverseAssumption<T>> assumptions, std::function<easyjni::JavaObject(T)> toJavaObject) -> Universe:: JavaList -
static auto toUniverseSolverResult(easyjni::JavaObject javaResult) -> Universe::
UniverseSolverResult
Protected variables
- easyjni::JavaClass* interface
- easyjni::JavaObject object
-
std::map<std::string, Universe::
IUniverseVariable*> mapping - std::vector<std::string> auxiliaryVariables
- std::vector<IUniverseConstraint*> constraints
Function documentation
Universe:: UniverseJavaSolver:: UniverseJavaSolver(easyjni::JavaClass* interface,
easyjni::JavaObject object) explicit
Parameters | |
---|---|
interface | The Java interface corresponding to IUniverseSolver. |
object | The Java object to adapt. |
Creates a UniverseJavaSolver.
Universe:: UniverseJavaSolver:: ~UniverseJavaSolver() override defaulted
Destroys this solver.
void Universe:: UniverseJavaSolver:: reset() override
Resets this solver in its original state.
int Universe:: UniverseJavaSolver:: nVariables() override
Returns | The number of variables. |
---|
Gives the number of variables defined in this solver.
const std::map<std::string, Universe:: IUniverseVariable*>& Universe:: UniverseJavaSolver:: getVariablesMapping() override
Returns | The mapping of the variables. |
---|
Gives the mapping of the variables in this solver.
const std::vector<std::string>& Universe:: UniverseJavaSolver:: getAuxiliaryVariables() override
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<Universe:: IUniverseConstraint*>& Universe:: UniverseJavaSolver:: getConstraints() override
Returns | The list of the constraints. |
---|
Gives the list of the constraints in this solver.
void Universe:: UniverseJavaSolver:: decisionVariables(const std::vector<std::string>& variables) override
Parameters | |
---|---|
variables | The variables on which to make decisions. |
Advises this solver to focus on some variables to make decisions.
void Universe:: UniverseJavaSolver:: valueHeuristicStatic(const std::vector<std::string>& variables,
const std::vector<Universe:: BigInteger>& orderedValues) override
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:: UniverseJavaSolver:: nConstraints() override
Returns | The number of constraints. |
---|
Gives the number of constraints defined in this solver.
bool Universe:: UniverseJavaSolver:: isOptimization() override
Returns | Whether the problem is an optimization problem. |
---|
Checks whether the associated problem is an optimization problem.
void Universe:: UniverseJavaSolver:: setTimeout(long seconds) override
Parameters | |
---|---|
seconds | The time limit to set (in seconds). |
Sets the time limit before interrupting the search.
void Universe:: UniverseJavaSolver:: setTimeoutMs(long mseconds) override
Sets the time limit before interrupting the search.
void Universe:: UniverseJavaSolver:: setVerbosity(int level) override
Parameters | |
---|---|
level | The verbosity level to set. |
Sets the verbosity level of the solver.
void Universe:: UniverseJavaSolver:: addSearchListener(Universe:: IUniverseSearchListener* listener) override
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:: UniverseJavaSolver:: removeSearchListener(Universe:: IUniverseSearchListener* listener) override
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:: UniverseJavaSolver:: setLogFile(const std::string& filename) override
Parameters | |
---|---|
filename | The name of the log file. |
Sets the log file to be used by the solver.
void Universe:: UniverseJavaSolver:: setLogStream(std::ostream& stream) override
Parameters | |
---|---|
stream | The logging output stream. |
Sets the output stream to be used by the solver for logging.
void Universe:: UniverseJavaSolver:: loadInstance(const std::string& filename) override
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:: UniverseJavaSolver:: solve() override
Returns | The outcome of the search conducted by the solver. |
---|
Solves the problem associated to this solver.
UniverseSolverResult Universe:: UniverseJavaSolver:: solve(const std::string& filename) override
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:: UniverseJavaSolver:: solve(const std::vector<UniverseAssumption<Universe:: BigInteger>>& assumptions) override
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:: UniverseJavaSolver:: interrupt() override
Interrupts (asynchronously) the search currently performed by this solver.
std::vector<Universe:: BigInteger> Universe:: UniverseJavaSolver:: solution() override
Returns | The solution found by this solver. |
---|
Gives the solution found by this solver (if any).
std::map<std::string, Universe:: BigInteger> Universe:: UniverseJavaSolver:: mapSolution() override
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:: UniverseJavaSolver:: mapSolution(bool excludeAux) override
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:: UniverseJavaSolver:: checkSolution() override
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:: UniverseJavaSolver:: checkSolution(const std::map<std::string, Universe:: BigInteger>& assignment) override
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:: UniverseJavaSolver:: toOptimizationSolver() override
Returns | The casted optimization solver. |
---|
Casts this solver into an IOptimizationSolver.
template<typename T>
static Universe:: JavaList Universe:: UniverseJavaSolver:: toJavaAssumptions(std::vector<Universe:: UniverseAssumption<T>> assumptions,
std::function<easyjni::JavaObject(T)> toJavaObject) protected
Template parameters | |
---|---|
T | The type of the assumed values. |
Parameters | |
assumptions | The native assumptions. |
toJavaObject | The function to apply to transform an assumed value to a JavaObject. |
Returns | The JavaList representing the assumptions. |
Creates a JavaList representing a vector of native UniverseAssumption instances.
static Universe:: UniverseSolverResult Universe:: UniverseJavaSolver:: toUniverseSolverResult(easyjni::JavaObject javaResult) protected
Parameters | |
---|---|
javaResult | The Java object to convert. |
Returns | The UniverseSolverResult corresponding to the given object. |
Converts the Java representation of a UniverseSolverResult to its native equivalent.
Variable documentation
easyjni::JavaClass* Universe:: UniverseJavaSolver:: interface protected
The Java interface corresponding to IUniverseSolver.
easyjni::JavaObject Universe:: UniverseJavaSolver:: object protected
The Java object to adapt.
std::map<std::string, Universe:: IUniverseVariable*> Universe:: UniverseJavaSolver:: mapping protected
The mapping of the variables.
std::vector<std::string> Universe:: UniverseJavaSolver:: auxiliaryVariables protected
The name of the auxiliary variables used by the solver.
std::vector<IUniverseConstraint*> Universe:: UniverseJavaSolver:: constraints protected
The constraints used by the solver.