Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <symmetry.h>
Public Member Functions | |
SymmetryPropagator () | |
SymmetryPropagator (const SymmetryPropagator &)=delete | |
This type is neither copyable nor movable. | |
SymmetryPropagator & | operator= (const SymmetryPropagator &)=delete |
~SymmetryPropagator () override | |
bool | Propagate (Trail *trail) final |
void | Untrail (const Trail &trail, int trail_index) final |
absl::Span< const Literal > | Reason (const Trail &trail, int trail_index, int64_t conflict_id) const final |
void | AddSymmetry (std::unique_ptr< SparsePermutation > permutation) |
int | num_permutations () const |
void | Permute (int index, absl::Span< const Literal > input, std::vector< Literal > *output) const |
Public Member Functions inherited from operations_research::sat::SatPropagator | |
SatPropagator (const std::string &name) | |
SatPropagator (const SatPropagator &)=delete | |
This type is neither copyable nor movable. | |
SatPropagator & | operator= (const SatPropagator &)=delete |
virtual | ~SatPropagator ()=default |
void | SetPropagatorId (int id) |
Sets/Gets this propagator unique id. | |
int | PropagatorId () const |
bool | PropagatePreconditionsAreSatisfied (const Trail &trail) const |
######################## Implementations below ######################## | |
bool | PropagationIsDone (const Trail &trail) const |
Returns true iff all the trail was inspected by this propagator. | |
virtual bool | IsEmpty () const |
Additional Inherited Members | |
Protected Attributes inherited from operations_research::sat::SatPropagator | |
const std::string | name_ |
int | propagator_id_ |
int | propagation_trail_index_ |
This class implements more or less the strategy described in the paper: Devriendt J., Bogaerts B., De Cat B., Denecker M., Mears C. "Symmetry propagation: Improved Dynamic Symmetry Breaking in SAT", 2012, IEEE 24th International Conference on Tools with Artificial Intelligence.
Basically, each time a literal is propagated, this class tries to detect if another literal could also be propagated by symmetry. Note that this uses a heuristic in order to be efficient and that it is not exhaustive in the sense that it doesn't detect all possible propagations.
Algorithm details:
Given the current solver trail (i.e. the assigned literals and their assignment order) the idea is to compute (as efficiently as possible) for each permutation added to this class what is called the first (under the trail assignment order) non-symmetric literal. A literal 'l' is said to be non-symmetric under a given assignment and for a given permutation 'p' if 'l' is assigned to true but not 'p(l)'.
If a first non-symmetric literal 'l' for a permutation 'p' is not a decision, then:
(user): Implement the optimizations mentioned in the paper?
(user): Instrument and see if the code can be optimized.
Definition at line 60 of file symmetry.h.
operations_research::sat::SymmetryPropagator::SymmetryPropagator | ( | ) |
Definition at line 31 of file symmetry.cc.
|
delete |
This type is neither copyable nor movable.
|
override |
Definition at line 37 of file symmetry.cc.
void operations_research::sat::SymmetryPropagator::AddSymmetry | ( | std::unique_ptr< SparsePermutation > | permutation | ) |
Adds a new permutation to this symmetry propagator. The ownership is transferred. This must be an integer permutation such that:
Remark: Any permutation which is a symmetry of the main SAT problem can be added here. However, since the number of permutations is usually not manageable, a good alternative is to only add the generators of the permutation group. It is also important to add permutations with a support as small as possible.
Definition at line 45 of file symmetry.cc.
|
inline |
Definition at line 92 of file symmetry.h.
|
delete |
void operations_research::sat::SymmetryPropagator::Permute | ( | int | index, |
absl::Span< const Literal > | input, | ||
std::vector< Literal > * | output ) const |
Visible for testing.
Permutes a list of literals from input into output using the permutation with given index. This uses tmp_literal_mapping_ and has a complexity in O(permutation_support + input_size).
Initialize tmp_literal_mapping_ (resize it if needed).
Permute the input into the output.
Clean up.
Definition at line 201 of file symmetry.cc.
|
finalvirtual |
Inspects the trail from propagation_trail_index_ until at least one literal is propagated. Returns false iff a conflict is detected (in which case trail->SetFailingClause() must be called).
This must update propagation_trail_index_ so that all the literals before it have been propagated. In particular, if nothing was propagated, then PropagationIsDone() must return true.
Implements operations_research::sat::SatPropagator.
Definition at line 135 of file symmetry.cc.
|
finalvirtual |
Explains why the literal at given trail_index was propagated by returning a reason for this propagation. This will only be called for literals that are on the trail and were propagated by this class.
The interpretation is that because all the literals of a reason were assigned to false, we could deduce the assignment of the given variable.
The returned Span has to be valid until the literal is untrailed. A client can use trail_.GetEmptyVectorToStoreReason() if it doesn't have a memory location that already contains the reason.
If conlict id is positive, then this is called during first UIP resolution and we will backtrack over this literal right away, so we don't need to have a span that survive more than once.
Reimplemented from operations_research::sat::SatPropagator.
Definition at line 156 of file symmetry.cc.
|
finalvirtual |
Reverts the state so that all the literals with a trail index greater or equal to the given one are not processed for propagation. Note that the trail current decision level is already reverted before this is called.
Reimplemented from operations_research::sat::SatPropagator.
Definition at line 143 of file symmetry.cc.