Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.sat.python.cp_model.CpSolverSolutionCallback Class Reference

Detailed Description

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 2796 of file cp_model.py.

Inheritance diagram for ortools.sat.python.cp_model.CpSolverSolutionCallback:
ortools.sat.python.cp_model.ObjectiveSolutionPrinter ortools.sat.python.cp_model.VarArrayAndObjectiveSolutionPrinter ortools.sat.python.cp_model.VarArraySolutionPrinter

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_boolean_propagations (self)
float deterministic_time (self)
float wall_time (self)
float user_time (self)
cp_model_pb2.CpSolverResponse response_proto (self)

Constructor & Destructor Documentation

◆ __init__()

None ortools.sat.python.cp_model.CpSolverSolutionCallback.__init__ ( self)

Definition at line 2810 of file cp_model.py.

Member Function Documentation

◆ best_objective_bound()

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 2884 of file cp_model.py.

◆ boolean_value()

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 2817 of file cp_model.py.

◆ deterministic_time()

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 2926 of file cp_model.py.

◆ float_value()

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 2850 of file cp_model.py.

◆ has_response()

bool ortools.sat.python.cp_model.CpSolverSolutionCallback.has_response ( self)

Definition at line 2867 of file cp_model.py.

◆ num_boolean_propagations()

int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_boolean_propagations ( self)
Returns the number of Boolean propagations done by the solver.

Definition at line 2919 of file cp_model.py.

◆ num_booleans()

int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_booleans ( self)
Returns the number of boolean variables managed by the SAT solver.

Definition at line 2891 of file cp_model.py.

◆ num_branches()

int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_branches ( self)
Returns the number of search branches explored by the solver.

Definition at line 2905 of file cp_model.py.

◆ num_conflicts()

int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_conflicts ( self)
Returns the number of conflicts since the creation of the solver.

Definition at line 2898 of file cp_model.py.

◆ num_integer_propagations()

int ortools.sat.python.cp_model.CpSolverSolutionCallback.num_integer_propagations ( self)
Returns the number of integer propagations done by the solver.

Definition at line 2912 of file cp_model.py.

◆ objective_value()

float ortools.sat.python.cp_model.CpSolverSolutionCallback.objective_value ( self)
Returns the value of the objective after solve.

Definition at line 2877 of file cp_model.py.

◆ OnSolutionCallback()

None ortools.sat.python.cp_model.CpSolverSolutionCallback.OnSolutionCallback ( self)
Proxy for the same method in snake case.

Definition at line 2813 of file cp_model.py.

◆ response_proto()

cp_model_pb2.CpSolverResponse ortools.sat.python.cp_model.CpSolverSolutionCallback.response_proto ( self)
Returns the response object.

Definition at line 2947 of file cp_model.py.

◆ stop_search()

None ortools.sat.python.cp_model.CpSolverSolutionCallback.stop_search ( self)
Stops the current search asynchronously.

Definition at line 2870 of file cp_model.py.

◆ user_time()

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 2940 of file cp_model.py.

◆ value()

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 2833 of file cp_model.py.

◆ wall_time()

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 2933 of file cp_model.py.


The documentation for this class was generated from the following file: