public interface

KnapsackState

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

Class Overview

The current state of the knapsack

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

Summary

Public Methods
abstract int getNumberOfItems()
Get the current number of items in the knapsack
abstract void init(int numberOfItems)
Initialize the knapsack with the number of items
abstract boolean isBound(int id)
Check if an item is currently bound to the knapsack
abstract boolean isIn(int id)
Check if an item is currently in the knapsack
abstract boolean updateState(boolean revert, KnapsackAssignment assignment)
Update this state with an assignment

Public Methods

public abstract int getNumberOfItems ()

Get the current number of items in the knapsack

Returns
  • number of items

public abstract void init (int numberOfItems)

Initialize the knapsack with the number of items

Parameters
numberOfItems the number of items

public abstract boolean isBound (int id)

Check if an item is currently bound to the knapsack

Parameters
id the item id
Returns
  • true if bound, false otherwise

public abstract boolean isIn (int id)

Check if an item is currently in the knapsack

Parameters
id the item id
Returns
  • true if inside, false otherwise

public abstract boolean updateState (boolean revert, KnapsackAssignment assignment)

Update this state with an assignment

Parameters
revert true to revert to the previous state, false otherwise
assignment the assignment that was made
Returns
  • true on success, false on failure