public class

KnapsackGenericSolverImpl

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

Class Overview

A generic knapsack solver that supports multiple dimensions

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

Summary

Public Constructors
KnapsackGenericSolverImpl(String solverName)
Create the solver
Public Methods
boolean bestSolution(int itemId)
long[] getLowerAndUpperBoundWhenItem(int itemId, boolean isItemIn, long lowerBound, long upperBound)
Compute an upper and lower bound on the knapsack given the assignment state of the knapsack
int getNumberOfItems()
void init(ArrayList<Long> profits, ArrayList<ArrayList<Long>> weights, ArrayList<Long> capacities)
void setMasterPropagatorId(int masterPropagatorId)
long solve()
[Expand]
Inherited Methods
From class org.apache.helix.controller.strategy.knapsack.AbstractBaseKnapsackSolver
From class java.lang.Object
From interface org.apache.helix.controller.strategy.knapsack.BaseKnapsackSolver

Public Constructors

public KnapsackGenericSolverImpl (String solverName)

Create the solver

Parameters
solverName name of the solver

Public Methods

public boolean bestSolution (int itemId)

public long[] getLowerAndUpperBoundWhenItem (int itemId, boolean isItemIn, long lowerBound, long upperBound)

Compute an upper and lower bound on the knapsack given the assignment state of the knapsack

Parameters
itemId the item id
isItemIn true if the item is in the knapsack, false otherwise
lowerBound the current lower bound
upperBound the current upper bound
Returns
  • the new lower and upper bounds

public int getNumberOfItems ()

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

public void setMasterPropagatorId (int masterPropagatorId)

public long solve ()