public class MasterSolver extends AbstractParallelMaster<SlaveSolver>
The expected ways to solve a problem using MasterSolver is:
Solver solver = new Solver(); // declare the variables and constraints // and an optional search strategy //... // Then create the master-solver MasterSolver ms = new MasterSolver(); // duplicate the solver into 4 solvers (1+3) ms.populate(solver, 3); // configure the search strategies (optional, but recommended) ms.configureSearches(); // Finally, solve the problem ms.findSolution();
Modifier and Type | Field and Description |
---|---|
protected Solver[] |
solvers
Pool of solvers to drive
|
nbWorkingSlaves, slaves, wait
Constructor and Description |
---|
MasterSolver() |
Modifier and Type | Method and Description |
---|---|
void |
declare(Solver... solvers)
An alternative to
populate(Solver, int) where the initial
model has already been duplicated. |
void |
declareSettings(Settings... settings)
Declare a specific
Settings to each solver. |
void |
findOptimalSolution(ResolutionPolicy policy,
IntVar objective)
Attempts optimize the value of the
objective variable w.r.t. to the optimization policy . |
boolean |
findSolution()
Attempts to find the first solution of the declared problem, running all solvers declared.
|
Solver[] |
getSolvers()
Return the solvers to drive
|
boolean |
hasReachedLimit()
Returns information on the completeness of the search process.
|
ESat |
isFeasible()
Returns information on the feasibility of the current problem defined by the solver.
|
void |
populate(Solver model,
int n)
Make
n-1 copies of the current model ,
the first solver of the array is the one given in parameter. |
void |
wishGranted()
A slave notify the master that he fulfilled his task
|
distributedSlavery, sequentialSlavery
protected Solver[] solvers
public void populate(Solver model, int n)
n-1
copies of the current model
,
the first solver of the array is the one given in parameter.
The solvers created are available thanks to the
Thus, there is n solvers in the returned array
Note that only the variables and the constraints are duplicated.model
- the model to duplicaten
- number of of copies to make.public void declare(Solver... solvers)
populate(Solver, int)
where the initial
model has already been duplicated.
The first solver in the array needs to be the original one (required for optimization problem)solvers
- the set of solvers to drive.public Solver[] getSolvers()
public void declareSettings(Settings... settings)
Settings
to each solver.
Calling this method is highly recommended to, at least, configure the search strategies for each solver.settings
- array of settingspublic ESat isFeasible()
Possible back values are:
- ESat.TRUE
: a solution has been found,
- ESat.FALSE
: the CSP has been proven to have no solution,
- ESat.UNDEFINED
: no solution has been found so far (within given limits)
without proving the unfeasibility, though.
ESat
.public boolean hasReachedLimit()
A call to isFeasible()
may provide complementary information.
Possible back values are:
- false
: the resolution is complete and
* findSolution()
: a solution has been found or the CSP has been proven to be unsatisfiable.
* findOptimalSolution(ResolutionPolicy, IntVar)
: the optimal solution has been found and
proven to be optimal, or the CSP has been proven to be unsatisfiable.
- true
: the resolution stopped after reaching a limit.
public boolean findSolution()
true
if and only if a solution has been found.public void findOptimalSolution(ResolutionPolicy policy, IntVar objective)
objective
variable w.r.t. to the optimization policy
.
Restores the best solution found so far (if any)policy
- optimization policy, among ResolutionPolicy.MINIMIZE and ResolutionPolicy.MAXIMIZEobjective
- the variable to optimize, the variable must be declared in solvers[0].public void wishGranted()
AbstractParallelMaster
wishGranted
in class AbstractParallelMaster<SlaveSolver>
Copyright © 2015. All rights reserved.