- throughput instead of troughput
- removed automatic calc of error
- better structured result summary
This commit is contained in:
2025-02-05 10:36:07 +01:00
parent 7de4e80bb0
commit af192c8bf3
9 changed files with 31 additions and 22 deletions

View File

@@ -54,7 +54,7 @@ public class Result {
fFormat.formatted(stats.avgQueueLength),
fFormat.formatted(stats.avgWaitTime),
fFormat.formatted(stats.avgResponse),
fFormat.formatted(stats.troughput),
fFormat.formatted(stats.throughput),
fFormat.formatted(stats.utilization * 100),
fFormat.formatted(stats.unavailable * 100),
fFormat.formatted(stats.lastEventTime));

View File

@@ -51,9 +51,16 @@ public class ResultSummary {
* @param node the node to get the summary
* @param stat the statistic to get the summary
* @return the summary of the statistics of the node
* @throws IllegalArgumentException if the node or the statistic is not found
*/
public StatisticsSummary getSummaryOf(String node, String stat) {
return this.stats.get(node).get(stat);
var stats = this.getSummaryOf(node);
var value = stats.get(stat);
if (value == null) {
var arr = String.join(", ", stats.keySet().toArray(new String[0]));
throw new IllegalArgumentException("Statistic [" + stat + "] not found. Available: " + arr);
}
return value;
}
/**
@@ -61,9 +68,13 @@ public class ResultSummary {
*
* @param node the node to get the summary
* @return the summary of the statistics of the node
* @throws IllegalArgumentException if the node is not found
*/
public Map<String, StatisticsSummary> getSummaryOf(String node) {
return this.stats.get(node);
var stat = this.stats.get(node);
if (stat == null)
throw new IllegalArgumentException("Node not found");
return stat;
}
/**
@@ -99,7 +110,7 @@ public class ResultSummary {
fFormat.formatted(stats.get("avgQueueLength").average),
fFormat.formatted(stats.get("avgWaitTime").average),
fFormat.formatted(stats.get("avgResponse").average),
fFormat.formatted(stats.get("troughput").average),
fFormat.formatted(stats.get("throughput").average),
fFormat.formatted(stats.get("utilization").average * 100),
fFormat.formatted(stats.get("unavailable").average * 100),
fFormat.formatted(stats.get("lastEventTime").average));

View File

@@ -24,7 +24,7 @@ public class Statistics {
// derived stats, you can calculate them even at the end
public double avgWaitTime = 0.0d;
public double avgResponse = 0.0d;
public double troughput = 0.0d;
public double throughput = 0.0d;
public double utilization = 0.0d;
public double unavailable = 0.0d;
@@ -75,7 +75,7 @@ public class Statistics {
this.waitTime = this.responseTime - this.busyTime;
this.avgWaitTime = this.waitTime / this.numDepartures;
this.avgResponse = this.responseTime / this.numDepartures;
this.troughput = this.numDepartures / time;
this.throughput = this.numDepartures / time;
this.utilization = this.busyTime / time;
this.unavailable = this.unavailableTime / time;
@@ -120,7 +120,7 @@ public class Statistics {
*/
public static String[] getOrderOfApply() {
return new String[] { "numArrivals", "numDepartures", "avgQueueLength", "avgWaitTime", "avgResponse",
"busyTime", "waitTime", "unavailableTime", "responseTime", "lastEventTime", "troughput", "utilization",
"busyTime", "waitTime", "unavailableTime", "responseTime", "lastEventTime", "throughput", "utilization",
"unavailable" };
}
@@ -152,7 +152,7 @@ public class Statistics {
save.unavailableTime = func.apply(val1.unavailableTime, val2.unavailableTime);
save.responseTime = func.apply(val1.responseTime, val2.responseTime);
save.lastEventTime = func.apply(val1.lastEventTime, val2.lastEventTime);
save.troughput = func.apply(val1.troughput, val2.troughput);
save.throughput = func.apply(val1.throughput, val2.throughput);
save.utilization = func.apply(val1.utilization, val2.utilization);
save.unavailable = func.apply(val1.unavailable, val2.unavailable);
}

View File

@@ -3,6 +3,7 @@ package net.berack.upo.valpre.sim.stats;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.math3.distribution.TDistribution;
/**
* A summary of the values.
@@ -14,8 +15,8 @@ public class StatisticsSummary {
public final double min;
public final double max;
public final double stdDev;
public final double error95;
public final double[] values;
private final TDistribution distr;
/**
* Create a summary of the values.
@@ -41,7 +42,7 @@ public class StatisticsSummary {
this.median = this.getPercentile(0.50);
this.min = values[0];
this.max = values[values.length - 1];
this.error95 = this.calcError(0.95);
this.distr = new TDistribution(null, values.length - 1);
}
/**
@@ -55,11 +56,8 @@ public class StatisticsSummary {
* @return the error of the values
*/
public double calcError(double alpha) {
var sampleSize = this.values.length;
var distr = new org.apache.commons.math3.distribution.TDistribution(sampleSize - 1);
var percentile = distr.inverseCumulativeProbability(alpha);
return percentile * (this.stdDev / Math.sqrt(sampleSize));
var percentile = this.distr.inverseCumulativeProbability(alpha);
return percentile * (this.stdDev / Math.sqrt(this.values.length));
}
/**