minor simplifications for number_generation

This commit is contained in:
lperron@google.com
2012-09-03 20:20:34 +00:00
parent 062e8cba72
commit 491b9d8676

View File

@@ -1450,6 +1450,34 @@ bool ParserState::PresolveOneConstraint(CtSpec* const spec) {
}
}
}
if (id == "int_div") {
if (IsBound(spec->Arg(0)) && IsBound(spec->Arg(1))) {
const int64 div = GetBound(spec->Arg(0)) / GetBound(spec->Arg(1));
if (spec->Arg(2)->isIntVar()) {
IntVarSpec* const var_spec = int_variables_[spec->Arg(2)->getIntVar()];
VLOG(1) << " - presolve: assign " << var_spec->DebugString()
<< " to " << div;
if (var_spec->MergeBounds(div, div)) {
spec->Nullify();
return true;
}
}
}
}
if (id == "int_times") {
if (IsBound(spec->Arg(0)) && IsBound(spec->Arg(1))) {
const int64 div = GetBound(spec->Arg(0)) * GetBound(spec->Arg(1));
if (spec->Arg(2)->isIntVar()) {
IntVarSpec* const var_spec = int_variables_[spec->Arg(2)->getIntVar()];
VLOG(1) << " - presolve: assign " << var_spec->DebugString()
<< " to " << div;
if (var_spec->MergeBounds(div, div)) {
spec->Nullify();
return true;
}
}
}
}
return false;
}