public class

KnapsackItem

extends Object
java.lang.Object
   ↳ org.apache.helix.controller.strategy.knapsack.KnapsackItem

Class Overview

Basic structure of an item in a knapsack

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

Summary

Fields
public final int id
public final long profit
public final long weight
Public Constructors
KnapsackItem(int id, long weight, long profit)
Initialize the item
Public Methods
double getEfficiency(long profitMax)
Get the profit to weight ratio
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public final int id

public final long profit

public final long weight

Public Constructors

public KnapsackItem (int id, long weight, long profit)

Initialize the item

Parameters
id the item id
weight the cost to place the item in the knapsack for one dimension
profit the benefit of placing the item in the knapsack

Public Methods

public double getEfficiency (long profitMax)

Get the profit to weight ratio

Parameters
profitMax the maximum possible profit for this item
Returns
  • the item addition effciency