Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class KnapsackPropagator
Note: This documentation is automatically generated.
----- KnapsackPropagator -----
KnapsackPropagator is the base class for modeling and propagating a
constraint given an assignment.
When some work has to be done both by the base and the derived class,
a protected pure virtual method ending by 'Propagator' is defined.
For instance, 'Init' creates a vector of items, and then calls
'InitPropagator' to let the derived class perform its own initialization.
Copies the current state into 'solution'.
All unbound items are set to false (i.e. not in the knapsack).
When 'has_one_propagator' is true, CopyCurrentSolutionPropagator is called
to have a better solution. When there is only one propagator
there is no need to check the solution with other propagators, so the
partial solution can be smartly completed.
[[["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."],[[["KnapsackPropagator is a base class for modeling and propagating knapsack constraints within the OR-Tools library."],["It provides methods for initialization, updating the problem state, and computing profit bounds."],["Derived classes extend its functionality by implementing specific propagation logic."],["The class manages the assignment of items to the knapsack and aims to find optimal solutions."],["It utilizes virtual and protected methods for flexible extension and customization."]]],["`KnapsackPropagator` is a base class for modeling constraints, involving actions like initialization (`Init`), and updates (`Update`). It manages profit bounds via `ComputeProfitBounds`. `GetNextItemId` determines the next item for assignment. `CopyCurrentStateToSolution` transfers the current state to a solution vector, potentially using `CopyCurrentSolutionPropagator` for optimization. It defines virtual methods like `InitPropagator` and `UpdatePropagator` allowing derived classes to perform custom initialization and updates.\n"]]