public final class KnapsackItem extends Object implements Comparable<KnapsackItem>
Modifier and Type | Field and Description |
---|---|
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 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 and Description |
---|
KnapsackItem(IntVar quantity,
int weight,
int profit)
It constructs an item.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
toString() |
public IntVar quantity
public int weight
public int profit
public double efficiency
public static String[] xmlAttributes
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.public int compareTo(KnapsackItem that)
compareTo
in interface Comparable<KnapsackItem>
public final IntVar getVariable()
public final int getProfit()
public final int getWeight()
public final double getEfficiency()
Copyright © 2015. All rights reserved.