Skip to content

Commit

Permalink
Issue 107: SVM reduce memory use
Browse files Browse the repository at this point in the history
  • Loading branch information
gwlucastrig committed Jan 23, 2024
1 parent 94c5c79 commit ab1139d
Show file tree
Hide file tree
Showing 6 changed files with 513 additions and 514 deletions.
20 changes: 10 additions & 10 deletions svm/src/main/java/org/tinfour/svm/SvmCapacityGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import java.util.Comparator;
import java.util.List;
import javax.imageio.ImageIO;
import org.tinfour.svm.SvmTriangleVolumeStore.AreaVolumeResult;
import org.tinfour.svm.SvmTriangleVolumeTabulator.AreaVolumeSum;
import org.tinfour.svm.properties.SvmProperties;
import org.tinfour.svm.properties.SvmUnitSpecification;
import org.tinfour.utils.AxisIntervals;
Expand All @@ -64,7 +64,7 @@
class SvmCapacityGraph {

private final SvmProperties properties;
private final List<AreaVolumeResult> resultList;
private final List<AreaVolumeSum> resultList;
private final double totalVolume;
private final double minLevel;
private final double maxLevel;
Expand Down Expand Up @@ -103,13 +103,13 @@ private double computeFontSize(double dSize, double dHeight) {
* shore reference elevation
*/
SvmCapacityGraph(SvmProperties properties,
List<AreaVolumeResult> sourceResultList,
List<AreaVolumeSum> sourceResultList,
double totalVolume) {
List<AreaVolumeResult> resultList = new ArrayList<>();
List<AreaVolumeSum> resultList = new ArrayList<>();
resultList.addAll(sourceResultList);
Collections.sort(resultList, new Comparator<AreaVolumeResult>() {
Collections.sort(resultList, new Comparator<AreaVolumeSum>() {
@Override
public int compare(AreaVolumeResult o1, AreaVolumeResult o2) {
public int compare(AreaVolumeSum o1, AreaVolumeSum o2) {
return Double.compare(o1.level, o2.level);
}

Expand Down Expand Up @@ -398,9 +398,9 @@ boolean writeOutput() throws IOException {

Path2D path = new Path2D.Double();
boolean moveFlag = true;
for (AreaVolumeResult avr : resultList) {
for (AreaVolumeSum avr : resultList) {
double level = avr.level;
double percent = 100.0 * avr.volume / totalVolume;
double percent = 100.0 * avr.getVolume() / totalVolume;
double x = x0 + (level - xCoords[0]) / xUnitsPerPixel;
double y = y1 - percent / cUnitsPerPixel;
if (moveFlag) {
Expand Down Expand Up @@ -445,9 +445,9 @@ private List<Point2D> extrapolate() {
double p1 = 0; // sum of x * y
double p2 = 0; // sum of x^2 * y

for (AreaVolumeResult avr : resultList) {
for (AreaVolumeSum avr : resultList) {
double x = avr.level - maxLevel;
double y = avr.volume / totalVolume - 1;
double y = avr.getVolume() / totalVolume - 1;
double x2 = x * x;
s2 += x2;
s3 += x2 * x;
Expand Down
Loading

0 comments on commit ab1139d

Please sign in to comment.