Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.constraint_solver.pywrapcp.BaseLns Class Reference
Inheritance diagram for ortools.constraint_solver.pywrapcp.BaseLns:
ortools.constraint_solver.pywrapcp.IntVarLocalSearchOperator ortools.constraint_solver.pywrapcp.LocalSearchOperator ortools.constraint_solver.pywrapcp.BaseObject

Public Member Functions

 __init__ (self, vars)
 
 InitFragments (self)
 
 NextFragment (self)
 
 AppendToFragment (self, index)
 
 FragmentSize (self)
 
 __getitem__ (self, index)
 
 __len__ (self)
 
 __disown__ (self)
 
- Public Member Functions inherited from ortools.constraint_solver.pywrapcp.IntVarLocalSearchOperator
 Start (self, assignment)
 
 IsIncremental (self)
 
 Size (self)
 
 Value (self, index)
 
 Var (self, index)
 
 OldValue (self, index)
 
 PrevValue (self, index)
 
 SetValue (self, index, value)
 
 Activated (self, index)
 
 Activate (self, index)
 
 Deactivate (self, index)
 
 AddVars (self, vars)
 
 OnStart (self)
 
 NextNeighbor (self, delta, deltadelta)
 
 OneNeighbor (self)
 
- Public Member Functions inherited from ortools.constraint_solver.pywrapcp.LocalSearchOperator
- Public Member Functions inherited from ortools.constraint_solver.pywrapcp.BaseObject
 DebugString (self)
 
 __str__ (self)
 
 __repr__ (self)
 

Properties

 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 
- Properties inherited from ortools.constraint_solver.pywrapcp.IntVarLocalSearchOperator
 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 
- Properties inherited from ortools.constraint_solver.pywrapcp.LocalSearchOperator
 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 
- Properties inherited from ortools.constraint_solver.pywrapcp.BaseObject
 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 

Detailed Description

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 4091 of file pywrapcp.py.

Constructor & Destructor Documentation

◆ __init__()

ortools.constraint_solver.pywrapcp.BaseLns.__init__ ( self,
vars )

Reimplemented from ortools.constraint_solver.pywrapcp.IntVarLocalSearchOperator.

Definition at line 4125 of file pywrapcp.py.

Member Function Documentation

◆ __disown__()

ortools.constraint_solver.pywrapcp.BaseLns.__disown__ ( self)

Reimplemented from ortools.constraint_solver.pywrapcp.IntVarLocalSearchOperator.

Definition at line 4150 of file pywrapcp.py.

◆ __getitem__()

ortools.constraint_solver.pywrapcp.BaseLns.__getitem__ ( self,
index )

Definition at line 4145 of file pywrapcp.py.

◆ __len__()

ortools.constraint_solver.pywrapcp.BaseLns.__len__ ( self)

Definition at line 4148 of file pywrapcp.py.

◆ AppendToFragment()

ortools.constraint_solver.pywrapcp.BaseLns.AppendToFragment ( self,
index )

Definition at line 4139 of file pywrapcp.py.

◆ FragmentSize()

ortools.constraint_solver.pywrapcp.BaseLns.FragmentSize ( self)

Definition at line 4142 of file pywrapcp.py.

◆ InitFragments()

ortools.constraint_solver.pywrapcp.BaseLns.InitFragments ( self)

Definition at line 4133 of file pywrapcp.py.

◆ NextFragment()

ortools.constraint_solver.pywrapcp.BaseLns.NextFragment ( self)

Definition at line 4136 of file pywrapcp.py.

Property Documentation

◆ thisown

ortools.constraint_solver.pywrapcp.BaseLns.thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
static

Definition at line 4122 of file pywrapcp.py.


The documentation for this class was generated from the following file: