![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
Specialization of LocalSearchOperator built from an array of IntVars which specifies the scope of the operator. This class also takes care of storing current variable values in Start(), keeps track of changes done by the operator and builds the delta. The Deactivate() method can be used to perform Large Neighborhood Search.
Definition at line 1122 of file constraint_solveri.h.
#include <constraint_solveri.h>
Public Member Functions | |
| IntVarLocalSearchOperator (const std::vector< IntVar * > &vars, bool keep_inverse_values=false) | |
| ~IntVarLocalSearchOperator () override | |
| bool | HoldsDelta () const override |
| void | Start (const Assignment *assignment) override |
| virtual bool | IsIncremental () const |
| int | Size () const |
| int64_t | Value (int64_t index) const |
| IntVar * | Var (int64_t index) const |
| Returns the variable of given index. | |
| virtual bool | SkipUnchanged (int) const |
| int64_t | OldValue (int64_t index) const |
| int64_t | PrevValue (int64_t index) const |
| void | SetValue (int64_t index, 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 change_was_incremental) |
| void | AddVars (const std::vector< IntVar * > &vars) |
| virtual void | OnStart () |
| bool | MakeNextNeighbor (Assignment *delta, Assignment *deltadelta) override |
| Public Member Functions inherited from operations_research::LocalSearchOperator | |
| LocalSearchOperator () | |
| ~LocalSearchOperator () override | |
| virtual void | EnterSearch () |
| virtual void | Reset () |
| virtual const LocalSearchOperator * | Self () const |
| virtual bool | HasFragments () const |
| Public Member Functions inherited from operations_research::BaseObject | |
| BaseObject () | |
| BaseObject (const BaseObject &)=delete | |
| BaseObject & | operator= (const BaseObject &)=delete |
| virtual | ~BaseObject ()=default |
| virtual std::string | DebugString () const |
Protected Member Functions | |
| virtual bool | MakeOneNeighbor () |
| MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator. | |
| int64_t | InverseValue (int64_t index) const |
| int64_t | OldInverseValue (int64_t index) const |
| void | AddToAssignment (IntVar *var, int64_t value, bool active, std::vector< int > *assignment_indices, int64_t index, Assignment *assignment) const |
|
inlineexplicit |
Definition at line 1127 of file constraint_solveri.h.
|
inlineoverride |
Definition at line 1138 of file constraint_solveri.h.
|
inline |
Definition at line 1185 of file constraint_solveri.h.
|
inline |
Definition at line 1182 of file constraint_solveri.h.
|
inlineprotected |
Definition at line 1262 of file constraint_solveri.h.
|
inline |
Definition at line 1223 of file constraint_solveri.h.
|
inline |
Definition at line 1188 of file constraint_solveri.h.
|
inline |
Definition at line 1186 of file constraint_solveri.h.
|
inlineoverridevirtual |
Reimplemented from operations_research::LocalSearchOperator.
Definition at line 1140 of file constraint_solveri.h.
|
inlineprotected |
Definition at line 1255 of file constraint_solveri.h.
|
inlinevirtual |
Reimplemented in operations_research::SwapActiveChainOperator< ignore_path_vars >, and operations_research::TwoOpt< ignore_path_vars >.
Definition at line 1163 of file constraint_solveri.h.
|
overridevirtual |
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). 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 operations_research::LocalSearchOperator.
Reimplemented in operations_research::PairNodeSwapActiveOperator< swap_first, ignore_path_vars >, and operations_research::SwapIndexPairOperator.
Definition at line 80 of file local_search.cc.
|
protectedvirtual |
MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
Creates a new neighbor. It returns false when the neighborhood is completely explored.
Reimplemented in operations_research::BaseInactiveNodeToPathOperator< ignore_path_vars >, operations_research::BaseLns, operations_research::ChangeValue, operations_research::MakePairActiveOperator< ignore_path_vars >, operations_research::PathOperator< ignore_path_vars >, operations_research::RelocateExpensiveChain< ignore_path_vars >, and operations_research::TSPLns< ignore_path_vars >.
Definition at line 102 of file local_search.cc.
|
inlineprotected |
Definition at line 1258 of file constraint_solveri.h.
|
inline |
Definition at line 1175 of file constraint_solveri.h.
|
inlinevirtual |
Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling IntVarLocalSearchOperator::Start explicitly.
Reimplemented in operations_research::SwapIndexPairOperator.
Definition at line 1235 of file constraint_solveri.h.
|
inline |
Definition at line 1176 of file constraint_solveri.h.
|
inline |
Definition at line 1212 of file constraint_solveri.h.
|
inline |
Definition at line 1179 of file constraint_solveri.h.
|
inline |
Definition at line 1165 of file constraint_solveri.h.
|
inlinevirtual |
Reimplemented in operations_research::PathOperator< ignore_path_vars >.
Definition at line 1174 of file constraint_solveri.h.
|
inlineoverridevirtual |
This method should not be overridden. Override OnStart() instead which is called before exiting this method.
Implements operations_research::LocalSearchOperator.
Definition at line 1143 of file constraint_solveri.h.
|
inline |
Returns the value in the current assignment of the variable of given index.
Definition at line 1168 of file constraint_solveri.h.
|
inline |
Returns the variable of given index.
Definition at line 1173 of file constraint_solveri.h.