Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <sat_base.h>
Public Member Functions | |
Literal (int signed_value) | |
Literal ()=default | |
Literal (LiteralIndex index) | |
Literal (BooleanVariable variable, bool is_positive) | |
operator LiteralIndex () const | |
BooleanVariable | Variable () const |
bool | IsPositive () const |
bool | IsNegative () const |
LiteralIndex | Index () const |
LiteralIndex | NegatedIndex () const |
int | SignedValue () const |
Literal | Negated () const |
std::string | DebugString () const |
bool | operator== (Literal other) const |
bool | operator!= (Literal other) const |
bool | operator< (const Literal &other) const |
Friends | |
template<typename H > | |
H | AbslHashValue (H h, Literal literal) |
A literal is used to represent a variable or its negation. If it represents the variable it is said to be positive. If it represent its negation, it is said to be negative. We support two representations as an integer.
The "signed" encoding of a literal is convenient for input/output and is used in the cnf file format. For a 0-based variable index x, (x + 1) represent the variable x and -(x + 1) represent its negation. The signed value 0 is an undefined literal and this class can never contain it.
The "index" encoding of a literal is convenient as an index to an array and is the one used internally for efficiency. It is always positive or zero, and for a 0-based variable index x, (x << 1) encode the variable x and the same number XOR 1 encode its negation.
Definition at line 66 of file sat_base.h.
|
inlineexplicit |
Definition at line 68 of file sat_base.h.
|
default |
|
inlineexplicit |
Definition at line 75 of file sat_base.h.
|
inline |
Definition at line 76 of file sat_base.h.
|
inline |
Definition at line 100 of file sat_base.h.
|
inline |
Definition at line 91 of file sat_base.h.
|
inline |
Definition at line 89 of file sat_base.h.
|
inline |
Definition at line 88 of file sat_base.h.
|
inline |
Definition at line 98 of file sat_base.h.
|
inline |
Definition at line 92 of file sat_base.h.
|
inline |
We want a literal to be implicitly converted to a LiteralIndex(). Before this, we used to have many literal.Index() that didn't add anything.
Definition at line 85 of file sat_base.h.
|
inline |
Definition at line 105 of file sat_base.h.
|
inline |
Definition at line 106 of file sat_base.h.
|
inline |
Definition at line 104 of file sat_base.h.
|
inline |
Definition at line 94 of file sat_base.h.
|
inline |
Definition at line 87 of file sat_base.h.
|
friend |
Definition at line 109 of file sat_base.h.