Commit 402173ef by Michael Schmid

Updated ResultCollector and minor changes

parent 2a366392
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
<attribute name="m2e-apt" value="true"/> <attribute name="m2e-apt" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
......
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter-api</artifactId>
<version>5.4.0</version> <version>5.4.0</version>
......
...@@ -12,16 +12,16 @@ import mvd.jester.priority.RateMonotonic; ...@@ -12,16 +12,16 @@ import mvd.jester.priority.RateMonotonic;
public class App { public class App {
public static void main(String[] args) { public static void main(String[] args) {
SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8); SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8);
TestEnvironment te = new TestEnvironment(builder, 30000); TestEnvironment te = new TestEnvironment(builder, 40000);
te.registerSchedulingAlgorithm(new RateMonotonic()); te.registerSchedulingAlgorithm(new RateMonotonic());
te.registerSchedulingAlgorithm(new EarliestDeadlineFirst()); // te.registerSchedulingAlgorithm(new EarliestDeadlineFirst());
// te.registerTest(mvd.jester.tests.SchmidMottok.class); te.registerTest(mvd.jester.tests.SchmidMottok.class);
// te.registerTest(mvd.jester.tests.MaiaBertogna.class); te.registerTest(mvd.jester.tests.MaiaBertogna.class);
te.registerSimulator(mvd.jester.simulator.MaiaBertogna.class); // te.registerSimulator(mvd.jester.simulator.MaiaBertogna.class);
te.registerSimulator(mvd.jester.simulator.SchmidMottok.class); // te.registerSimulator(mvd.jester.simulator.SchmidMottok.class);
te.runTests(); te.runTests();
......
...@@ -8,6 +8,7 @@ import java.util.Optional; ...@@ -8,6 +8,7 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import com.google.common.collect.Table; import com.google.common.collect.Table;
import com.google.common.math.Stats; import com.google.common.math.Stats;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import mvd.jester.info.SchedulingInfo; import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo; import mvd.jester.info.TerminationInfo;
import mvd.jester.simulator.AbstractSimulator; import mvd.jester.simulator.AbstractSimulator;
...@@ -36,22 +37,52 @@ public class ResultCollector { ...@@ -36,22 +37,52 @@ public class ResultCollector {
public void logAll() { public void logAll() {
if (!testResults.isEmpty()) { if (!testResults.isEmpty()) {
logFeasibility(testResults, "test"); logFeasibility(testResults, "test");
logTardinessStatistics(simulatorResults, "test"); logFeasibilityRatio(testResults, "test");
logTardinessStatistics(testResults, "test");
logFailedTardiness(testResults, "test"); logFailedTardiness(testResults, "test");
} }
if (!simulatorResults.isEmpty()) { if (!simulatorResults.isEmpty()) {
logFeasibility(simulatorResults, "sim"); logFeasibility(simulatorResults, "sim");
logFeasibilityRatio(simulatorResults, "sim");
logTardinessStatistics(simulatorResults, "sim"); logTardinessStatistics(simulatorResults, "sim");
logFailedTardiness(simulatorResults, "sim"); logFailedTardiness(simulatorResults, "sim");
} }
} }
public <T extends PairInterface> void logFeasibilityRatio(
Table<Long, Pair<T>, Set<SchedulingInfo>> results, String type) {
LocalTime date = LocalTime.now();
Logger log = new Logger("./results/feasibility_ratio_" + type + "_" + numberOfProcessors
+ "_" + date.getHour() + ":" + date.getMinute() + ".txt");
String firstLine = new String("Utilization");
if (!results.isEmpty()) {
for (Pair<T> pair : results.columnKeySet()) {
firstLine = firstLine + "\t" + pair.getName();
}
log.log(firstLine);
for (Long util : totalNumberOfTasksets.keySet()) {
String line = String.valueOf((double) util / 10);
for (Pair<T> pair : results.columnKeySet()) {
long feasibleTasksets = results.get(util, pair).stream()
.filter(s -> s.checkTasksetFeasible()).count();
line += "\t" + ((double) feasibleTasksets / totalNumberOfTasksets.get(util));
}
log.log(line);
}
}
log.finalize();
}
public <T extends PairInterface> void logFeasibility( public <T extends PairInterface> void logFeasibility(
Table<Long, Pair<T>, Set<SchedulingInfo>> results, String type) { Table<Long, Pair<T>, Set<SchedulingInfo>> results, String type) {
LocalTime date = LocalTime.now(); LocalTime date = LocalTime.now();
Logger log = new Logger("./results/results_" + type + "_" + numberOfProcessors + "_" Logger log = new Logger("./results/feasibility_" + type + "_" + numberOfProcessors + "_"
+ date.getHour() + ":" + date.getMinute() + ".txt"); + date.getHour() + ":" + date.getMinute() + ".txt");
String firstLine = new String("Utilization\tTotal"); String firstLine = new String("Utilization");
if (!results.isEmpty()) { if (!results.isEmpty()) {
for (Pair<T> pair : results.columnKeySet()) { for (Pair<T> pair : results.columnKeySet()) {
...@@ -61,8 +92,7 @@ public class ResultCollector { ...@@ -61,8 +92,7 @@ public class ResultCollector {
log.log(firstLine); log.log(firstLine);
for (Long util : totalNumberOfTasksets.keySet()) { for (Long util : totalNumberOfTasksets.keySet()) {
String line = String line = String.valueOf((double) util / 10);
String.valueOf((double) util / 10) + "\t" + totalNumberOfTasksets.get(util);
for (Pair<T> pair : results.columnKeySet()) { for (Pair<T> pair : results.columnKeySet()) {
long feasibleTasksets = results.get(util, pair).stream() long feasibleTasksets = results.get(util, pair).stream()
.filter(s -> s.checkTasksetFeasible()).count(); .filter(s -> s.checkTasksetFeasible()).count();
...@@ -81,7 +111,7 @@ public class ResultCollector { ...@@ -81,7 +111,7 @@ public class ResultCollector {
LocalTime date = LocalTime.now(); LocalTime date = LocalTime.now();
Logger log = new Logger("./results/failed_tardiness_" + type + "_" + numberOfProcessors Logger log = new Logger("./results/failed_tardiness_" + type + "_" + numberOfProcessors
+ "_" + date.getHour() + ":" + date.getMinute() + ".txt"); + "_" + date.getHour() + ":" + date.getMinute() + ".txt");
String firstLine = new String("Utilization\tTotal"); String firstLine = new String("Utilization");
if (!results.isEmpty()) { if (!results.isEmpty()) {
for (Pair<T> pair : results.columnKeySet()) { for (Pair<T> pair : results.columnKeySet()) {
...@@ -91,8 +121,7 @@ public class ResultCollector { ...@@ -91,8 +121,7 @@ public class ResultCollector {
log.log(firstLine); log.log(firstLine);
for (Long kv : totalNumberOfTasksets.keySet()) { for (Long kv : totalNumberOfTasksets.keySet()) {
String line = String line = String.valueOf((double) kv / 10);
String.valueOf((double) kv / 10) + "\t" + totalNumberOfTasksets.get(kv);
for (Pair<T> pair : results.columnKeySet()) { for (Pair<T> pair : results.columnKeySet()) {
Set<SchedulingInfo> simulationInfos = results.get(kv, pair); Set<SchedulingInfo> simulationInfos = results.get(kv, pair);
List<Long> values = new ArrayList<>(); List<Long> values = new ArrayList<>();
...@@ -122,7 +151,7 @@ public class ResultCollector { ...@@ -122,7 +151,7 @@ public class ResultCollector {
LocalTime date = LocalTime.now(); LocalTime date = LocalTime.now();
Logger log = new Logger("./results/statistics_tardiness_" + type + "_" + numberOfProcessors Logger log = new Logger("./results/statistics_tardiness_" + type + "_" + numberOfProcessors
+ "_" + date.getHour() + ":" + date.getMinute() + ".txt"); + "_" + date.getHour() + ":" + date.getMinute() + ".txt");
String firstLine = new String("Utilization\tTotal"); String firstLine = new String("Utilization");
if (!results.isEmpty()) { if (!results.isEmpty()) {
for (Pair<T> pair : results.columnKeySet()) { for (Pair<T> pair : results.columnKeySet()) {
...@@ -132,23 +161,18 @@ public class ResultCollector { ...@@ -132,23 +161,18 @@ public class ResultCollector {
log.log(firstLine); log.log(firstLine);
for (Long kv : totalNumberOfTasksets.keySet()) { for (Long kv : totalNumberOfTasksets.keySet()) {
String line = String line = String.valueOf((double) kv / 10);
String.valueOf((double) kv / 10) + "\t" + totalNumberOfTasksets.get(kv);
for (Pair<T> pair : results.columnKeySet()) { for (Pair<T> pair : results.columnKeySet()) {
Set<SchedulingInfo> simulationInfos = results.get(kv, pair); Set<SchedulingInfo> simulationInfos = results.get(kv, pair);
List<Long> values = new ArrayList<>(); DescriptiveStatistics stats = new DescriptiveStatistics();
for (SchedulingInfo s : simulationInfos) { for (SchedulingInfo s : simulationInfos) {
for (TerminationInfo t : s.getTerminationInfos()) { for (TerminationInfo t : s.getTerminationInfos()) {
values.add(t.getLateness()); stats.addValue(t.getLateness());
} }
} }
double meanTardiness = 0; line += "\t" + stats.getMean();
if (!values.isEmpty()) {
meanTardiness = Stats.meanOf(values.iterator());
}
line += "\t" + meanTardiness;
} }
log.log(line); log.log(line);
} }
......
...@@ -19,6 +19,8 @@ public class SchedulingInfo { ...@@ -19,6 +19,8 @@ public class SchedulingInfo {
public SchedulingInfo(Set<TerminationInfo> terminationInfos) { public SchedulingInfo(Set<TerminationInfo> terminationInfos) {
this.terminationInfos = terminationInfos; this.terminationInfos = terminationInfos;
failedTerminationInfo =
terminationInfos.stream().filter(t -> t.getLateness() > 0).findFirst();
} }
public boolean checkTasksetFeasible() { public boolean checkTasksetFeasible() {
......
...@@ -101,8 +101,11 @@ public class SystemSetup { ...@@ -101,8 +101,11 @@ public class SystemSetup {
} }
private long randomTaskPeriod() { private long randomTaskPeriod(boolean serial) {
if (serial)
return ThreadLocalRandom.current().nextLong(minPeriod, maxPeriod); return ThreadLocalRandom.current().nextLong(minPeriod, maxPeriod);
else
return ThreadLocalRandom.current().nextLong(minPeriod, maxPeriod * 10);
} }
private long randomTaskRatio() { private long randomTaskRatio() {
...@@ -126,20 +129,13 @@ public class SystemSetup { ...@@ -126,20 +129,13 @@ public class SystemSetup {
private Task generateTask() { private Task generateTask() {
boolean serial = randomTaskRatio() > this.ratio; boolean serial = randomTaskRatio() > this.ratio;
long period = randomTaskPeriod(); long period = randomTaskPeriod(serial);
long numberOfSegments = 1; long numberOfSegments = serial ? 1 : randomNumberOfSegments();
Set<Segment> segments = new LinkedHashSet<Segment>();
if (!serial) {
numberOfSegments = randomNumberOfSegments();
} else {
numberOfSegments = 1;
}
long parallelNumberOfJobs = serial ? 1 : randomNumberOfJobs(); long parallelNumberOfJobs = serial ? 1 : randomNumberOfJobs();
Set<Segment> segments = new LinkedHashSet<Segment>();
for (int i = 0; i < numberOfSegments; ++i) { for (int i = 0; i < numberOfSegments; ++i) {
long numberOfJobs = 1; long numberOfJobs = i % 2 == 1 ? parallelNumberOfJobs : 1;
if (i % 2 == 1) {
numberOfJobs = parallelNumberOfJobs;
}
long wcet = randomWcet(period, numberOfSegments); long wcet = randomWcet(period, numberOfSegments);
segments.add(new Segment(wcet, numberOfJobs)); segments.add(new Segment(wcet, numberOfJobs));
} }
...@@ -147,10 +143,9 @@ public class SystemSetup { ...@@ -147,10 +143,9 @@ public class SystemSetup {
} }
private Set<Task> generateTaskSet() { private Set<Task> generateTaskSet() {
// SortedTaskSet taskSet = new SortedTaskSet(priorityManager);
Set<Task> taskSet = new HashSet<>(); Set<Task> taskSet = new HashSet<>();
for (int i = 0; i < 4; ++i) { for (int i = 0; i < numberOfProcessors; ++i) {
Task task = generateTask(); Task task = generateTask();
taskSet.add(task); taskSet.add(task);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment