Class BaseLns
- java.lang.Object
-
- com.google.ortools.constraintsolver.BaseObject
-
- com.google.ortools.constraintsolver.LocalSearchOperator
-
- com.google.ortools.constraintsolver.IntVarLocalSearchOperator
-
- com.google.ortools.constraintsolver.BaseLns
-
public class BaseLns extends IntVarLocalSearchOperator
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_;
};
-
-
Field Summary
-
Fields inherited from class com.google.ortools.constraintsolver.BaseObject
swigCMemOwn
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendToFragment(int index)voiddelete()protected voidfinalize()intfragmentSize()protected static longgetCPtr(BaseLns obj)booleanHasFragments()voidinitFragments()booleannextFragment()protected voidswigDirectorDisconnect()protected static longswigRelease(BaseLns obj)voidswigReleaseOwnership()voidswigTakeOwnership()-
Methods inherited from class com.google.ortools.constraintsolver.IntVarLocalSearchOperator
activate, activated, addVars, ApplyChanges, deactivate, getCPtr, HoldsDelta, isIncremental, oldValue, oneNeighbor, onStart, PrevValue, RevertChanges, setValue, size, SkipUnchanged, start, swigRelease, value, var
-
Methods inherited from class com.google.ortools.constraintsolver.LocalSearchOperator
getCPtr, nextNeighbor, reset, swigRelease
-
Methods inherited from class com.google.ortools.constraintsolver.BaseObject
getCPtr, swigRelease, toString
-
-
-
-
Constructor Detail
-
BaseLns
protected BaseLns(long cPtr, boolean cMemoryOwn)
-
BaseLns
public BaseLns(IntVar[] vars)
-
-
Method Detail
-
getCPtr
protected static long getCPtr(BaseLns obj)
-
swigRelease
protected static long swigRelease(BaseLns obj)
-
finalize
protected void finalize()
- Overrides:
finalizein classIntVarLocalSearchOperator
-
delete
public void delete()
- Overrides:
deletein classIntVarLocalSearchOperator
-
swigDirectorDisconnect
protected void swigDirectorDisconnect()
- Overrides:
swigDirectorDisconnectin classIntVarLocalSearchOperator
-
swigReleaseOwnership
public void swigReleaseOwnership()
- Overrides:
swigReleaseOwnershipin classIntVarLocalSearchOperator
-
swigTakeOwnership
public void swigTakeOwnership()
- Overrides:
swigTakeOwnershipin classIntVarLocalSearchOperator
-
initFragments
public void initFragments()
-
nextFragment
public boolean nextFragment()
-
appendToFragment
public void appendToFragment(int index)
-
fragmentSize
public int fragmentSize()
-
HasFragments
public boolean HasFragments()
- Overrides:
HasFragmentsin classLocalSearchOperator
-
-