public interface

KnapsackPropagator

org.apache.helix.controller.strategy.knapsack.KnapsackPropagator
Known Indirect Subclasses

Class Overview

Constraint enforcer for a single dimenstion on a knapsack solution search

Based on the C++ knapsack solver in Google's or-tools package.

Summary

Public Methods
abstract void computeProfitBounds()
Compute the upper and lower bounds of potential profits
abstract void copyCurrentStateToSolution(boolean hasOnePropagator, ArrayList<Boolean> solution)
Copy the current computed state to the final solution
abstract long currentProfit()
Get the current profit of the search
abstract int getNextItemId()
Get the next item to use in the search
abstract void init(ArrayList<Long> profits, ArrayList<Long> weights)
Initialize the propagator
abstract long profitLowerBound()
Get the lowest possible profit of the search
abstract long profitUpperBound()
Get the highest possible profit of the search
abstract boolean update(boolean revert, KnapsackAssignment assignment)
Update the search

Public Methods

public abstract void computeProfitBounds ()

Compute the upper and lower bounds of potential profits

public abstract void copyCurrentStateToSolution (boolean hasOnePropagator, ArrayList<Boolean> solution)

Copy the current computed state to the final solution

Parameters
hasOnePropagator true if there is only one propagator, i.e. 1 dimension
solution the solution vector

public abstract long currentProfit ()

Get the current profit of the search

Returns
  • current profit

public abstract int getNextItemId ()

Get the next item to use in the search

Returns
  • item id

public abstract void init (ArrayList<Long> profits, ArrayList<Long> weights)

Initialize the propagator

Parameters
profits profits for selecting each item
weights weights of each item for this dimension

public abstract long profitLowerBound ()

Get the lowest possible profit of the search

Returns
  • profit lower bound

public abstract long profitUpperBound ()

Get the highest possible profit of the search

Returns
  • profit upper bound

public abstract boolean update (boolean revert, KnapsackAssignment assignment)

Update the search

Parameters
revert revert the assignment
assignment the assignment to use for the update
Returns
  • true if successful, false if failed