From 1a8aee7e56febac885fb46b6688fa5ba804b316f Mon Sep 17 00:00:00 2001 From: Nuwan Gunasekara Date: Sat, 11 Mar 2023 15:52:57 +1300 Subject: [PATCH] Fixing Issue #271 --- moa/src/main/java/moa/AbstractMOAObject.java | 6 ++--- moa/src/main/java/moa/MOAObject.java | 2 +- .../meta/AccuracyWeightedEnsemble.java | 4 +-- .../meta/WeightedMajorityAlgorithm.java | 4 +-- .../main/java/moa/classifiers/trees/EFDT.java | 26 +++++++++---------- .../trees/HoeffdingAdaptiveTree.java | 8 +++--- .../trees/HoeffdingOptionTree.java | 26 +++++++++---------- .../moa/classifiers/trees/HoeffdingTree.java | 26 +++++++++---------- .../main/java/moa/core/AutoExpandVector.java | 2 +- 9 files changed, 52 insertions(+), 52 deletions(-) diff --git a/moa/src/main/java/moa/AbstractMOAObject.java b/moa/src/main/java/moa/AbstractMOAObject.java index 60310da9e..3cea8bf11 100644 --- a/moa/src/main/java/moa/AbstractMOAObject.java +++ b/moa/src/main/java/moa/AbstractMOAObject.java @@ -37,7 +37,7 @@ public MOAObject copy() { } @Override - public int measureByteSize() { + public long measureByteSize() { return measureByteSize(this); } @@ -73,7 +73,7 @@ public static MOAObject copy(MOAObject obj) { * @param obj object to measure the memory size * @return the memory size of this object */ - public static int measureByteSize(MOAObject obj) { - return (int) SizeOf.fullSizeOf(obj); + public static long measureByteSize(MOAObject obj) { + return SizeOf.fullSizeOf(obj); } } diff --git a/moa/src/main/java/moa/MOAObject.java b/moa/src/main/java/moa/MOAObject.java index 497547634..4ec56618d 100644 --- a/moa/src/main/java/moa/MOAObject.java +++ b/moa/src/main/java/moa/MOAObject.java @@ -36,7 +36,7 @@ public interface MOAObject extends Serializable { * * @return the memory size of this object */ - public int measureByteSize(); + public long measureByteSize(); /** * This method produces a copy of this object. diff --git a/moa/src/main/java/moa/classifiers/meta/AccuracyWeightedEnsemble.java b/moa/src/main/java/moa/classifiers/meta/AccuracyWeightedEnsemble.java index aad854abe..3bb6b2f58 100644 --- a/moa/src/main/java/moa/classifiers/meta/AccuracyWeightedEnsemble.java +++ b/moa/src/main/java/moa/classifiers/meta/AccuracyWeightedEnsemble.java @@ -430,9 +430,9 @@ protected Classifier addToStored(Classifier newClassifier, double newClassifiers * * @return the size of the removed classifier. */ - protected int removePoorestModelBytes() { + protected long removePoorestModelBytes() { int poorestIndex = Utils.minIndex(this.ensembleWeights); - int byteSize = this.ensemble[poorestIndex].measureByteSize(); + long byteSize = this.ensemble[poorestIndex].measureByteSize(); discardModel(poorestIndex); return byteSize; } diff --git a/moa/src/main/java/moa/classifiers/meta/WeightedMajorityAlgorithm.java b/moa/src/main/java/moa/classifiers/meta/WeightedMajorityAlgorithm.java index ebbdee654..43d96c1e8 100644 --- a/moa/src/main/java/moa/classifiers/meta/WeightedMajorityAlgorithm.java +++ b/moa/src/main/java/moa/classifiers/meta/WeightedMajorityAlgorithm.java @@ -197,9 +197,9 @@ public void discardModel(int index) { this.ensembleWeights = newEnsembleWeights; } - protected int removePoorestModelBytes() { + protected long removePoorestModelBytes() { int poorestIndex = Utils.minIndex(this.ensembleWeights); - int byteSize = this.ensemble[poorestIndex].measureByteSize(); + long byteSize = this.ensemble[poorestIndex].measureByteSize(); discardModel(poorestIndex); return byteSize; } diff --git a/moa/src/main/java/moa/classifiers/trees/EFDT.java b/moa/src/main/java/moa/classifiers/trees/EFDT.java index dda4912ca..d900ed250 100644 --- a/moa/src/main/java/moa/classifiers/trees/EFDT.java +++ b/moa/src/main/java/moa/classifiers/trees/EFDT.java @@ -185,8 +185,8 @@ public String getPurposeString() { return "Hoeffding Tree or VFDT."; } - public int calcByteSize() { - int size = (int) SizeOf.sizeOf(this); + public long calcByteSize() { + long size = SizeOf.sizeOf(this); if (this.treeRoot != null) { size += this.treeRoot.calcByteSizeIncludingSubtree(); } @@ -194,7 +194,7 @@ public int calcByteSize() { } @Override - public int measureByteSize() { + public long measureByteSize() { return calcByteSize(); } @@ -352,7 +352,7 @@ public void estimateModelByteSizes() { this.inactiveLeafByteSizeEstimate = (double) totalInactiveSize / this.inactiveLeafNodeCount; } - int actualModelSize = this.measureByteSize(); + long actualModelSize = this.measureByteSize(); double estimatedModelSize = (this.activeLeafNodeCount * this.activeLeafByteSizeEstimate + this.inactiveLeafNodeCount * this.inactiveLeafByteSizeEstimate); @@ -699,11 +699,11 @@ public void setInfogainSum(HashMap igs) { infogainSum = igs; } - public int calcByteSize() { - return (int) (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution)); + public long calcByteSize() { + return (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution)); } - public int calcByteSizeIncludingSubtree() { + public long calcByteSizeIncludingSubtree() { return calcByteSize(); } @@ -769,14 +769,14 @@ public static class SplitNode extends Node { protected AutoExpandVector children; // = new AutoExpandVector(); @Override - public int calcByteSize() { + public long calcByteSize() { return super.calcByteSize() - + (int) (SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest)); + + SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest); } @Override - public int calcByteSizeIncludingSubtree() { - int byteSize = calcByteSize(); + public long calcByteSizeIncludingSubtree() { + long byteSize = calcByteSize(); for (Node child : this.children) { if (child != null) { byteSize += child.calcByteSizeIncludingSubtree(); @@ -1256,9 +1256,9 @@ public ActiveLearningNode(double[] initialClassObservations) { } @Override - public int calcByteSize() { + public long calcByteSize() { return super.calcByteSize() - + (int) (SizeOf.fullSizeOf(this.attributeObservers)); + + (SizeOf.fullSizeOf(this.attributeObservers)); } @Override diff --git a/moa/src/main/java/moa/classifiers/trees/HoeffdingAdaptiveTree.java b/moa/src/main/java/moa/classifiers/trees/HoeffdingAdaptiveTree.java index d2ff8af13..b74fa45bf 100644 --- a/moa/src/main/java/moa/classifiers/trees/HoeffdingAdaptiveTree.java +++ b/moa/src/main/java/moa/classifiers/trees/HoeffdingAdaptiveTree.java @@ -107,8 +107,8 @@ public static class AdaSplitNode extends SplitNode implements NewNode { // return ErrorChange; //} @Override - public int calcByteSizeIncludingSubtree() { - int byteSize = calcByteSize(); + public long calcByteSizeIncludingSubtree() { + long byteSize = calcByteSize(); if (alternateTree != null) { byteSize += alternateTree.calcByteSizeIncludingSubtree(); } @@ -314,8 +314,8 @@ public static class AdaLearningNode extends LearningNodeNBAdaptive implements Ne protected Random classifierRandom; @Override - public int calcByteSize() { - int byteSize = super.calcByteSize(); + public long calcByteSize() { + long byteSize = super.calcByteSize(); if (estimationErrorWeight != null) { byteSize += estimationErrorWeight.measureByteSize(); } diff --git a/moa/src/main/java/moa/classifiers/trees/HoeffdingOptionTree.java b/moa/src/main/java/moa/classifiers/trees/HoeffdingOptionTree.java index e810e47de..07d86107d 100644 --- a/moa/src/main/java/moa/classifiers/trees/HoeffdingOptionTree.java +++ b/moa/src/main/java/moa/classifiers/trees/HoeffdingOptionTree.java @@ -205,11 +205,11 @@ public Node(double[] classObservations) { this.observedClassDistribution = new DoubleVector(classObservations); } - public int calcByteSize() { - return (int) (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution)); + public long calcByteSize() { + return SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution); } - public int calcByteSizeIncludingSubtree() { + public long calcByteSizeIncludingSubtree() { return calcByteSize(); } @@ -290,14 +290,14 @@ public static class SplitNode extends Node { protected AutoExpandVector children = new AutoExpandVector(); @Override - public int calcByteSize() { + public long calcByteSize() { return super.calcByteSize() - + (int) (SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest)); + + SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest); } @Override - public int calcByteSizeIncludingSubtree() { - int byteSize = calcByteSize(); + public long calcByteSizeIncludingSubtree() { + long byteSize = calcByteSize(); for (Node child : this.children) { if (child != null) { byteSize += child.calcByteSizeIncludingSubtree(); @@ -539,9 +539,9 @@ public ActiveLearningNode(double[] initialClassObservations) { } @Override - public int calcByteSize() { + public long calcByteSize() { return super.calcByteSize() - + (int) (SizeOf.fullSizeOf(this.attributeObservers)); + + SizeOf.fullSizeOf(this.attributeObservers); } @Override @@ -617,8 +617,8 @@ public void disableAttribute(int attIndex) { protected int maxPredictionPaths; - public int calcByteSize() { - int size = (int) SizeOf.sizeOf(this); + public long calcByteSize() { + long size = SizeOf.sizeOf(this); if (this.treeRoot != null) { size += this.treeRoot.calcByteSizeIncludingSubtree(); } @@ -626,7 +626,7 @@ public int calcByteSize() { } @Override - public int measureByteSize() { + public long measureByteSize() { return calcByteSize(); } @@ -1040,7 +1040,7 @@ public void estimateModelByteSizes() { this.inactiveLeafByteSizeEstimate = (double) totalInactiveSize / this.inactiveLeafNodeCount; } - int actualModelSize = this.measureByteSize(); + long actualModelSize = this.measureByteSize(); double estimatedModelSize = (this.activeLeafNodeCount * this.activeLeafByteSizeEstimate + this.inactiveLeafNodeCount * this.inactiveLeafByteSizeEstimate); diff --git a/moa/src/main/java/moa/classifiers/trees/HoeffdingTree.java b/moa/src/main/java/moa/classifiers/trees/HoeffdingTree.java index 5abebf4fd..2b70a8ff4 100644 --- a/moa/src/main/java/moa/classifiers/trees/HoeffdingTree.java +++ b/moa/src/main/java/moa/classifiers/trees/HoeffdingTree.java @@ -192,11 +192,11 @@ public Node(double[] classObservations) { this.observedClassDistribution = new DoubleVector(classObservations); } - public int calcByteSize() { - return (int) (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution)); + public long calcByteSize() { + return SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution); } - public int calcByteSizeIncludingSubtree() { + public long calcByteSizeIncludingSubtree() { return calcByteSize(); } @@ -262,14 +262,14 @@ public static class SplitNode extends Node { protected AutoExpandVector children; // = new AutoExpandVector(); @Override - public int calcByteSize() { + public long calcByteSize() { return super.calcByteSize() - + (int) (SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest)); + + SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest); } @Override - public int calcByteSizeIncludingSubtree() { - int byteSize = calcByteSize(); + public long calcByteSizeIncludingSubtree() { + long byteSize = calcByteSize(); for (Node child : this.children) { if (child != null) { byteSize += child.calcByteSizeIncludingSubtree(); @@ -429,9 +429,9 @@ public ActiveLearningNode(double[] initialClassObservations) { } @Override - public int calcByteSize() { + public long calcByteSize() { return super.calcByteSize() - + (int) (SizeOf.fullSizeOf(this.attributeObservers)); + + SizeOf.fullSizeOf(this.attributeObservers); } @Override @@ -511,8 +511,8 @@ public void disableAttribute(int attIndex) { protected boolean growthAllowed; - public int calcByteSize() { - int size = (int) SizeOf.sizeOf(this); + public long calcByteSize() { + long size = SizeOf.sizeOf(this); if (this.treeRoot != null) { size += this.treeRoot.calcByteSizeIncludingSubtree(); } @@ -528,7 +528,7 @@ public Node getTreeRoot() { } @Override - public int measureByteSize() { + public long measureByteSize() { return calcByteSize(); } @@ -804,7 +804,7 @@ public void estimateModelByteSizes() { this.inactiveLeafByteSizeEstimate = (double) totalInactiveSize / this.inactiveLeafNodeCount; } - int actualModelSize = this.measureByteSize(); + long actualModelSize = this.measureByteSize(); double estimatedModelSize = (this.activeLeafNodeCount * this.activeLeafByteSizeEstimate + this.inactiveLeafNodeCount * this.inactiveLeafByteSizeEstimate); diff --git a/moa/src/main/java/moa/core/AutoExpandVector.java b/moa/src/main/java/moa/core/AutoExpandVector.java index 33c3ed53e..938f70a78 100644 --- a/moa/src/main/java/moa/core/AutoExpandVector.java +++ b/moa/src/main/java/moa/core/AutoExpandVector.java @@ -121,7 +121,7 @@ public MOAObject copy() { } @Override - public int measureByteSize() { + public long measureByteSize() { return AbstractMOAObject.measureByteSize(this); }