![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
Solution callback. This class implements a callback that will be called at each new solution found during search. The method on_solution_callback() will be called by the solver, and must be implemented. The current solution can be queried using the boolean_value() and value() methods. These methods returns the same information as their counterpart in the `CpSolver` class.
Definition at line 2095 of file cp_model.py.
Public Member Functions | |
| None | __init__ (self) |
| None | OnSolutionCallback (self) |
| bool | boolean_value (self, LiteralT lit) |
| int | value (self, LinearExprT expression) |
| float | float_value (self, LinearExprT expression) |
| bool | has_response (self) |
| None | stop_search (self) |
| float | objective_value (self) |
| float | best_objective_bound (self) |
| int | num_booleans (self) |
| int | num_conflicts (self) |
| int | num_branches (self) |
| int | num_integer_propagations (self) |
| int | num_binary_propagations (self) |
| float | deterministic_time (self) |
| float | wall_time (self) |
| float | user_time (self) |
| cmh.CpSolverResponse | response_proto (self) |
| None ortools.sat.python.cp_model.CpSolverSolutionCallback.__init__ | ( | self | ) |
Definition at line 2109 of file cp_model.py.
| float ortools.sat.python.cp_model.CpSolverSolutionCallback.best_objective_bound | ( | self | ) |
Returns the best lower (upper) bound found when min(max)imizing.
Definition at line 2186 of file cp_model.py.
| bool ortools.sat.python.cp_model.CpSolverSolutionCallback.boolean_value | ( | self, | |
| LiteralT | lit ) |
Returns the boolean value of a boolean literal.
Args:
lit: A boolean variable or its negation.
Returns:
The Boolean value of the literal in the solution.
Raises:
RuntimeError: if `lit` is not a boolean variable or its negation.
Definition at line 2119 of file cp_model.py.
| float ortools.sat.python.cp_model.CpSolverSolutionCallback.deterministic_time | ( | self | ) |
Returns the determistic time in seconds since the creation of the solver.
Definition at line 2228 of file cp_model.py.
| float ortools.sat.python.cp_model.CpSolverSolutionCallback.float_value | ( | self, | |
| LinearExprT | expression ) |
Evaluates an linear expression in the current solution.
Args:
expression: a linear expression of the model.
Returns:
An integer value equal to the evaluation of the linear expression
against the current solution.
Raises:
RuntimeError: if 'expression' is not a LinearExpr.
Definition at line 2152 of file cp_model.py.
| bool ortools.sat.python.cp_model.CpSolverSolutionCallback.has_response | ( | self | ) |
Definition at line 2169 of file cp_model.py.
| int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_binary_propagations | ( | self | ) |
Returns the number of Boolean propagations done by the solver.
Definition at line 2221 of file cp_model.py.
| int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_booleans | ( | self | ) |
Returns the number of boolean variables managed by the SAT solver.
Definition at line 2193 of file cp_model.py.
| int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_branches | ( | self | ) |
Returns the number of search branches explored by the solver.
Definition at line 2207 of file cp_model.py.
| int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_conflicts | ( | self | ) |
Returns the number of conflicts since the creation of the solver.
Definition at line 2200 of file cp_model.py.
| int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_integer_propagations | ( | self | ) |
Returns the number of integer propagations done by the solver.
Definition at line 2214 of file cp_model.py.
| float ortools.sat.python.cp_model.CpSolverSolutionCallback.objective_value | ( | self | ) |
Returns the value of the objective after solve.
Definition at line 2179 of file cp_model.py.
| None ortools.sat.python.cp_model.CpSolverSolutionCallback.OnSolutionCallback | ( | self | ) |
Proxy for the same method in snake case.
Definition at line 2113 of file cp_model.py.
| cmh.CpSolverResponse ortools.sat.python.cp_model.CpSolverSolutionCallback.response_proto | ( | self | ) |
Returns the response object.
Definition at line 2249 of file cp_model.py.
| None ortools.sat.python.cp_model.CpSolverSolutionCallback.stop_search | ( | self | ) |
Stops the current search asynchronously.
Definition at line 2172 of file cp_model.py.
| float ortools.sat.python.cp_model.CpSolverSolutionCallback.user_time | ( | self | ) |
Returns the user time in seconds since the creation of the solver.
Definition at line 2242 of file cp_model.py.
| int ortools.sat.python.cp_model.CpSolverSolutionCallback.value | ( | self, | |
| LinearExprT | expression ) |
Evaluates an linear expression in the current solution.
Args:
expression: a linear expression of the model.
Returns:
An integer value equal to the evaluation of the linear expression
against the current solution.
Raises:
RuntimeError: if 'expression' is not a LinearExpr.
Definition at line 2135 of file cp_model.py.
| float ortools.sat.python.cp_model.CpSolverSolutionCallback.wall_time | ( | self | ) |
Returns the wall time in seconds since the creation of the solver.
Definition at line 2235 of file cp_model.py.