Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::IntVarLocalSearchOperator Class Reference

#include <constraint_solveri.h>

Inheritance diagram for operations_research::IntVarLocalSearchOperator:
operations_research::LocalSearchOperator operations_research::BaseObject operations_research::BaseLns operations_research::ChangeValue operations_research::FilteredHeuristicLocalSearchOperator operations_research::PathOperator operations_research::SwapIndexPairOperator operations_research::FilteredHeuristicCloseNodesLNSOperator operations_research::FilteredHeuristicExpensiveChainLNSOperator operations_research::FilteredHeuristicPathLNSOperator operations_research::RelocatePathAndHeuristicInsertUnperformedOperator operations_research::BaseInactiveNodeToPathOperator operations_research::Cross operations_research::Exchange operations_research::ExchangeSubtrip operations_research::GroupPairAndRelocateOperator operations_research::IndexPairSwapActiveOperator operations_research::LightPairRelocateOperator operations_research::LinKernighan operations_research::MakeChainInactiveOperator operations_research::MakeInactiveOperator operations_research::MakePairActiveOperator operations_research::MakePairInactiveOperator operations_research::MakeRelocateNeighborsOperator operations_research::PairExchangeOperator operations_research::PairExchangeRelocateOperator operations_research::PairNodeSwapActiveOperator< swap_first > operations_research::PairRelocateOperator operations_research::PathLns operations_research::Relocate operations_research::RelocateAndMakeInactiveOperator operations_research::RelocateExpensiveChain operations_research::RelocateSubtrip operations_research::SwapActiveToShortestPathOperator operations_research::TSPLns operations_research::TSPOpt operations_research::TwoOpt

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
 
IntVarVar (int64_t index) const
 Returns the variable of given index.
 
virtual bool SkipUnchanged (int index) 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
 --— Base operator class for operators manipulating IntVars --—
 
- Public Member Functions inherited from operations_research::LocalSearchOperator
 LocalSearchOperator ()
 
 ~LocalSearchOperator () override
 
virtual void Reset ()
 
virtual const LocalSearchOperatorSelf () const
 
virtual bool HasFragments () const
 
- Public Member Functions inherited from operations_research::BaseObject
 BaseObject ()
 
 BaseObject (const BaseObject &)=delete
 This type is neither copyable nor movable.
 
BaseObjectoperator= (const BaseObject &)=delete
 
virtual ~BaseObject ()
 
virtual std::string DebugString () const
 

Protected Member Functions

virtual bool MakeOneNeighbor ()
 
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
 

Detailed Description

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 1063 of file constraint_solveri.h.

Constructor & Destructor Documentation

◆ IntVarLocalSearchOperator()

operations_research::IntVarLocalSearchOperator::IntVarLocalSearchOperator ( const std::vector< IntVar * > & vars,
bool keep_inverse_values = false )
inlineexplicit

If keep_inverse_values is true, assumes that vars models an injective function f with domain [0, vars.size()) in which case the operator will maintain the inverse function.

Definition at line 1068 of file constraint_solveri.h.

◆ ~IntVarLocalSearchOperator()

operations_research::IntVarLocalSearchOperator::~IntVarLocalSearchOperator ( )
inlineoverride

Definition at line 1079 of file constraint_solveri.h.

Member Function Documentation

◆ Activate()

void operations_research::IntVarLocalSearchOperator::Activate ( int64_t index)
inline

Definition at line 1126 of file constraint_solveri.h.

◆ Activated()

bool operations_research::IntVarLocalSearchOperator::Activated ( int64_t index) const
inline

Definition at line 1123 of file constraint_solveri.h.

◆ AddToAssignment()

void operations_research::IntVarLocalSearchOperator::AddToAssignment ( IntVar * var,
int64_t value,
bool active,
std::vector< int > * assignment_indices,
int64_t index,
Assignment * assignment ) const
inlineprotected

Definition at line 1203 of file constraint_solveri.h.

◆ AddVars()

void operations_research::IntVarLocalSearchOperator::AddVars ( const std::vector< IntVar * > & vars)
inline

Definition at line 1164 of file constraint_solveri.h.

◆ ApplyChanges()

bool operations_research::IntVarLocalSearchOperator::ApplyChanges ( Assignment * delta,
Assignment * deltadelta ) const
inline

