![]() |
Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
|
Public Member Functions | |
None | __init__ (self, "CpModel" cp_model) |
"Constraint" | only_enforce_if (self, Iterable[LiteralT] boolvar) |
"Constraint" | only_enforce_if (self, *LiteralT boolvar) |
"Constraint" | only_enforce_if (self, *boolvar) |
"Constraint" | with_name (self, str name) |
str | name (self) |
int | index (self) |
cp_model_pb2.ConstraintProto | proto (self) |
str | Name (self) |
int | Index (self) |
cp_model_pb2.ConstraintProto | Proto (self) |
Static Public Attributes | |
"Constraint" | OnlyEnforceIf = only_enforce_if |
"Constraint" | WithName = with_name |
Base class for constraints. Constraints are built by the CpModel through the add<XXX> methods. Once created by the CpModel class, they are automatically added to the model. The purpose of this class is to allow specification of enforcement literals for this constraint. b = model.new_bool_var('b') x = model.new_int_var(0, 10, 'x') y = model.new_int_var(0, 10, 'y') model.add(x + 2 * y == 5).only_enforce_if(b.negated())
Definition at line 311 of file cp_model.py.
None ortools.sat.python.cp_model.Constraint.__init__ | ( | self, | |
"CpModel" | cp_model ) |
Definition at line 326 of file cp_model.py.
int ortools.sat.python.cp_model.Constraint.Index | ( | self | ) |
Definition at line 410 of file cp_model.py.
int ortools.sat.python.cp_model.Constraint.index | ( | self | ) |
Returns the index of the constraint in the model.
Definition at line 393 of file cp_model.py.
str ortools.sat.python.cp_model.Constraint.Name | ( | self | ) |
Definition at line 407 of file cp_model.py.
str ortools.sat.python.cp_model.Constraint.name | ( | self | ) |
Returns the name of the constraint.
Definition at line 386 of file cp_model.py.
"Constraint" ortools.sat.python.cp_model.Constraint.only_enforce_if | ( | self, | |
* | boolvar ) |
Adds an enforcement literal to the constraint. This method adds one or more literals (that is, a boolean variable or its negation) as enforcement literals. The conjunction of all these literals determines whether the constraint is active or not. It acts as an implication, so if the conjunction is true, it implies that the constraint must be enforced. If it is false, then the constraint is ignored. BoolOr, BoolAnd, and linear constraints all support enforcement literals. Args: *boolvar: One or more Boolean literals. Returns: self.
Definition at line 342 of file cp_model.py.
"Constraint" ortools.sat.python.cp_model.Constraint.only_enforce_if | ( | self, | |
*LiteralT | boolvar ) |
Definition at line 340 of file cp_model.py.
"Constraint" ortools.sat.python.cp_model.Constraint.only_enforce_if | ( | self, | |
Iterable[LiteralT] | boolvar ) |
Definition at line 337 of file cp_model.py.
cp_model_pb2.ConstraintProto ortools.sat.python.cp_model.Constraint.Proto | ( | self | ) |
Definition at line 413 of file cp_model.py.
cp_model_pb2.ConstraintProto ortools.sat.python.cp_model.Constraint.proto | ( | self | ) |
Returns the constraint protobuf.
Definition at line 398 of file cp_model.py.
"Constraint" ortools.sat.python.cp_model.Constraint.with_name | ( | self, | |
str | name ) |
Sets the name of the constraint.
Definition at line 377 of file cp_model.py.
|
static |
Definition at line 404 of file cp_model.py.
|
static |
Definition at line 405 of file cp_model.py.