Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <sat_inprocessing.h>
Public Member Functions | |
Inprocessing (Model *model) | |
bool | PresolveLoop (SatPresolveOptions options) |
bool | InprocessingRound () |
bool | LevelZeroPropagate () |
bool | DetectEquivalencesAndStamp (bool use_transitive_reduction, bool log_info) |
bool | RemoveFixedAndEquivalentVariables (bool log_info) |
bool | MoreFixedVariableToClean () const |
bool | MoreRedundantVariableToClean () const |
bool | SubsumeAndStrenghtenRound (bool log_info) |
void | ProvideLogger (SolverLogger *logger) |
A bit hacky. Only needed during refactoring. | |
We need to keep some information from one call to the next, so we use a class. Note that as this becomes big, we can probably split it.
Definition at line 97 of file sat_inprocessing.h.
|
inlineexplicit |
Definition at line 99 of file sat_inprocessing.h.
bool operations_research::sat::Inprocessing::DetectEquivalencesAndStamp | ( | bool | use_transitive_reduction, |
bool | log_info ) |
Detects equivalences in the implication graph and propagates any failed literal found during the process.
It make sense to do the pre-stamping right after the equivalence detection since it needs a DAG and can detect extra failed literal.
Definition at line 314 of file sat_inprocessing.cc.
bool operations_research::sat::Inprocessing::InprocessingRound | ( | ) |
When the option use_sat_inprocessing is true, then this is called at each restart. It is up to the heuristics here to decide what inprocessing we do or if we wait for the next call before doing anything.
Mainly useful for development.
Store the dtime of the first call (first restart) and wait for the next restart.
Try to spend a given ratio of time in the inprocessing.
LP Propagation during inprocessing can be really slow, so we temporarily disable it.
We make sure we do not "pollute" the current saved polarities. We will restore them at the end.
Probing.
Definition at line 172 of file sat_inprocessing.cc.
bool operations_research::sat::Inprocessing::LevelZeroPropagate | ( | ) |
Simple wrapper that makes sure all the clauses are attached before a propagation is performed.
Definition at line 306 of file sat_inprocessing.cc.
bool operations_research::sat::Inprocessing::MoreFixedVariableToClean | ( | ) | const |
Returns true if there is new fixed variables or new equivalence relations since RemoveFixedAndEquivalentVariables() was last called.
Definition at line 295 of file sat_inprocessing.cc.
bool operations_research::sat::Inprocessing::MoreRedundantVariableToClean | ( | ) | const |
Definition at line 300 of file sat_inprocessing.cc.
bool operations_research::sat::Inprocessing::PresolveLoop | ( | SatPresolveOptions | options | ) |
Does some simplifications until a fix point is reached or the given deterministic time is passed.
Mainly useful for development.
We currently do the transformations in a given order and restart each time we did something to make sure that the earlier step cannot strengthen more. This might not be the best, but it is really good during development phase to make sure each individual functions is as incremental and as fast as possible.
This one is fast since only newly fixed variables are considered.
This also prepare the stamping below so that we do that on a DAG and do not consider potential new implications added by RemoveFixedAndEquivalentVariables().
IMPORTANT: Since we only run this on pure sat problem, we can just get rid of equivalent variable right away and do not need to keep them in the implication_graph_ for propagation.
This is needed for the correctness of the bounded variable elimination.
We wait for the fix-point to be reached before doing the other simplifications below.
Probing.
Definition at line 67 of file sat_inprocessing.cc.
|
inline |
A bit hacky. Only needed during refactoring.
Definition at line 150 of file sat_inprocessing.h.
bool operations_research::sat::Inprocessing::RemoveFixedAndEquivalentVariables | ( | bool | log_info | ) |
Removes fixed variables and exploit equivalence relations to cleanup the clauses. Returns false if UNSAT.
Preconditions.
Test if some work is needed.
Start the round.
We need this temporary vector for the DRAT proof settings, otherwise we could just have done an in-place transformation.
Used to mark clause literals.
We first do a loop to see if there is anything to do.
Rewrite the clause.
Restore marked.
Definition at line 336 of file sat_inprocessing.cc.
bool operations_research::sat::Inprocessing::SubsumeAndStrenghtenRound | ( | bool | log_info | ) |
Processes all clauses and see if there is any subsumption/strenghtening reductions that can be performed. Returns false if UNSAT.
We need this temporary vector for the DRAT proof settings, otherwise we could just have done an in-place transformation.
This function needs the watcher to be detached as we might remove some of the watched literals.
Process clause by increasing sizes.
Used to mark clause literals.
Clause index in clauses.
Clause signatures in the same order as clauses.
Check for subsumption, note that this currently ignore all clauses in the binary implication graphs. Stamping is doing some of that (and some also happen during probing), but we could consider only direct implications here and be a bit more exhaustive than what stamping do with them (at least for node with many incoming and outgoing implications).
Compute hash and mark literals.
Look for clause that subsumes this one. Note that because we inspect all one watcher lists for the literals of this clause, if a clause is included inside this one, it must appear in one of these lists.
For strengthenning we also need to check the negative watcher lists.
Any literal here can be removed, but afterwards the other might not. For now we just remove the first one.
Recompute signature.
Register one literal to watch. Any literal works, but we choose the smallest list.
Important: we can only use this clause to subsume/strenghten others if it cannot be deleted later.
We might have fixed variables, finish the propagation.
Definition at line 445 of file sat_inprocessing.cc.