|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsavi.alg.knapsack.Items
public class Items
Class representing knapsack problem instance.
Field Summary | |
---|---|
protected int |
count
number of items in this knapsack instance |
protected int |
idx
internal iterator for addItem method |
protected double[][] |
items
array with items; one item is pair of integers (int[2]) - weight and cost |
Constructor Summary | |
---|---|
Items(double[][] it)
Creates a new instance of Items, set items |
|
Items(int count)
Creates a new instance of Items, creates empty array |
Method Summary | |
---|---|
protected void |
addItem(double w,
double c)
Insert new item into the instance |
int |
getCount()
Get current items count in knapsack instance |
double |
getItemCost(int item)
Return cost of desired item. |
double |
getItemWeight(int item)
Return weight of desired item. |
void |
randomItems(double wmax,
double cmax)
Randomly cretes items. |
void |
setItems(double[][] it)
Set prepared items |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int count
protected int idx
protected double[][] items
Constructor Detail |
---|
public Items(int count)
count
- maximum itemspublic Items(double[][] it)
it
- initialized itemsMethod Detail |
---|
public void setItems(double[][] it)
it
- itemsprotected void addItem(double w, double c)
w
- item weightc
- item costpublic int getCount()
public void randomItems(double wmax, double cmax)
wmax
- maximum item weightcmax
- maximum item costpublic double getItemWeight(int item)
item
- item index
public double getItemCost(int item)
item
- item index
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |