![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
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 4349 of file pywrapcp.py.
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 | |
| __init__ (self, vars, keep_inverse_values=False) | |
| 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) | |
| __disown__ (self) | |
| Public Member Functions inherited from ortools.constraint_solver.pywrapcp.LocalSearchOperator | |
| __init__ (self, *args, **kwargs) | |
| __disown__ (self) | |
| Public Member Functions inherited from ortools.constraint_solver.pywrapcp.BaseObject | |
| __init__ (self) | |
| DebugString (self) | |
| __str__ (self) | |
| __repr__ (self) | |
| __disown__ (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") | |
| ortools.constraint_solver.pywrapcp.BaseLns.__init__ | ( | self, | |
| vars ) |
Definition at line 4383 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.__disown__ | ( | self | ) |
Definition at line 4408 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.__getitem__ | ( | self, | |
| index ) |
Definition at line 4403 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.__len__ | ( | self | ) |
Definition at line 4406 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.AppendToFragment | ( | self, | |
| index ) |
Definition at line 4397 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.FragmentSize | ( | self | ) |
Definition at line 4400 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.InitFragments | ( | self | ) |
Definition at line 4391 of file pywrapcp.py.
| ortools.constraint_solver.pywrapcp.BaseLns.NextFragment | ( | self | ) |
Definition at line 4394 of file pywrapcp.py.
|
static |
Definition at line 4380 of file pywrapcp.py.