|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectJaCoP.constraints.knapsack.KnapsackItem
public final class KnapsackItem
This class stores information about items being considered by a Knapsack constraint. It is a holder for integer attributes like weight and profit, as well as finite domain variable denoting the quantity being taken. It also stores precomputed efficiency of the item. It implements comparable interface in such a away so that items can be sorted in decreasing efficiency. In case of equal efficiency then item which is heavier is preferred.
| Field Summary | |
|---|---|
double |
efficiency
It stores information about the item efficiency - profit/weight. |
int |
profit
It specifies the profit of a single instance of this item. |
IntVar |
quantity
It is a finite domain variable specifying the possible quantity of that item. |
int |
weight
It specifies the weight of a single instance of this item. |
static java.lang.String[] |
xmlAttributes
It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format. |
| Constructor Summary | |
|---|---|
KnapsackItem(IntVar quantity,
int weight,
int profit)
It constructs an item. |
|
| Method Summary | |
|---|---|
int |
compareTo(KnapsackItem that)
Method used in the sorting of the items, we use profit and weight to know the less efficient item without using division. |
double |
getEfficiency()
It returns an efficiency of that item. |
int |
getProfit()
It returns a profit of a single instance of that item. |
IntVar |
getVariable()
t returns quantity variable associated with that item. |
int |
getWeight()
It returns a weight of a single instance of that item. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public IntVar quantity
public int weight
public int profit
public double efficiency
public static java.lang.String[] xmlAttributes
| Constructor Detail |
|---|
public KnapsackItem(IntVar quantity,
int weight,
int profit)
quantity - - number of items it is possible to take.weight - - weight of the single item.profit - - profit due to one single item.| Method Detail |
|---|
public int compareTo(KnapsackItem that)
compareTo in interface java.lang.Comparable<KnapsackItem>public final IntVar getVariable()
public final int getProfit()
public final int getWeight()
public final double getEfficiency()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||