public final class CpSolver
extends java.lang.Object
This class proposes different solve() methods, as well as accessors to get the values of variables in the best solution, as well as general statistics of the search.
Constructor and Description |
---|
CpSolver()
Main construction of the CpSolver class.
|
Modifier and Type | Method and Description |
---|---|
double |
bestObjectiveBound()
Returns the best lower bound found when minimizing, of the best upper bound found when
maximizing.
|
java.lang.Boolean |
booleanValue(Literal var)
Returns the Boolean value of a literal in the last solution found.
|
void |
clearBestBoundCallback()
Clears the best bound callback.
|
void |
clearLogCallback()
Clears the log callback.
|
SatParameters.Builder |
getParameters()
Returns the builder of the parameters of the SAT solver for modification.
|
java.lang.String |
getSolutionInfo()
Returns some information on how the solution was found, or the reason why the model or the
parameters are invalid.
|
long |
numBranches()
Returns the number of branches explored during search.
|
long |
numConflicts()
Returns the number of conflicts created during search.
|
double |
objectiveValue()
Returns the best objective value found during search.
|
CpSolverResponse |
response()
Returns the internal response protobuf that is returned internally by the SAT solver.
|
java.lang.String |
responseStats()
Returns some statistics on the solution found as a string.
|
CpSolverStatus |
searchAllSolutions(CpModel model,
CpSolverSolutionCallback cb)
Deprecated.
Use the solve() method with the same signature, after setting the
enumerate_all_solution parameter to true.
|
void |
setBestBoundCallback(java.util.function.Consumer<java.lang.Double> cb)
Sets the best bound callback for the solver.
|
void |
setLogCallback(java.util.function.Consumer<java.lang.String> cb)
Sets the log callback for the solver.
|
CpSolverStatus |
solve(CpModel model)
Solves the given model, and returns the solve status.
|
CpSolverStatus |
solve(CpModel model,
CpSolverSolutionCallback cb)
Solves the given model, calls the solution callback at each incumbent solution, and returns the
solve status.
|
CpSolverStatus |
solveWithSolutionCallback(CpModel model,
CpSolverSolutionCallback cb)
Deprecated.
Use the solve() method with the same signature.
|
void |
stopSearch()
Stops the search asynchronously.
|
java.util.List<java.lang.Integer> |
sufficientAssumptionsForInfeasibility() |
double |
userTime()
Returns the user time of the search.
|
long |
value(LinearArgument expr)
Returns the value of a linear expression in the last solution found.
|
double |
wallTime()
Returns the wall time of the search.
|
public CpSolverStatus solve(CpModel model)
public CpSolverStatus solve(CpModel model, CpSolverSolutionCallback cb)
@Deprecated public CpSolverStatus solveWithSolutionCallback(CpModel model, CpSolverSolutionCallback cb)
@Deprecated public CpSolverStatus searchAllSolutions(CpModel model, CpSolverSolutionCallback cb)
This method searches for all feasible solutions of a given model. Then it feeds the solutions to the callback.
Note that the model cannot have an objective.
model
- the model to solvecb
- the callback that will be called at each solutionpublic void stopSearch()
public double objectiveValue()
public double bestObjectiveBound()
public long value(LinearArgument expr)
public java.lang.Boolean booleanValue(Literal var)
public CpSolverResponse response()
public long numBranches()
public long numConflicts()
public double wallTime()
public double userTime()
public java.util.List<java.lang.Integer> sufficientAssumptionsForInfeasibility()
public SatParameters.Builder getParameters()
public void setLogCallback(java.util.function.Consumer<java.lang.String> cb)
public void clearLogCallback()
public void setBestBoundCallback(java.util.function.Consumer<java.lang.Double> cb)
public void clearBestBoundCallback()
public java.lang.String responseStats()
public java.lang.String getSolutionInfo()
Copyright © 2025. All rights reserved.