![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
Methods for building and solving CP-SAT models.
The following two sections describe the main
methods for building and solving CP-SAT models.
* [`CpModel`](#cp_model.CpModel): Methods for creating models, including
variables and constraints.
* [`CpSolver`](#cp_model.CpSolver): Methods for solving a model and evaluating
solutions.
The following methods implement callbacks that the
solver calls each time it finds a new solution.
* [`CpSolverSolutionCallback`](#cp_model.CpSolverSolutionCallback):
A general method for implementing callbacks.
* [`ObjectiveSolutionPrinter`](#cp_model.ObjectiveSolutionPrinter):
Print objective values and elapsed time for intermediate solutions.
* [`VarArraySolutionPrinter`](#cp_model.VarArraySolutionPrinter):
Print intermediate solutions (variable values, time).
* [`VarArrayAndObjectiveSolutionPrinter`]
(#cp_model.VarArrayAndObjectiveSolutionPrinter):
Print both intermediate solutions and objective values.
Additional methods for solving CP-SAT models:
* [`Constraint`](#cp_model.Constraint): A few utility methods for modifying
constraints created by `CpModel`.
* [`LinearExpr`](#lineacp_model.LinearExpr): Methods for creating constraints
and the objective from large arrays of coefficients.
Other methods and functions listed are primarily used for developing OR-Tools,
rather than for solving specific optimization problems.
Classes | |
| class | CpModel |
| class | CpSolver |
| class | CpSolverSolutionCallback |
| class | ObjectiveSolutionPrinter |
| class | VarArrayAndObjectiveSolutionPrinter |
| class | VarArraySolutionPrinter |
Functions | |
| Callable[[Callable], Callable] | deprecated (str message) |
| Callable | deprecated_method (func, str old_name) |
| str | snake_case_to_camel_case (str name) |
| bool | object_is_a_true_literal (LiteralT literal) |
| bool | object_is_a_false_literal (LiteralT literal) |
| pd.Index | _get_index (_IndexOrSeries obj) |
| pd.Series | _convert_to_series_and_validate_index (Union[LinearExprT, pd.Series] value_or_series, pd.Index index) |
| pd.Series | _convert_to_series_and_validate_index (Union[LiteralT, pd.Series] value_or_series, pd.Index index) |
| pd.Series | _convert_to_series_and_validate_index (Union[IntegralT, pd.Series] value_or_series, pd.Index index) |
| _convert_to_series_and_validate_index (value_or_series, index) | |
Variables | |
| BoundedLinearExpression = cmh.BoundedLinearExpression | |
| Constraint = cmh.Constraint | |
| CpModelProto = cmh.CpModelProto | |
| CpSolverResponse = cmh.CpSolverResponse | |
| CpSolverStatus = cmh.CpSolverStatus | |
| Domain = sorted_interval_list.Domain | |
| FlatFloatExpr = cmh.FlatFloatExpr | |
| FlatIntExpr = cmh.FlatIntExpr | |
| IntervalVar = cmh.IntervalVar | |
| IntVar = cmh.IntVar | |
| LinearExpr = cmh.LinearExpr | |
| NotBooleanVariable = cmh.NotBooleanVariable | |
| SatParameters = cmh.SatParameters | |
| INT_MIN = -(2**63) | |
| int | INT_MAX = 2**63 - 1 |
| INT32_MIN = -(2**31) | |
| int | INT32_MAX = 2**31 - 1 |
| UNKNOWN = cmh.CpSolverStatus.UNKNOWN | |
| MODEL_INVALID = cmh.CpSolverStatus.MODEL_INVALID | |
| FEASIBLE = cmh.CpSolverStatus.FEASIBLE | |
| INFEASIBLE = cmh.CpSolverStatus.INFEASIBLE | |
| OPTIMAL = cmh.CpSolverStatus.OPTIMAL | |
| CHOOSE_FIRST = cmh.DecisionStrategyProto.VariableSelectionStrategy.CHOOSE_FIRST | |
| tuple | CHOOSE_LOWEST_MIN |
| tuple | CHOOSE_HIGHEST_MAX |
| tuple | CHOOSE_MIN_DOMAIN_SIZE |
| tuple | CHOOSE_MAX_DOMAIN_SIZE |
| SELECT_MIN_VALUE = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_MIN_VALUE | |
| SELECT_MAX_VALUE = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_MAX_VALUE | |
| SELECT_LOWER_HALF = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_LOWER_HALF | |
| SELECT_UPPER_HALF = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_UPPER_HALF | |
| tuple | SELECT_MEDIAN_VALUE |
| tuple | SELECT_RANDOM_HALF |
| AUTOMATIC_SEARCH = cmh.SatParameters.SearchBranching.AUTOMATIC_SEARCH | |
| FIXED_SEARCH = cmh.SatParameters.SearchBranching.FIXED_SEARCH | |
| PORTFOLIO_SEARCH = cmh.SatParameters.SearchBranching.PORTFOLIO_SEARCH | |
| LP_SEARCH = cmh.SatParameters.SearchBranching.LP_SEARCH | |
| PSEUDO_COST_SEARCH = cmh.SatParameters.SearchBranching.PSEUDO_COST_SEARCH | |
| tuple | PORTFOLIO_WITH_QUICK_RESTART_SEARCH |
| HINT_SEARCH = cmh.SatParameters.SearchBranching.HINT_SEARCH | |
| PARTIAL_FIXED_SEARCH = cmh.SatParameters.SearchBranching.PARTIAL_FIXED_SEARCH | |
| RANDOMIZED_SEARCH = cmh.SatParameters.SearchBranching.RANDOMIZED_SEARCH | |
| IntegralT = Union[int, np.int8, np.uint8, np.int32, np.uint32, np.int64, np.uint64] | |
| tuple | IntegralTypes |
| NumberT | |
| tuple | NumberTypes |
| LiteralT = Union[cmh.Literal, IntegralT, bool] | |
| BoolVarT = cmh.Literal | |
| VariableT = Union["IntVar", IntegralT] | |
| LinearExprT = Union[LinearExpr, "IntVar", IntegralT] | |
| ObjLinearExprT = Union[LinearExpr, NumberT] | |
| ArcT = tuple[IntegralT, IntegralT, LiteralT] | |
| _IndexOrSeries = Union[pd.Index, pd.Series] | |
| bool | enable_warnings = False |
|
protected |
Definition at line 291 of file cp_model.py.
|
protected |
Definition at line 279 of file cp_model.py.
|
protected |
Definition at line 285 of file cp_model.py.
|
protected |
Returns a pd.Series of the given index with the corresponding values.
Definition at line 296 of file cp_model.py.
|
protected |
Returns the indices of `obj` as a `pd.Index`.
Definition at line 271 of file cp_model.py.
| Callable[[Callable], Callable] ortools.sat.python.cp_model.deprecated | ( | str | message | ) |
Decorator that warns about a deprecated function.
Definition at line 191 of file cp_model.py.
| Callable ortools.sat.python.cp_model.deprecated_method | ( | func, | |
| str | old_name ) |
Wrapper that warns about a deprecated method.
Definition at line 210 of file cp_model.py.
| bool ortools.sat.python.cp_model.object_is_a_false_literal | ( | LiteralT | literal | ) |
Checks if literal is either False, or a Boolean literals fixed to False.
Definition at line 255 of file cp_model.py.
| bool ortools.sat.python.cp_model.object_is_a_true_literal | ( | LiteralT | literal | ) |
Checks if literal is either True, or a Boolean literals fixed to True.
Definition at line 239 of file cp_model.py.
| str ortools.sat.python.cp_model.snake_case_to_camel_case | ( | str | name | ) |
Converts a snake_case name to CamelCase.
Definition at line 229 of file cp_model.py.
|
protected |
Definition at line 183 of file cp_model.py.
Definition at line 182 of file cp_model.py.
| ortools.sat.python.cp_model.AUTOMATIC_SEARCH = cmh.SatParameters.SearchBranching.AUTOMATIC_SEARCH |
Definition at line 128 of file cp_model.py.
| ortools.sat.python.cp_model.BoolVarT = cmh.Literal |
Definition at line 175 of file cp_model.py.
| ortools.sat.python.cp_model.BoundedLinearExpression = cmh.BoundedLinearExpression |
Definition at line 68 of file cp_model.py.
| ortools.sat.python.cp_model.CHOOSE_FIRST = cmh.DecisionStrategyProto.VariableSelectionStrategy.CHOOSE_FIRST |
Definition at line 101 of file cp_model.py.
| tuple ortools.sat.python.cp_model.CHOOSE_HIGHEST_MAX |
Definition at line 105 of file cp_model.py.
| tuple ortools.sat.python.cp_model.CHOOSE_LOWEST_MIN |
Definition at line 102 of file cp_model.py.
| tuple ortools.sat.python.cp_model.CHOOSE_MAX_DOMAIN_SIZE |
Definition at line 111 of file cp_model.py.
| tuple ortools.sat.python.cp_model.CHOOSE_MIN_DOMAIN_SIZE |
Definition at line 108 of file cp_model.py.
| ortools.sat.python.cp_model.Constraint = cmh.Constraint |
Definition at line 69 of file cp_model.py.
| ortools.sat.python.cp_model.CpModelProto = cmh.CpModelProto |
Definition at line 70 of file cp_model.py.
| ortools.sat.python.cp_model.CpSolverResponse = cmh.CpSolverResponse |
Definition at line 71 of file cp_model.py.
| ortools.sat.python.cp_model.CpSolverStatus = cmh.CpSolverStatus |
Definition at line 72 of file cp_model.py.
| ortools.sat.python.cp_model.Domain = sorted_interval_list.Domain |
Definition at line 73 of file cp_model.py.
| bool ortools.sat.python.cp_model.enable_warnings = False |
Definition at line 187 of file cp_model.py.
| ortools.sat.python.cp_model.FEASIBLE = cmh.CpSolverStatus.FEASIBLE |
Definition at line 96 of file cp_model.py.
| ortools.sat.python.cp_model.FIXED_SEARCH = cmh.SatParameters.SearchBranching.FIXED_SEARCH |
Definition at line 129 of file cp_model.py.
| ortools.sat.python.cp_model.FlatFloatExpr = cmh.FlatFloatExpr |
Definition at line 74 of file cp_model.py.
| ortools.sat.python.cp_model.FlatIntExpr = cmh.FlatIntExpr |
Definition at line 75 of file cp_model.py.
| ortools.sat.python.cp_model.HINT_SEARCH = cmh.SatParameters.SearchBranching.HINT_SEARCH |
Definition at line 136 of file cp_model.py.
| ortools.sat.python.cp_model.INFEASIBLE = cmh.CpSolverStatus.INFEASIBLE |
Definition at line 97 of file cp_model.py.
| int ortools.sat.python.cp_model.INT32_MAX = 2**31 - 1 |
Definition at line 90 of file cp_model.py.
| ortools.sat.python.cp_model.INT32_MIN = -(2**31) |
Definition at line 89 of file cp_model.py.
| int ortools.sat.python.cp_model.INT_MAX = 2**63 - 1 |
Definition at line 88 of file cp_model.py.
| ortools.sat.python.cp_model.INT_MIN = -(2**63) |
Definition at line 87 of file cp_model.py.
| ortools.sat.python.cp_model.IntegralT = Union[int, np.int8, np.uint8, np.int32, np.uint32, np.int64, np.uint64] |
Definition at line 141 of file cp_model.py.
| tuple ortools.sat.python.cp_model.IntegralTypes |
Definition at line 142 of file cp_model.py.
| ortools.sat.python.cp_model.IntervalVar = cmh.IntervalVar |
Definition at line 76 of file cp_model.py.
| ortools.sat.python.cp_model.IntVar = cmh.IntVar |
Definition at line 77 of file cp_model.py.
| ortools.sat.python.cp_model.LinearExpr = cmh.LinearExpr |
Definition at line 78 of file cp_model.py.
| ortools.sat.python.cp_model.LinearExprT = Union[LinearExpr, "IntVar", IntegralT] |
Definition at line 179 of file cp_model.py.
| ortools.sat.python.cp_model.LiteralT = Union[cmh.Literal, IntegralT, bool] |
Definition at line 174 of file cp_model.py.
| ortools.sat.python.cp_model.LP_SEARCH = cmh.SatParameters.SearchBranching.LP_SEARCH |
Definition at line 131 of file cp_model.py.
| ortools.sat.python.cp_model.MODEL_INVALID = cmh.CpSolverStatus.MODEL_INVALID |
Definition at line 95 of file cp_model.py.
| ortools.sat.python.cp_model.NotBooleanVariable = cmh.NotBooleanVariable |
Definition at line 79 of file cp_model.py.
| ortools.sat.python.cp_model.NumberT |
Definition at line 151 of file cp_model.py.
| tuple ortools.sat.python.cp_model.NumberTypes |
Definition at line 162 of file cp_model.py.
| ortools.sat.python.cp_model.ObjLinearExprT = Union[LinearExpr, NumberT] |
Definition at line 180 of file cp_model.py.
| ortools.sat.python.cp_model.OPTIMAL = cmh.CpSolverStatus.OPTIMAL |
Definition at line 98 of file cp_model.py.
| ortools.sat.python.cp_model.PARTIAL_FIXED_SEARCH = cmh.SatParameters.SearchBranching.PARTIAL_FIXED_SEARCH |
Definition at line 137 of file cp_model.py.
| ortools.sat.python.cp_model.PORTFOLIO_SEARCH = cmh.SatParameters.SearchBranching.PORTFOLIO_SEARCH |
Definition at line 130 of file cp_model.py.
| tuple ortools.sat.python.cp_model.PORTFOLIO_WITH_QUICK_RESTART_SEARCH |
Definition at line 133 of file cp_model.py.
| ortools.sat.python.cp_model.PSEUDO_COST_SEARCH = cmh.SatParameters.SearchBranching.PSEUDO_COST_SEARCH |
Definition at line 132 of file cp_model.py.
| ortools.sat.python.cp_model.RANDOMIZED_SEARCH = cmh.SatParameters.SearchBranching.RANDOMIZED_SEARCH |
Definition at line 138 of file cp_model.py.
| ortools.sat.python.cp_model.SatParameters = cmh.SatParameters |
Definition at line 80 of file cp_model.py.
| ortools.sat.python.cp_model.SELECT_LOWER_HALF = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_LOWER_HALF |
Definition at line 118 of file cp_model.py.
| ortools.sat.python.cp_model.SELECT_MAX_VALUE = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_MAX_VALUE |
Definition at line 117 of file cp_model.py.
| tuple ortools.sat.python.cp_model.SELECT_MEDIAN_VALUE |
Definition at line 120 of file cp_model.py.
| ortools.sat.python.cp_model.SELECT_MIN_VALUE = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_MIN_VALUE |
Definition at line 116 of file cp_model.py.
| tuple ortools.sat.python.cp_model.SELECT_RANDOM_HALF |
Definition at line 123 of file cp_model.py.
| ortools.sat.python.cp_model.SELECT_UPPER_HALF = cmh.DecisionStrategyProto.DomainReductionStrategy.SELECT_UPPER_HALF |
Definition at line 119 of file cp_model.py.
| ortools.sat.python.cp_model.UNKNOWN = cmh.CpSolverStatus.UNKNOWN |
Definition at line 93 of file cp_model.py.
| ortools.sat.python.cp_model.VariableT = Union["IntVar", IntegralT] |
Definition at line 176 of file cp_model.py.