Commit 471ee8c4 by Michael Schmid

nfj creation does not work

parent bc29a6dc
......@@ -222,8 +222,8 @@ public class SystemSetup<T extends Task> {
}
private long randomProbability() {
// return random.nextInt(99) + 1;
return ThreadLocalRandom.current().nextLong(0, 100);
return random.nextInt(100);
// return ThreadLocalRandom.current().nextLong(0, 100);
}
public Set<DagTask> generateTaskSet(final double totalUtilization) {
......@@ -258,7 +258,7 @@ public class SystemSetup<T extends Task> {
final Job j = fork(jobDag, Optional.empty(), this.depth);
fork(jobDag, Optional.of(j), this.depth);
// randomEdges(jobDag); // TODO: uncomment
randomEdges(jobDag);
final long workload = DagUtils.calculateWorkload(jobDag);
final long criticalPath = DagUtils.calculateCriticalPath(jobDag);
......@@ -297,7 +297,7 @@ public class SystemSetup<T extends Task> {
System.out.println("Adding fork edge failed!");
}
}
if (depth >= 0 && randomProbability() <= p_par) {
if (depth >= 0 && randomProbability() < p_par) {
final long numberOfJobs = randomNumberOfBranches();
for (int i = 0; i < numberOfJobs; ++i) {
childs.add(fork(jobDag, Optional.of(job), depth - 1));
......@@ -311,7 +311,7 @@ public class SystemSetup<T extends Task> {
final Multimap<Job, Job> edgePairs = ArrayListMultimap.create();
for (final Job j1 : jobDag) {
for (final Job j2 : jobDag) {
if (randomProbability() <= p_add) {
if (randomProbability() < p_add) {
edgePairs.put(j1, j2);
}
}
......@@ -327,20 +327,20 @@ public class SystemSetup<T extends Task> {
}
private long randomTaskPeriod(final long criticalPathLength, final long workload) {
// long upper = (long) (workload / getBeta());
// return random.nextInt((int) (upper - criticalPathLength)) + criticalPathLength;
return ThreadLocalRandom.current().nextLong(criticalPathLength,
(long) (workload / getBeta()));
long upper = (long) (workload / getBeta());
return random.nextInt((int) (upper - criticalPathLength)) + criticalPathLength;
// return ThreadLocalRandom.current().nextLong(criticalPathLength,
// (long) (workload / getBeta()));
}
private long randomNumberOfBranches() {
// return random.nextInt((int) maxNumberOfBranches - 2) + 2;
return ThreadLocalRandom.current().nextLong(2, maxNumberOfBranches);
return random.nextInt((int) maxNumberOfBranches - 2) + 2;
// return ThreadLocalRandom.current().nextLong(2, maxNumberOfBranches);
}
private long randomWcet() {
// return random.nextInt((int) (maximumWcet - minimumWcet)) + minimumWcet;
return ThreadLocalRandom.current().nextLong(minimumWcet, maximumWcet);
return random.nextInt((int) (maximumWcet - minimumWcet)) + minimumWcet;
// return ThreadLocalRandom.current().nextLong(minimumWcet, maximumWcet);
}
/**
......
......@@ -108,12 +108,12 @@ public class DagUtils {
private static LinkedList<Job> getUnvisitedJoinNodes(
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag) {
final DirectedAcyclicGraph<Job, DefaultEdge> jobDag, final Set<Job> visitedJobs) {
final LinkedList<Job> joinNodes = new LinkedList<>();
final ClosestFirstIterator<Job, DefaultEdge> it = new ClosestFirstIterator<>(jobDag);
for (; it.hasNext();) {
final Job j = it.next();
if (jobDag.inDegreeOf(j) > 1 && !j.getVisited()) {
if (jobDag.inDegreeOf(j) > 1 && /* /* !j.getVisited() */!visitedJobs.contains(j)) {
joinNodes.add(j);
}
}
......@@ -131,24 +131,24 @@ public class DagUtils {
sink = j;
}
final Set<Job> visitedJobs = new HashSet<>();
while (true) {
final LinkedList<Job> joins = getUnvisitedJoinNodes(modifiedJobDag);
final LinkedList<Job> joins = getUnvisitedJoinNodes(modifiedJobDag, visitedJobs);
if (joins.isEmpty()) {
break;
}
final Job joinNode = joins.getFirst();
visitedJobs.add(joinNode);
joinNode.setVisited(true);
final Set<Job> ancestorsOfJ = jobDag.getAncestors(modifiedJobDag, joinNode);
ancestorsOfJ.add(joinNode);
nextEdge: while (modifiedJobDag.inDegreeOf(joinNode) > 1) {
final List<Job> predecessors = Graphs.predecessorListOf(modifiedJobDag, joinNode);
for (final Job p : predecessors) {
if (modifiedJobDag.outDegreeOf(p) > 1
|| !checkPredecessors(modifiedJobDag, joinNode, ancestorsOfJ, p)) {
if (!checkPredecessors(modifiedJobDag, joinNode, p)) {
// || !checkPredecessors(modifiedJobDag, p, joinNode, ancestorsOfJ)) {
// DefaultEdge e = modifiedJobDag.getEdge(p, joinNode);
// if ((modifiedJobDag.outDegreeOf(p) > 1)
// || checkForFork(modifiedJobDag, joinNode, ancestorsOfJ, e)) {
// || checkForFork(modifiedJobDag, joinNode, e)) {
final DefaultEdge conflictingEdge = modifiedJobDag.getEdge(p, joinNode);
modifiedJobDag.removeEdge(conflictingEdge);
if (modifiedJobDag.outDegreeOf(p) == 0) {
......@@ -170,7 +170,7 @@ public class DagUtils {
}
public static boolean checkForFork(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag,
final Job joinNode, Set<Job> ancestorsOfJ2, final DefaultEdge edge) {
final Job joinNode, final DefaultEdge edge) {
Set<Job> ancestorsOfJ = jobDag.getAncestors(jobDag, joinNode);
nextFork: for (final Job f : jobDag) {
......@@ -206,6 +206,7 @@ public class DagUtils {
final Job current, final Job joinNode, final Set<Job> ancestorsOfJ2) {
final List<Job> successorsOfCurrent = Graphs.successorListOf(jobDag, current);
final Set<Job> ancestorsOfJ = jobDag.getAncestors(jobDag, joinNode);
ancestorsOfJ.add(joinNode);
if (ancestorsOfJ.containsAll(successorsOfCurrent)) {
final Set<Job> descendantsOfCurrent = jobDag.getDescendants(jobDag, current);
if (descendantsOfCurrent.containsAll(Graphs.predecessorListOf(jobDag, joinNode))) {
......@@ -224,12 +225,14 @@ public class DagUtils {
}
private static boolean checkPredecessors(final DirectedAcyclicGraph<Job, DefaultEdge> jobDag,
final Job joinNode, final Set<Job> ancestorsOfJ2, Job current) {
Set<Job> ancestorsOfJ = jobDag.getAncestors(jobDag, joinNode);
final Job joinNode, Job current) {
final Set<Job> ancestorsOfJ = jobDag.getAncestors(jobDag, joinNode);
ancestorsOfJ.add(joinNode);
if (jobDag.outDegreeOf(current) > 1) {
if (!ancestorsOfJ.containsAll(Graphs.successorListOf(jobDag, current))) {
return false;
}
final Set<Job> descendantsOfCurrent = jobDag.getDescendants(jobDag, current);
if (descendantsOfCurrent.containsAll(Graphs.predecessorListOf(jobDag, joinNode))) {
return true;
......@@ -237,7 +240,7 @@ public class DagUtils {
}
final List<Job> predecessorList = Graphs.predecessorListOf(jobDag, current);
for (Job p : predecessorList) {
if (!checkPredecessors(jobDag, joinNode, ancestorsOfJ, p)) {
if (!checkPredecessors(jobDag, joinNode, p)) {
return false;
}
}
......
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