Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <bop_ls.h>
Public Member Functions | |
AssignmentAndConstraintFeasibilityMaintainer (const sat::LinearBooleanProblem &problem, absl::BitGenRef random) | |
AssignmentAndConstraintFeasibilityMaintainer (const AssignmentAndConstraintFeasibilityMaintainer &)=delete | |
This type is neither copyable nor movable. | |
AssignmentAndConstraintFeasibilityMaintainer & | operator= (const AssignmentAndConstraintFeasibilityMaintainer &)=delete |
void | SetReferenceSolution (const BopSolution &reference_solution) |
void | UseCurrentStateAsReference () |
void | Assign (absl::Span< const sat::Literal > literals) |
void | AddBacktrackingLevel () |
void | BacktrackOneLevel () |
void | BacktrackAll () |
const std::vector< sat::Literal > & | PotentialOneFlipRepairs () |
bool | IsFeasible () const |
Returns true if there is no infeasible constraint in the current state. | |
int | NumInfeasibleConstraints () const |
const std::vector< ConstraintIndex > & | PossiblyInfeasibleConstraints () const |
Returns a superset of all the infeasible constraints in the current state. | |
size_t | NumConstraints () const |
bool | Assignment (VariableIndex var) const |
const BopSolution & | reference () const |
Returns the current assignment. | |
int64_t | ConstraintLowerBound (ConstraintIndex constraint) const |
Returns the lower bound of the constraint. | |
int64_t | ConstraintUpperBound (ConstraintIndex constraint) const |
Returns the upper bound of the constraint. | |
int64_t | ConstraintValue (ConstraintIndex constraint) const |
bool | ConstraintIsFeasible (ConstraintIndex constraint) const |
Returns true if the given constraint is currently feasible. | |
std::string | DebugString () const |
Static Public Attributes | |
static const ConstraintIndex | kObjectiveConstraint |
This class is used to incrementally maintain an assignment and the feasibility of the constraints of a given LinearBooleanProblem.
The current assignment is initialized using a feasible reference solution, i.e. the reference solution satisfies all the constraints of the problem. The current assignment is updated using the Assign() method.
The assignment can be accessed at any time using Assignment(). The set of infeasible constraints can be accessed at any time using PossiblyInfeasibleConstraints().
|
explicit |
|
delete |
This type is neither copyable nor movable.
void operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::AddBacktrackingLevel | ( | ) |
Adds a new backtracking level to specify the state that will be restored by BacktrackOneLevel(). See the example in the class comment.
void operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::Assign | ( | absl::Span< const sat::Literal > | literals | ) |
Assigns all literals. That updates the assignment, the constraint values, and the infeasible constraints.
|
inline |
void operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::BacktrackAll | ( | ) |
void operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::BacktrackOneLevel | ( | ) |
Backtracks internal structures to the previous level defined by AddBacktrackingLevel(). As a consequence the state will be exactly as before the previous call to AddBacktrackingLevel().
Backtrack each literal of the last level.
|
inline |
|
inline |
|
inline |
|
inline |
std::string operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::DebugString | ( | ) | const |
|
inline |
|
inline |
|
inline |
Returns the exact number of infeasible constraints.
|
delete |
|
inline |
const std::vector< sat::Literal > & operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::PotentialOneFlipRepairs | ( | ) |
This returns the list of literal that appear in exactly all the current infeasible constraints (ignoring the objective) and correspond to a flip in a good direction for all the infeasible constraint. Performing this flip may repair the problem without any propagations.
Important: The returned reference is only valid until the next PotentialOneFlipRepairs() call.
First, we compute the hash that a Literal should have in order to repair all the infeasible constraint (ignoring the objective).
We only returns the flips.
|
inline |
void operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::SetReferenceSolution | ( | const BopSolution & | reference_solution | ) |
void operations_research::bop::AssignmentAndConstraintFeasibilityMaintainer::UseCurrentStateAsReference | ( | ) |
Behaves exactly like SetReferenceSolution() where the passed reference is the current assignment held by this class. Note that the current assignment must be feasible (i.e. IsFeasible() is true).
|
static |