![]() |
OR-Tools
9.3
|
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 1260 of file constraint_solveri.h.
Public Member Functions | |
| BaseLns (const std::vector< IntVar * > &vars) | |
| ~BaseLns () override | |
| virtual void | InitFragments () |
| virtual bool | NextFragment ()=0 |
| void | AppendToFragment (int index) |
| int | FragmentSize () const |
| bool | HasFragments () const override |
| bool | MakeNextNeighbor (Assignment *delta, Assignment *deltadelta) override |
| Redefines MakeNextNeighbor to export a simpler interface. More... | |
| bool | HoldsDelta () const override |
| void | Start (const Assignment *assignment) override |
| This method should not be overridden. More... | |
| virtual bool | IsIncremental () const |
| int | Size () const |
| const int64_t & | Value (int64_t index) const |
| Returns the value in the current assignment of the variable of given index. More... | |
| IntVar * | Var (int64_t index) const |
| Returns the variable of given index. More... | |
| virtual bool | SkipUnchanged (int index) const |
| const int64_t & | OldValue (int64_t index) const |
| void | SetValue (int64_t index, const 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 incremental) |
| void | AddVars (const std::vector< IntVar * > &vars) |
| virtual void | Reset () |
| virtual const LocalSearchOperator * | Self () const |
| virtual std::string | DebugString () const |
Protected Member Functions | |
| bool | MakeOneNeighbor () override |
| This method should not be overridden. Override NextFragment() instead. More... | |
| bool | IsInverseValue (int64_t index) const |
| int64_t | InverseValue (int64_t index) const |
| int64_t | OldInverseValue (int64_t index) const |
| void | SetInverseValue (int64_t index, int64_t value) |
| void | SetOldInverseValue (int64_t index, int64_t value) |
| void | MarkChange (int64_t index) |
| OnStart() should really be protected, but then SWIG doesn't see it. More... | |
Protected Attributes | |
| std::vector< IntVar * > | vars_ |
| std::vector< int64_t > | values_ |
| std::vector< int64_t > | old_values_ |
| std::vector< int64_t > | prev_values_ |
| std::vector< int > | assignment_indices_ |
| Bitset64 | activated_ |
| Bitset64 | was_activated_ |
| SparseBitset | changes_ |
| SparseBitset | delta_changes_ |
| bool | cleared_ |
| IntVarLocalSearchHandler | var_handler_ |
Definition at line 101 of file local_search.cc.
|
override |
Definition at line 104 of file local_search.cc.
|
inlineinherited |
Definition at line 850 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 849 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 895 of file constraint_solveri.h.
| void AppendToFragment | ( | int | index | ) |
Definition at line 121 of file local_search.cc.
|
inlineinherited |
Definition at line 858 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 854 of file constraint_solveri.h.
|
inlinevirtualinherited |
Reimplemented in Trace, LocalSearchMonitorMaster, PropagationBaseObject, Decision, DecisionBuilder, ProfiledDecisionBuilder, Demon, Constraint, IntVarIterator, SolutionCollector, OptimizeVar, SearchLimit, RegularLimit, SequenceVar, Assignment, Pack, CallMethod0< T >, CallMethod1< T, P >, CallMethod2< T, P, Q >, CallMethod3< T, P, Q, R >, DelayedCallMethod0< T >, DelayedCallMethod1< T, P >, DelayedCallMethod2< T, P, Q >, LocalSearchFilterManager, PropagationMonitor, LocalSearchMonitor, BooleanVar, SearchLog, ArrayWithOffset< T >, DemonProfiler, IfThenElseCt, PiecewiseLinearExpr, TwoOpt, Relocate, Exchange, Cross, MakeActiveOperator, RelocateAndMakeActiveOperator, MakeActiveAndRelocate, MakeInactiveOperator, RelocateAndMakeInactiveOperator, MakeChainInactiveOperator, SwapActiveOperator, ExtendedSwapActiveOperator, TSPOpt, TSPLns, LinKernighan, PathLns, NeighborhoodLimit, LocalSearchProfiler, FindOneNeighbor, LocalSearchPhaseParameters, Dimension, GlobalVehicleBreaksConstraint, MakeRelocateNeighborsOperator, MakePairActiveOperator, MakePairInactiveOperator, PairRelocateOperator, LightPairRelocateOperator, PairExchangeOperator, PairExchangeRelocateOperator, SwapIndexPairOperator, IndexPairSwapActiveOperator, FilteredHeuristicPathLNSOperator, RelocatePathAndHeuristicInsertUnperformedOperator, FilteredHeuristicExpensiveChainLNSOperator, FilteredHeuristicCloseNodesLNSOperator, RelocateExpensiveChain, PairNodeSwapActiveOperator< swap_first >, RelocateSubtrip, ExchangeSubtrip, IntVarFilteredDecisionBuilder, and SymmetryManager.
Definition at line 3173 of file constraint_solver.h.
| int FragmentSize | ( | ) | const |
Definition at line 127 of file local_search.cc.
|
inlineoverridevirtual |
Reimplemented from LocalSearchOperator.
Definition at line 1268 of file constraint_solveri.h.
|
inlineoverridevirtualinherited |
Reimplemented from LocalSearchOperator.
Definition at line 817 of file constraint_solveri.h.
|
virtual |
Definition at line 119 of file local_search.cc.
|
inlineprotectedinherited |
Definition at line 1066 of file constraint_solveri.h.
|
inlinevirtualinherited |
Reimplemented in TwoOpt.
Definition at line 833 of file constraint_solveri.h.
|
inlineprotectedinherited |
Definition at line 1061 of file constraint_solveri.h.
|
overridevirtualinherited |
Redefines MakeNextNeighbor to export a simpler interface.
The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.
Implements LocalSearchOperator.
Reimplemented in SwapIndexPairOperator, IndexPairSwapActiveOperator, and PairNodeSwapActiveOperator< swap_first >.
Definition at line 76 of file local_search.cc.
|
overrideprotectedvirtual |
This method should not be overridden. Override NextFragment() instead.
Reimplemented from IntVarLocalSearchOperator.
Definition at line 106 of file local_search.cc.
|
inlineprotectedinherited |
OnStart() should really be protected, but then SWIG doesn't see it.
So we make it public, but only subclasses should access to it (to override it).
Definition at line 919 of file constraint_solveri.h.
|
pure virtual |
|
inlineprotectedinherited |
Definition at line 1068 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 844 of file constraint_solveri.h.
|
inlinevirtualinherited |
Reimplemented in PathOperator.
Definition at line 798 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 882 of file constraint_solveri.h.
|
inlinevirtualinherited |
Definition at line 800 of file constraint_solveri.h.
|
inlineprotectedinherited |
Definition at line 1072 of file constraint_solveri.h.
|
inlineprotectedinherited |
Definition at line 1076 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 845 of file constraint_solveri.h.
|
inlineinherited |
Definition at line 834 of file constraint_solveri.h.
|
inlinevirtualinherited |
Reimplemented in PathOperator.
Definition at line 843 of file constraint_solveri.h.
|
inlineoverridevirtualinherited |
This method should not be overridden.
Override OnStart() instead which is called before exiting this method.
Implements LocalSearchOperator.
Definition at line 820 of file constraint_solveri.h.
|
inlineinherited |
Returns the value in the current assignment of the variable of given index.
Definition at line 837 of file constraint_solveri.h.
|
inlineinherited |
Returns the variable of given index.
Definition at line 842 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 929 of file constraint_solveri.h.
|
mutableprotectedinherited |
Definition at line 928 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 931 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 933 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 932 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 926 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 927 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 925 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 934 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 924 of file constraint_solveri.h.
|
protectedinherited |
Definition at line 930 of file constraint_solveri.h.