Commit 402173ef by Michael Schmid

Updated ResultCollector and minor changes

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