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.
Method | |
---|---|
ComputeProfitBounds | Return type: ComputeProfitBounds should set 'profit_lower_bound_' and 'profit_upper_bound_' which are constraint specific. |
CopyCurrentStateToSolution | Return type: Arguments: 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. |
current_profit | Return type: |
GetNextItemId | Return type: Returns the id of next item to assign. Returns kNoSelection when all items are bound. |
Init | Return type: Arguments: Initializes data structure and then calls InitPropagator. |
KnapsackPropagator | Return type: Arguments: |
~KnapsackPropagator | Return type: |
profit_lower_bound | Return type: |
profit_upper_bound | Return type: |
Update | Return type: Arguments: Updates data structure and then calls UpdatePropagator. Returns false when failure. |