Definition at line 1129 of file constraint_solveri.h.

◆ Deactivate()

void operations_research::IntVarLocalSearchOperator::Deactivate ( int64_t index)
inline

Definition at line 1127 of file constraint_solveri.h.

◆ HoldsDelta()

bool operations_research::IntVarLocalSearchOperator::HoldsDelta ( ) const
inlineoverridevirtual

Reimplemented from operations_research::LocalSearchOperator.

Definition at line 1081 of file constraint_solveri.h.

◆ InverseValue()

int64_t operations_research::IntVarLocalSearchOperator::InverseValue ( int64_t index) const
inlineprotected

Definition at line 1196 of file constraint_solveri.h.

◆ IsIncremental()

virtual bool operations_research::IntVarLocalSearchOperator::IsIncremental ( ) const
inlinevirtual

Reimplemented in operations_research::TwoOpt.

Definition at line 1104 of file constraint_solveri.h.

◆ MakeNextNeighbor()

bool operations_research::IntVarLocalSearchOperator::MakeNextNeighbor ( Assignment * delta,
Assignment * deltadelta )
overridevirtual

--— Base operator class for operators manipulating IntVars --—

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 >, and operations_research::SwapIndexPairOperator.

Definition at line 83 of file local_search.cc.

◆ MakeOneNeighbor()

bool operations_research::IntVarLocalSearchOperator::MakeOneNeighbor ( )
protectedvirtual

Creates a new neighbor. It returns false when the neighborhood is completely explored.

Todo
(user): make it pure virtual, implies porting all apps overriding MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
Todo
(user): Make this a pure virtual.

Reimplemented in operations_research::BaseInactiveNodeToPathOperator, operations_research::BaseLns, operations_research::ChangeValue, operations_research::MakePairActiveOperator, operations_research::PathOperator, operations_research::RelocateExpensiveChain, and operations_research::TSPLns.

Definition at line 104 of file local_search.cc.

◆ OldInverseValue()

int64_t operations_research::IntVarLocalSearchOperator::OldInverseValue ( int64_t index) const
inlineprotected

Definition at line 1199 of file constraint_solveri.h.

◆ OldValue()

int64_t operations_research::IntVarLocalSearchOperator::OldValue ( int64_t index) const
inline

Definition at line 1116 of file constraint_solveri.h.

◆ OnStart()

virtual void operations_research::IntVarLocalSearchOperator::OnStart ( )
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 1176 of file constraint_solveri.h.

◆ PrevValue()

int64_t operations_research::IntVarLocalSearchOperator::PrevValue ( int64_t index) const
inline

Definition at line 1117 of file constraint_solveri.h.

◆ RevertChanges()

void operations_research::IntVarLocalSearchOperator::RevertChanges ( bool change_was_incremental)
inline

Definition at line 1153 of file constraint_solveri.h.

◆ SetValue()

void operations_research::IntVarLocalSearchOperator::SetValue ( int64_t index,
int64_t value )
inline

Definition at line 1120 of file constraint_solveri.h.

◆ Size()

int operations_research::IntVarLocalSearchOperator::Size ( ) const
inline

Definition at line 1106 of file constraint_solveri.h.

◆ SkipUnchanged()

virtual bool operations_research::IntVarLocalSearchOperator::SkipUnchanged ( int index) const
inlinevirtual

Reimplemented in operations_research::PathOperator.

Definition at line 1115 of file constraint_solveri.h.

◆ Start()

void operations_research::IntVarLocalSearchOperator::Start ( const Assignment * assignment)
inlineoverridevirtual

This method should not be overridden. Override OnStart() instead which is called before exiting this method.

Implements operations_research::LocalSearchOperator.

Definition at line 1084 of file constraint_solveri.h.

◆ Value()

int64_t operations_research::IntVarLocalSearchOperator::Value ( int64_t index) const
inline

Returns the value in the current assignment of the variable of given index.

Definition at line 1109 of file constraint_solveri.h.

◆ Var()

IntVar * operations_research::IntVarLocalSearchOperator::Var ( int64_t index) const
inline

Returns the variable of given index.

Definition at line 1114 of file constraint_solveri.h.


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