C++ Reference: class BaseLns

This documentation is automatically generated.

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_; };
Method
AppendToFragment

Return type: void

Arguments: int index

BaseLns

Return type: explicit

Arguments: const std::vector<IntVar*>& vars

~BaseLns

FragmentSize

Return type: int

HasFragments

Return type: bool

InitFragments

Return type: virtual void

NextFragment

Return type: virtual bool