|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsavi.alg.knapsack.StateKnapsack
public class StateKnapsack
State representing knapsack problem.
Field Summary | |
---|---|
protected double |
currCost
current cost |
protected double |
currWeight
current weight |
protected Items |
items
reference to available items |
protected int |
itmCount
number of items in knapsack |
protected double |
maxWeight
capacity (maximum knapsack weight) |
protected java.util.Random |
rnd
random generator |
protected boolean[] |
sack
represent items, if they in knapsack |
Constructor Summary | |
---|---|
StateKnapsack(Items items,
double maxWeight)
Creates a new instance of StateKnapsack |
Method Summary | |
---|---|
java.lang.Object |
clone()
Creates and returns a copy of this object. |
void |
findInitialState(double temp)
Initialize state |
void |
findNextState(double temp)
Finds next state of knapsack problem. |
double |
getActualCost()
Count actual optimalization criterion. |
Items |
getItems()
Return available items. |
boolean[] |
getKnapsack()
Return true/false list of items representing content of knapsack |
double |
getRealCost()
This method count current cost. |
int |
getSelectedItemsCount()
Get count of items in knapsack. |
java.lang.String[] |
getSubmission()
Return text representation of knapsack instance. |
double |
getWeight()
Count weight of items in knapsack. |
double |
recountCost()
Recount current cost. |
void |
setCapacity(double capacity)
Set maximum weight of items in knapsack |
void |
setItems(Items items)
Set available items. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Items items
protected double currCost
protected double currWeight
protected double maxWeight
protected int itmCount
protected boolean[] sack
protected java.util.Random rnd
Constructor Detail |
---|
public StateKnapsack(Items items, double maxWeight)
items
- items listmaxWeight
- knapsack capacityMethod Detail |
---|
public void findInitialState(double temp)
findInitialState
in interface StateSkeleton
temp
- starting temperaturepublic void findNextState(double temp)
findNextState
in interface StateSkeleton
temp
- current temperaturepublic double getRealCost()
public double getActualCost()
getActualCost
in interface StateSkeleton
public java.lang.Object clone()
clone
in interface StateSkeleton
clone
in class java.lang.Object
public double recountCost()
public int getSelectedItemsCount()
public double getWeight()
public boolean[] getKnapsack()
public Items getItems()
public void setCapacity(double capacity)
capacity
- capacitypublic void setItems(Items items)
items
- instance of class Itemspublic java.lang.String[] getSubmission()
getSubmission
in interface StateSkeleton
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |