public abstract class

AbstractKnapsackPropagator

extends Object
implements KnapsackPropagator
java.lang.Object
   ↳ org.apache.helix.controller.strategy.knapsack.AbstractKnapsackPropagator
Known Direct Subclasses

Class Overview

Common implementation of a knapsack constraint satisfier

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

Summary

Public Constructors
AbstractKnapsackPropagator(KnapsackState state)
Initialize the propagator
Public Methods
void copyCurrentStateToSolution(boolean hasOnePropagator, ArrayList<Boolean> solution)
Copy the current computed state to the final solution
long currentProfit()
Get the current profit of the search
void init(ArrayList<Long> profits, ArrayList<Long> weights)
Initialize the propagator
long profitLowerBound()
Get the lowest possible profit of the search
long profitUpperBound()
Get the highest possible profit of the search
boolean update(boolean revert, KnapsackAssignment assignment)
Update the search
Protected Methods
abstract void copyCurrentStateToSolutionPropagator(ArrayList<Boolean> solution)
abstract void initPropagator()
ArrayList<KnapsackItem> items()
void setProfitLowerBound(long profit)
void setProfitUpperBound(long profit)
KnapsackState state()
abstract boolean updatePropagator(boolean revert, KnapsackAssignment assignment)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.helix.controller.strategy.knapsack.KnapsackPropagator

Public Constructors

public AbstractKnapsackPropagator (KnapsackState state)

Initialize the propagator

Parameters
state the current knapsack state

Public Methods

public 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 long currentProfit ()

Get the current profit of the search

Returns
  • current profit

public 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 long profitLowerBound ()

Get the lowest possible profit of the search

Returns
  • profit lower bound

public long profitUpperBound ()

Get the highest possible profit of the search

Returns
  • profit upper bound

public 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

Protected Methods

protected abstract void copyCurrentStateToSolutionPropagator (ArrayList<Boolean> solution)

protected abstract void initPropagator ()

protected ArrayList<KnapsackItem> items ()

protected void setProfitLowerBound (long profit)

protected void setProfitUpperBound (long profit)

protected KnapsackState state ()

protected abstract boolean updatePropagator (boolean revert, KnapsackAssignment assignment)