Returns the base offset in memory for f(s, node), with node contained in s.
This is useful in the Dynamic Programming iterations.
Note(user): inlining this function gains about 5%.
TODO(user): Investigate how to compute BaseOffset(card - 1, s \ { n })
from BaseOffset(card, n) to speed up the DP iteration.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eLatticeMemoryManager\u003c/code\u003e is a C++ class designed for efficient memory management in dynamic programming algorithms, particularly for Hamiltonian path problems.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for calculating memory offsets, storing and retrieving values associated with sets and nodes, crucial for the Held-Karp algorithm.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003eOffset\u003c/code\u003e, \u003ccode\u003eBaseOffset\u003c/code\u003e, and \u003ccode\u003eOffsetDelta\u003c/code\u003e are optimized for quick access to data during DP iterations, improving performance.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSetValue\u003c/code\u003e and \u003ccode\u003eValue\u003c/code\u003e offer general access, while \u003ccode\u003eSetValueAtOffset\u003c/code\u003e and \u003ccode\u003eValueAtOffset\u003c/code\u003e are optimized for use within dynamic programming loops.\u003c/p\u003e\n"],["\u003cp\u003eThe class requires initialization via \u003ccode\u003eInit\u003c/code\u003e to allocate and prepare the memory structure before use.\u003c/p\u003e\n"]]],["The `LatticeMemoryManager` class manages memory for storing values related to sets and nodes. Key actions include: initializing memory with `Init`, retrieving memory offsets with `Offset` and `BaseOffset`, and calculating offset changes using `OffsetDelta`. Values are stored and retrieved using `SetValue`, `SetValueAtOffset`, `Value`, and `ValueAtOffset`. These methods handle the dynamic programming iterations and other memory access, providing the ability to store and recall calculated results at given memory offsets.\n"],null,["# LatticeMemoryManager\n\nC++ Reference: class LatticeMemoryManager\n=========================================\n\n\nNote: This documentation is automatically generated.\n\n| Method ||\n|--------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`BaseOffset`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L307) | Return type: `inline uint64_t ` Arguments: `int card, Set s` Returns the base offset in memory for f(s, node), with node contained in s. This is useful in the Dynamic Programming iterations. Note(user): inlining this function gains about 5%. TODO(user): Investigate how to compute BaseOffset(card - 1, s \\\\ { n }) from BaseOffset(card, n) to speed up the DP iteration. |\n| [`Init`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L297) | Return type: `void ` Arguments: `int max_card` Reserves memory and fills in the data necessary to access memory. |\n| [`LatticeMemoryManager`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L294) | \u003cbr /\u003e |\n| [`Offset`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L300) | Return type: `uint64_t ` Arguments: `Set s, int node` Returns the offset in memory for f(s, node), with node contained in s. |\n| [`OffsetDelta`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L311) | Return type: `uint64_t ` Arguments: `int card, int added_node, int removed_node, int rank` Returns the offset delta for a set of cardinality 'card', to which node 'removed_node' is replaced by 'added_node' at 'rank' |\n| [`SetValue`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L320) | Return type: `void ` Arguments: `Set s, int node, CostType value` Memorizes the value = f(s, node) at the correct offset. This is favored in all other uses than the Dynamic Programming iterations. |\n| [`SetValueAtOffset`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L324) | Return type: `void ` Arguments: `uint64_t offset, CostType value` Memorizes 'value' at 'offset'. This is useful in the Dynamic Programming iterations where we want to avoid compute the offset of a pair (set, node). |\n| [`Value`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L330) | Return type: `CostType ` Arguments: `Set s, int node` Returns the memorized value f(s, node) with node in s. This is favored in all other uses than the Dynamic Programming iterations. |\n| [`ValueAtOffset`](https://github.com/google/or-tools/blob/v9.4/ortools/graph/hamiltonian_path.h#L334) | Return type: `CostType ` Arguments: `uint64_t offset` Returns the memorized value at 'offset'. This is useful in the Dynamic Programming iterations. |"]]