[CP-SAT] little cleanups
This commit is contained in:
committed by
Corentin Le Molgat
parent
2a352d1f3f
commit
0cbdbb78f1
@@ -125,9 +125,11 @@ inline std::vector<IntegerValue> ToIntegerValueVector(
|
||||
|
||||
// Enforces the XOR of a set of literals to be equal to the given value.
|
||||
inline std::function<void(Model*)> LiteralXorIs(
|
||||
const std::vector<Literal>& enforcement_literals,
|
||||
absl::Span<const Literal> enforcement_literals,
|
||||
const std::vector<Literal>& literals, bool value) {
|
||||
return [=](Model* model) {
|
||||
return [=, enforcement_literals = std::vector<Literal>(
|
||||
enforcement_literals.begin(), enforcement_literals.end())](
|
||||
Model* model) {
|
||||
model->TakeOwnership(
|
||||
new BooleanXorPropagator(enforcement_literals, literals, value, model));
|
||||
};
|
||||
|
||||
@@ -2390,7 +2390,7 @@ void ExpandSomeLinearOfSizeTwo(ConstraintProto* ct, PresolveContext* context) {
|
||||
reachable_rhs_superset.IntersectionWith(rhs.Complement());
|
||||
|
||||
// Let's check we will not create encoding literals for variables that are too
|
||||
// large, or have little encoding literals.
|
||||
// large, or have few encoding literals.
|
||||
const bool small_enough = context->DomainSize(var1) <= max_domain_size &&
|
||||
context->DomainSize(var2) <= max_domain_size &&
|
||||
context->IsMostlyFullyEncoded(var1) &&
|
||||
|
||||
@@ -1091,7 +1091,7 @@ bool ConvertCpModelProtoToCnf(const CpModelProto& cp_model, std::string* out) {
|
||||
|
||||
absl::StrAppend(out, "p cnf ", num_vars, " ", num_clauses, "\n");
|
||||
ConvertSatCpModelProtoToClauses(
|
||||
cp_model, [&out](const std::vector<Literal>& clause) {
|
||||
cp_model, [&out](absl::Span<const Literal> clause) {
|
||||
for (const Literal lit : clause) {
|
||||
absl::StrAppend(out, lit.SignedValue(), " ");
|
||||
}
|
||||
|
||||
@@ -1682,7 +1682,7 @@ PYBIND11_MODULE(cp_model_helper, m) {
|
||||
.def("__bool__",
|
||||
[](std::shared_ptr<Literal> /*self*/) {
|
||||
ThrowError(PyExc_NotImplementedError,
|
||||
"Evaluating a Literal as a Boolean valueis "
|
||||
"Evaluating a Literal as a Boolean value is "
|
||||
"not supported.");
|
||||
})
|
||||
.def("__hash__", &Literal::Hash)
|
||||
|
||||
@@ -515,7 +515,7 @@ message SatParameters {
|
||||
optional bool expand_reservoir_constraints = 182 [default = true];
|
||||
|
||||
// Max domain size for expanding linear2 constraints (ax + by ==/!= c).
|
||||
optional int32 max_domain_size_for_linear2_expansion = 336 [default = 32];
|
||||
optional int32 max_domain_size_for_linear2_expansion = 336 [default = 8];
|
||||
|
||||
// Mainly useful for testing.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user