![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
KnapsackSearchPath is a small class used to represent the path between a node to another node in the search tree.
As the solution state is not stored for each search node, the state should be rebuilt at each node. One simple solution is to apply all decisions between the node 'to' and the root. This can be computed in O(number_of_items). However, it is possible to achieve better average complexity. Two consecutively explored nodes are usually close enough (i.e., much less than number_of_items) to benefit from an incremental update from the node 'from' to the node 'to'. The 'via' field is the common parent of 'from' field and 'to' field. So the state can be built by reverting all decisions from 'from' to 'via' and then applying all decisions from 'via' to 'to'.
Definition at line 379 of file knapsack_solver.h.
#include <knapsack_solver.h>
Public Member Functions | |
| KnapsackSearchPath (const KnapsackSearchNode &from, const KnapsackSearchNode &to) | |
| KnapsackSearchPath (const KnapsackSearchPath &)=delete | |
| KnapsackSearchPath & | operator= (const KnapsackSearchPath &)=delete |
| void | Init () |
| const KnapsackSearchNode & | from () const |
| const KnapsackSearchNode & | via () const |
| const KnapsackSearchNode & | to () const |
| const KnapsackSearchNode * | MoveUpToDepth (const KnapsackSearchNode &node, int depth) const |
| operations_research::KnapsackSearchPath::KnapsackSearchPath | ( | const KnapsackSearchNode & | from, |
| const KnapsackSearchNode & | to ) |
Definition at line 121 of file knapsack_solver.cc.
|
delete |
|
inline |
Definition at line 391 of file knapsack_solver.h.
| void operations_research::KnapsackSearchPath::Init | ( | ) |
Definition at line 125 of file knapsack_solver.cc.
| const KnapsackSearchNode * operations_research::KnapsackSearchPath::MoveUpToDepth | ( | const KnapsackSearchNode & | node, |
| int | depth ) const |
Definition at line 138 of file knapsack_solver.cc.
|
delete |
|
inline |
Definition at line 393 of file knapsack_solver.h.
|
inline |
Definition at line 392 of file knapsack_solver.h.