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

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

#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< ignore_path_vars > operations_research::SwapIndexPairOperator operations_research::FilteredHeuristicCloseNodesLNSOperator operations_research::FilteredHeuristicExpensiveChainLNSOperator operations_research::FilteredHeuristicPathLNSOperator operations_research::RelocatePathAndHeuristicInsertUnperformedOperator operations_research::RelocateVisitTypeOperator operations_research::BaseInactiveNodeToPathOperator< ignore_path_vars > operations_research::Cross< ignore_path_vars > operations_research::Exchange< ignore_path_vars > operations_research::ExchangeSubtrip< ignore_path_vars > operations_research::GroupPairAndRelocateOperator< ignore_path_vars > operations_research::IndexPairSwapActiveOperator< ignore_path_vars > operations_research::LightPairRelocateOperator< ignore_path_vars > operations_research::LinKernighan< ignore_path_vars > operations_research::MakeChainInactiveOperator< ignore_path_vars > operations_research::MakeInactiveOperator< ignore_path_vars > operations_research::MakePairActiveOperator< ignore_path_vars > operations_research::MakePairInactiveOperator< ignore_path_vars > operations_research::MakeRelocateNeighborsOperator< ignore_path_vars > operations_research::PairExchangeOperator< ignore_path_vars > operations_research::PairExchangeRelocateOperator< ignore_path_vars > operations_research::PairNodeSwapActiveOperator< swap_first, ignore_path_vars > operations_research::PairRelocateOperator< ignore_path_vars > operations_research::PathLns< ignore_path_vars > operations_research::Relocate< ignore_path_vars > operations_research::RelocateAndMakeInactiveOperator< ignore_path_vars > operations_research::RelocateExpensiveChain< ignore_path_vars > operations_research::RelocateSubtrip< ignore_path_vars > operations_research::SwapActiveToShortestPathOperator< ignore_path_vars > operations_research::TSPLns< ignore_path_vars > operations_research::TSPOpt< ignore_path_vars > operations_research::TwoOpt< ignore_path_vars > operations_research::TwoOptWithShortestPathOperator< ignore_path_vars >

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) 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 LocalSearchOperatorSelf () const
virtual bool HasFragments () const
Public Member Functions inherited from operations_research::BaseObject
 BaseObject ()
 BaseObject (const BaseObject &)=delete
BaseObjectoperator= (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

Constructor & Destructor Documentation

◆ IntVarLocalSearchOperator()

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

Definition at line 1127 of file constraint_solveri.h.

◆ ~IntVarLocalSearchOperator()

operations_research::IntVarLocalSearchOperator::~IntVarLocalSearchOperator ( )
inlineoverride

Definition at line 1138 of file constraint_solveri.h.

Member Function Documentation

◆ Activate()

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

Definition at line 1185 of file constraint_solveri.h.

◆ Activated()

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

Definition at line 1182 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 1262 of file constraint_solveri.h.

◆ AddVars()

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

Definition at line 1223 of file constraint_solveri.h.

◆ ApplyChanges()

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

Definition at line 1188 of file constraint_solveri.h.

◆ Deactivate()

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

Definition at line 1186 of file constraint_solveri.h.

◆ HoldsDelta()

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

Reimplemented from operations_research::LocalSearchOperator.

Definition at line 1140 of file constraint_solveri.h.

◆ InverseValue()

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

Definition at line 1255 of file constraint_solveri.h.

◆ IsIncremental()

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

◆ MakeNextNeighbor()

bool operations_research::IntVarLocalSearchOperator::MakeNextNeighbor ( Assignment * delta,
Assignment * deltadelta )
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.

◆ MakeOneNeighbor()

◆ OldInverseValue()

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

Definition at line 1258 of file constraint_solveri.h.

◆ OldValue()

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

Definition at line 1175 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 1235 of file constraint_solveri.h.

◆ PrevValue()

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

Definition at line 1176 of file constraint_solveri.h.

◆ RevertChanges()

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

Definition at line 1212 of file constraint_solveri.h.

◆ SetValue()

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

Definition at line 1179 of file constraint_solveri.h.

◆ Size()

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

Definition at line 1165 of file constraint_solveri.h.

◆ SkipUnchanged()

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

◆ 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 1143 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 1168 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 1173 of file constraint_solveri.h.


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