Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Generic filter-based heuristic applied to IntVars. More...
#include <routing_search.h>
Public Member Functions | |
IntVarFilteredHeuristic (Solver *solver, const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, LocalSearchFilterManager *filter_manager) | |
— First solution heuristics — | |
virtual | ~IntVarFilteredHeuristic () |
Assignment * | BuildSolution () |
int64_t | number_of_decisions () const |
int64_t | number_of_rejects () const |
virtual std::string | DebugString () const |
Protected Member Functions | |
void | ResetSolution () |
Resets the data members for a new solution. | |
virtual void | Initialize () |
Initialize the heuristic; called before starting to build a new solution. | |
virtual bool | InitializeSolution () |
Virtual method to initialize the solution. | |
virtual bool | BuildSolutionInternal ()=0 |
Virtual method to redefine how to build a solution. | |
std::optional< int64_t > | Evaluate (bool commit) |
virtual bool | StopSearch () |
Returns true if the search must be stopped. | |
void | SetValue (int64_t index, int64_t value) |
const std::vector< int > & | delta_indices () const |
Returns the indices of the nodes currently in the insertion delta. | |
int64_t | Value (int64_t index) const |
bool | Contains (int64_t index) const |
Returns true if the variable of index 'index' is in the current solution. | |
IntVar * | Var (int64_t index) const |
Returns the variable of index 'index'. | |
int64_t | SecondaryVarIndex (int64_t index) const |
Returns the index of a secondary var. | |
bool | HasSecondaryVars () const |
Returns true if there are secondary variables. | |
bool | IsSecondaryVar (int64_t index) const |
Returns true if 'index' is a secondary variable index. | |
void | SynchronizeFilters () |
Synchronizes filters with an assignment (the current solution). | |
Protected Attributes | |
Assignment *const | assignment_ |
Generic filter-based heuristic applied to IntVars.
Definition at line 174 of file routing_search.h.
operations_research::IntVarFilteredHeuristic::IntVarFilteredHeuristic | ( | Solver * | solver, |
const std::vector< IntVar * > & | vars, | ||
const std::vector< IntVar * > & | secondary_vars, | ||
LocalSearchFilterManager * | filter_manager ) |
— First solution heuristics —
Definition at line 273 of file routing_search.cc.
|
inlinevirtual |
Definition at line 180 of file routing_search.h.
Assignment * operations_research::IntVarFilteredHeuristic::BuildSolution | ( | ) |
Builds a solution. Returns the resulting assignment if a solution was found, and nullptr otherwise.
Initialize must be called before the state of the heuristic is changed, in particular before InitializeSolution() and BuildSolutionInternal().
Definition at line 305 of file routing_search.cc.
|
protectedpure virtual |
Virtual method to redefine how to build a solution.
Implemented in operations_research::CheapestAdditionFilteredHeuristic, operations_research::ChristofidesFilteredHeuristic, operations_research::GlobalCheapestInsertionFilteredHeuristic, operations_research::LocalCheapestInsertionFilteredHeuristic, and operations_research::SavingsFilteredHeuristic.
|
inlineprotected |
Returns true if the variable of index 'index' is in the current solution.
Definition at line 232 of file routing_search.h.
|
inlinevirtual |
Reimplemented in operations_research::ChristofidesFilteredHeuristic, operations_research::ComparatorCheapestAdditionFilteredHeuristic, operations_research::EvaluatorCheapestAdditionFilteredHeuristic, operations_research::GlobalCheapestInsertionFilteredHeuristic, operations_research::LocalCheapestInsertionFilteredHeuristic, operations_research::ParallelSavingsFilteredHeuristic, and operations_research::SequentialSavingsFilteredHeuristic.
Definition at line 191 of file routing_search.h.
|
inlineprotected |
Returns the indices of the nodes currently in the insertion delta.
Definition at line 225 of file routing_search.h.
|
protected |
Evaluates the modifications to the current solution. If these modifications are "filter-feasible" returns their corresponding cost computed by filters. If 'commit' is true, the modifications are committed to the current solution. In any case all modifications to the internal delta are cleared before returning.
objective upper_bound_ is used to reduce the number of potential insertion candidates, specifically when filter_manager_ filters cost. Rationale: the best cost candidate will always be valid and will be inserted so no use accepting degrading ones. However when a candidate is committed, the upper bound is relaxed to make sure further (cost-degrading) insertions will be accepted (cf. SynchronizeFilters()).
Reset is_in_delta to all false.
Definition at line 350 of file routing_search.cc.
|
inlineprotected |
Returns true if there are secondary variables.
Definition at line 243 of file routing_search.h.
|
inlineprotectedvirtual |
Initialize the heuristic; called before starting to build a new solution.
Reimplemented in operations_research::LocalCheapestInsertionFilteredHeuristic.
Definition at line 197 of file routing_search.h.
|
inlineprotectedvirtual |
Virtual method to initialize the solution.
Definition at line 199 of file routing_search.h.
|
inlineprotected |
Returns true if 'index' is a secondary variable index.
Definition at line 245 of file routing_search.h.
|
inline |
Returns statistics on search, number of decisions sent to filters, number of decisions rejected by filters.
Definition at line 188 of file routing_search.h.
|
inline |
Definition at line 189 of file routing_search.h.
|
protected |
Resets the data members for a new solution.
Wiping assignment when starting a new search.
Definition at line 295 of file routing_search.cc.
|
inlineprotected |
Returns the index of a secondary var.
Definition at line 238 of file routing_search.h.
|
inlineprotected |
Modifies the current solution by setting the variable of index 'index' to value 'value'.
Definition at line 214 of file routing_search.h.
|
inlineprotectedvirtual |
Returns true if the search must be stopped.
Reimplemented in operations_research::RoutingFilteredHeuristic.
Definition at line 211 of file routing_search.h.
|
protected |
Synchronizes filters with an assignment (the current solution).
Resetting the upper bound to allow cost-increasing insertions.
Definition at line 393 of file routing_search.cc.
|
inlineprotected |
Returns the value of the variable of index 'index' in the last committed solution.
Definition at line 228 of file routing_search.h.
|
inlineprotected |
Returns the variable of index 'index'.
Definition at line 236 of file routing_search.h.
|
protected |
Definition at line 249 of file routing_search.h.