Class CpSolver
java.lang.Object
com.google.ortools.sat.CpSolver
Wrapper around the SAT solver.
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the best lower bound found when minimizing, of the best upper bound found when maximizing.booleanValue
(Literal var) Returns the Boolean value of a literal in the last solution found.void
Clears the best bound callback.void
Clears the log callback.Returns the builder of the parameters of the SAT solver for modification.Returns some information on how the solution was found, or the reason why the model or the parameters are invalid.long
Returns the number of branches explored during search.long
Returns the number of conflicts created during search.double
Returns the best objective value found during search.response()
Returns the internal response protobuf that is returned internally by the SAT solver.Returns some statistics on the solution found as a string.searchAllSolutions
(CpModel model, CpSolverSolutionCallback cb) Deprecated.Use the solve() method with the same signature, after setting the enumerate_all_solution parameter to true.void
Sets the best bound callback for the solver.void
setLogCallback
(Consumer<String> cb) Sets the log callback for the solver.Solves the given model, and returns the solve status.solve
(CpModel model, CpSolverSolutionCallback cb) Solves the given model, calls the solution callback at each incumbent solution, and returns the solve status.Deprecated.Use the solve() method with the same signature.void
Stops the search asynchronously.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.
-
Constructor Details
-
CpSolver
public CpSolver()Main construction of the CpSolver class.
-
-
Method Details
-
solve
Solves the given model, and returns the solve status. -
solve
Solves the given model, calls the solution callback at each incumbent solution, and returns the solve status. -
solveWithSolutionCallback
@Deprecated public CpSolverStatus solveWithSolutionCallback(CpModel model, CpSolverSolutionCallback cb) Deprecated.Use the solve() method with the same signature.Solves the given model, passes each incumber solution to the solution callback if not null, and returns the solve status. -
searchAllSolutions
Deprecated.Use the solve() method with the same signature, after setting the enumerate_all_solution parameter to true.Searches for all solutions of a satisfiability problem.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.
- Parameters:
model
- the model to solvecb
- the callback that will be called at each solution- Returns:
- the status of the solve (FEASIBLE, INFEASIBLE...)
-
stopSearch
public void stopSearch()Stops the search asynchronously. -
objectiveValue
public double objectiveValue()Returns the best objective value found during search. -
bestObjectiveBound
public double bestObjectiveBound()Returns the best lower bound found when minimizing, of the best upper bound found when maximizing. -
value
Returns the value of a linear expression in the last solution found. -
booleanValue
-
response
Returns the internal response protobuf that is returned internally by the SAT solver. -
numBranches
public long numBranches()Returns the number of branches explored during search. -
numConflicts
public long numConflicts()Returns the number of conflicts created during search. -
wallTime
public double wallTime()Returns the wall time of the search. -
userTime
public double userTime()Returns the user time of the search. -
sufficientAssumptionsForInfeasibility
-
getParameters
Returns the builder of the parameters of the SAT solver for modification. -
setLogCallback
-
clearLogCallback
public void clearLogCallback()Clears the log callback. -
setBestBoundCallback
-
clearBestBoundCallback
public void clearBestBoundCallback()Clears the best bound callback. -
responseStats
Returns some statistics on the solution found as a string. -
getSolutionInfo
Returns some information on how the solution was found, or the reason why the model or the parameters are invalid.
-