Opus5
Class ZeroOneKnapsackProblem

java.lang.Object
  |
  +--Opus5.ZeroOneKnapsackProblem

public class ZeroOneKnapsackProblem
extends java.lang.Object

Represents a 0/1 knapsack problem.

Version:
$Id: ZeroOneKnapsackProblem.java,v 3.2 1998/07/28 20:03:35 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Inner Class Summary
protected  class ZeroOneKnapsackProblem.Node
           
 
Field Summary
protected  int capacity
          The capacity of the knapsack.
protected  int numberOfItems
          The total number of items from which to choose.
protected  int[] profit
          The profits associated with taking each of the items.
protected  int[] weight
          The weights of each of the items.
 
Constructor Summary
ZeroOneKnapsackProblem(int[] weight, int[] profit, int capacity)
          Constructs a ZeroOneKnapsackProblem with the specified weights, profits and capacity.
 
Method Summary
 Solution solve(Solver solver)
          Solves this 0/1 knapsack problem using the specified solver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numberOfItems

protected int numberOfItems
The total number of items from which to choose.

weight

protected int[] weight
The weights of each of the items.

profit

protected int[] profit
The profits associated with taking each of the items.

capacity

protected int capacity
The capacity of the knapsack.
Constructor Detail

ZeroOneKnapsackProblem

public ZeroOneKnapsackProblem(int[] weight,
                              int[] profit,
                              int capacity)
Constructs a ZeroOneKnapsackProblem with the specified weights, profits and capacity.
Parameters:
weight - The weights of the items to be considered.
weight - The profits of the items to be considered.
capacity - The total capacity of the knapsack.
Method Detail

solve

public Solution solve(Solver solver)
Solves this 0/1 knapsack problem using the specified solver.
Parameters:
solver - The solver to use.
Returns:
The solution to this problem.