Package org.jacop.constraints.knapsack
Class TreeLeaf
java.lang.Object
org.jacop.constraints.knapsack.TreeNode
org.jacop.constraints.knapsack.TreeLeaf
It contains information required by the leaf node of the item tree.
- Version:
- 4.8
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal double
It specifies the efficiency of the item in the leaf.int
It specifies the position in the tree.int
It specifies the maximal value of quantity variable after the last consistency check.int
It specifies the minimal value of quantity variable after the last consistency check.final int
It store the profit of one instance of the item stored in this leaf.final IntVar
It specifies the finite domain variable denoting the allowed quantity of the item,int
It represents the offset from the minimal value.final int
It stores the weight of one instance of the item stored in this leaf.Fields inherited from class org.jacop.constraints.knapsack.TreeNode
left, leftNeighbor, parent, right, rightNeighbor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal double
It returns computed beforehand the efficiency of the item stored in this tree leaf.int
final int
getPSum()
It does not recompute sum of profits.final IntVar
int
final int
getWMax()
It does not recompute the maximum of weights.final int
getWSum()
It does not recompute sum of weights.final boolean
Used to know the changes that occurredfinal boolean
Used to know the changes that occurredfinal boolean
isLeaf()
final int
Used to know the changes that occurredfinal int
max()
final int
min()
final String
It generates description of the node only.void
recomputeDown
(Tree tree) This function recomputes the attributes of this node after recomputing the left and right subtree.void
recomputeUp
(Tree tree) This function is used to recompute the attributes of all nodes on the way to root from this node.final String
toString()
void
updateInternalValues
(Tree tree) Only used in removeLevelLate(), update the internal value like previous and slice.Methods inherited from class org.jacop.constraints.knapsack.TreeNode
setLeftNeighbor, setRightNeighbor
-
Field Details
-
quantity
It specifies the finite domain variable denoting the allowed quantity of the item, -
efficiency
public final double efficiencyIt specifies the efficiency of the item in the leaf. -
previousMaxQ
public int previousMaxQIt specifies the maximal value of quantity variable after the last consistency check. It is used to determine if the maximal value of the quantity variable has changed since the last execution of the consistency function. -
previousMinQ
public int previousMinQIt specifies the minimal value of quantity variable after the last consistency check. It is used to determine if the minimal value of the quantity variable has changed since the last execution of the consistency function. -
weightOfOne
public final int weightOfOneIt stores the weight of one instance of the item stored in this leaf. -
profitOfOne
public final int profitOfOneIt store the profit of one instance of the item stored in this leaf. -
slice
public int sliceIt represents the offset from the minimal value. Slice of value 1 means that 1 item has been already counted in capacity and profit of the knapsack and quantity variable should be offset by one. Both min and max values will be reduced by one. -
positionInTheTree
public int positionInTheTreeIt specifies the position in the tree.
-
-
Constructor Details
-
TreeLeaf
It creates a leaf in the tree of items.- Parameters:
quantity
- finite domain variable specifying the quantity.weight
- it specifies the weight of one instance of the item.profit
- it specifies the profit of one instance of the item.positionInTheTree
- it specifies the position in the tree.
-
-
Method Details
-
getVariable
- Returns:
- The variable stored in this leaf
-
getProfitOfOne
public int getProfitOfOne()- Returns:
- The profit of one unit of the variable
-
getWeightOfOne
public int getWeightOfOne()- Returns:
- The weight of one unit of the variable
-
hasMinChanged
public final boolean hasMinChanged()Used to know the changes that occurred- Returns:
- If the minimum has changed
-
lastIncreasedOfMin
public final int lastIncreasedOfMin()Used to know the changes that occurred- Returns:
- The last change of the minimum
-
hasMaxChanged
public final boolean hasMaxChanged()Used to know the changes that occurred- Returns:
- If the maximum has changed
-
getWMax
public final int getWMax()Description copied from class:TreeNode
It does not recompute the maximum of weights. -
getWSum
public final int getWSum()Description copied from class:TreeNode
It does not recompute sum of weights. -
getPSum
public final int getPSum()Description copied from class:TreeNode
It does not recompute sum of profits. -
isLeaf
public final boolean isLeaf() -
getEfficiency
public final double getEfficiency()It returns computed beforehand the efficiency of the item stored in this tree leaf.- Returns:
- the efficiency of the item stored at this computer.
-
toString
-
nodeToString
Description copied from class:TreeNode
It generates description of the node only.- Overrides:
nodeToString
in classTreeNode
- Returns:
- the description containing values of all node internal attributes.
-
updateInternalValues
Only used in removeLevelLate(), update the internal value like previous and slice. It does not updates anything else in the tree.- Parameters:
tree
- it specifies the tree to which this leaf belongs too.
-
min
public final int min()- Returns:
- The minimum value of the variable after slicing.
-
max
public final int max()- Returns:
- The maximum value of the variable after slicing
-
recomputeDown
Description copied from class:TreeNode
This function recomputes the attributes of this node after recomputing the left and right subtree.- Overrides:
recomputeDown
in classTreeNode
- Parameters:
tree
- It is required by leaves so tree atributes like alreadyUsedCapacity are properly updated.
-
recomputeUp
Description copied from class:TreeNode
This function is used to recompute the attributes of all nodes on the way to root from this node. It assumes that left and right subtree have a correct values for their attributes.- Overrides:
recomputeUp
in classTreeNode
- Parameters:
tree
- only added to be in agreement with the function template for leaf which need information about tree it belongs to.
-