Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <constraint_solveri.h>
Public Member Functions | |
BaseLns (const std::vector< IntVar * > &vars) | |
--— Base Large Neighborhood Search operator --— | |
~BaseLns () override | |
virtual void | InitFragments () |
virtual bool | NextFragment ()=0 |
void | AppendToFragment (int index) |
int | FragmentSize () const |
bool | HasFragments () const override |
Public Member Functions inherited from operations_research::IntVarLocalSearchOperator | |
IntVarLocalSearchOperator (const std::vector< IntVar * > &vars, bool keep_inverse_values=false) | |
~IntVarLocalSearchOperator () override | |
bool | HoldsDelta () const override |
void | Start (const Assignment *assignment) override |
virtual bool | IsIncremental () const |
int | Size () const |
int64_t | Value (int64_t index) const |
IntVar * | Var (int64_t index) const |
Returns the variable of given index. | |
virtual bool | SkipUnchanged (int index) const |
int64_t | OldValue (int64_t index) const |
int64_t | PrevValue (int64_t index) const |
void | SetValue (int64_t index, int64_t value) |
bool | Activated (int64_t index) const |
void | Activate (int64_t index) |
void | Deactivate (int64_t index) |
bool | ApplyChanges (Assignment *delta, Assignment *deltadelta) const |
void | RevertChanges (bool change_was_incremental) |
void | AddVars (const std::vector< IntVar * > &vars) |
bool | MakeNextNeighbor (Assignment *delta, Assignment *deltadelta) override |
--— Base operator class for operators manipulating IntVars --— | |
Public Member Functions inherited from operations_research::LocalSearchOperator | |
LocalSearchOperator () | |
~LocalSearchOperator () override | |
virtual void | Reset () |
virtual const LocalSearchOperator * | Self () const |
Public Member Functions inherited from operations_research::BaseObject | |
BaseObject () | |
BaseObject (const BaseObject &)=delete | |
This type is neither copyable nor movable. | |
BaseObject & | operator= (const BaseObject &)=delete |
virtual | ~BaseObject () |
virtual std::string | DebugString () const |
Protected Member Functions | |
bool | MakeOneNeighbor () override |
This method should not be overridden. Override NextFragment() instead. | |
Protected Member Functions inherited from operations_research::IntVarLocalSearchOperator | |
int64_t | InverseValue (int64_t index) const |
int64_t | OldInverseValue (int64_t index) const |
void | AddToAssignment (IntVar *var, int64_t value, bool active, std::vector< int > *assignment_indices, int64_t index, Assignment *assignment) const |
This is the base class for building an Lns operator. An Lns fragment is a collection of variables which will be relaxed. Fragments are built with NextFragment(), which returns false if there are no more fragments to build. Optionally one can override InitFragments, which is called from LocalSearchOperator::Start to initialize fragment data. Here's a sample relaxing one variable at a time: class OneVarLns : public BaseLns { public: OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {} virtual ~OneVarLns() {} virtual void InitFragments() { index_ = 0; } virtual bool NextFragment() { const int size = Size(); if (index_ < size) { AppendToFragment(index_); ++index_; return true; } else { return false; } } private: int index_; };
Definition at line 1265 of file constraint_solveri.h.
|
explicit |
--— Base Large Neighborhood Search operator --—
Definition at line 108 of file local_search.cc.
|
override |
Definition at line 111 of file local_search.cc.
void operations_research::BaseLns::AppendToFragment | ( | int | index | ) |
Definition at line 128 of file local_search.cc.
int operations_research::BaseLns::FragmentSize | ( | ) | const |
Definition at line 134 of file local_search.cc.
|
inlineoverridevirtual |
Reimplemented from operations_research::LocalSearchOperator.
Definition at line 1273 of file constraint_solveri.h.
|
virtual |
Definition at line 126 of file local_search.cc.
|
overrideprotectedvirtual |
This method should not be overridden. Override NextFragment() instead.
Reimplemented from operations_research::IntVarLocalSearchOperator.
Definition at line 113 of file local_search.cc.
|
pure virtual |