public final class TreeLeaf extends TreeNode
Modifier and Type | Field and Description |
---|---|
double |
efficiency
It specifies the efficiency of the item in the leaf.
|
int |
positionInTheTree
It specifies the position in the tree.
|
int |
previousMaxQ
It specifies the maximal value of quantity variable after the last
consistency check.
|
int |
previousMinQ
It specifies the minimal value of quantity variable after the last
consistency check.
|
int |
profitOfOne
It store the profit of one instance of the item stored in this leaf.
|
IntVar |
quantity
It specifies the finite domain variable denoting the allowed
quantity of the item,
|
int |
slice
It represents the offset from the minimal value.
|
int |
weightOfOne
It stores the weight of one instance of the item stored in this leaf.
|
left, leftNeighbor, parent, right, rightNeighbor
Constructor and Description |
---|
TreeLeaf(IntVar quantity,
int weight,
int profit,
int positionInTheTree)
It creates a leaf in the tree of items.
|
Modifier and Type | Method and Description |
---|---|
double |
getEfficiency()
It returns computed beforehand
the efficiency of the item stored in this tree leaf.
|
int |
getProfitOfOne() |
int |
getPSum()
It does not recompute sum of profits.
|
IntVar |
getVariable() |
int |
getWeightOfOne() |
int |
getWMax()
It does not recompute the maximum of weights.
|
int |
getWSum()
It does not recompute sum of weights.
|
boolean |
hasMaxChanged()
Used to know the changes that occurred
|
boolean |
hasMinChanged()
Used to know the changes that occurred
|
boolean |
isLeaf() |
int |
lastIncreasedOfMin()
Used to know the changes that occurred
|
int |
max() |
int |
min() |
String |
nodeToString()
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.
|
String |
toString() |
void |
updateInternalValues(Tree tree)
Only used in removeLevelLate(), update the internal value like previous
and slice.
|
setLeftNeighbor, setRightNeighbor
public final IntVar quantity
public final double efficiency
public int previousMaxQ
public int previousMinQ
public final int weightOfOne
public final int profitOfOne
public int slice
public int positionInTheTree
public TreeLeaf(IntVar quantity, int weight, int profit, int positionInTheTree)
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.public final IntVar getVariable()
public int getProfitOfOne()
public int getWeightOfOne()
public final boolean hasMinChanged()
public final int lastIncreasedOfMin()
public final boolean hasMaxChanged()
public final int getWMax()
TreeNode
public final int getWSum()
TreeNode
public final int getPSum()
TreeNode
public final boolean isLeaf()
public final double getEfficiency()
public final String nodeToString()
TreeNode
nodeToString
in class TreeNode
public void updateInternalValues(Tree tree)
tree
- it specifies the tree to which this leaf belongs too.public final int min()
public final int max()
public void recomputeDown(Tree tree)
TreeNode
recomputeDown
in class TreeNode
tree
- It is required by leaves so tree atributes like alreadyUsedCapacity are properly updated.public void recomputeUp(Tree tree)
TreeNode
recomputeUp
in class TreeNode
tree
- only added to be in agreement with the function template
for leaf which need information about tree it belongs to.Copyright © 2022. All rights reserved.