Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
jester
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
75736ee6
authored
Jun 02, 2020
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decomposition tree creation now works as well
parent
c5bc69e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
65 deletions
+10
-65
src/main/java/mvd/jester/model/SystemSetup.java
+1
-1
src/main/java/mvd/jester/utils/DagUtils.java
+5
-4
src/test/java/mvd/jester/model/TestDagUtils.java
+4
-60
No files found.
src/main/java/mvd/jester/model/SystemSetup.java
View file @
75736ee6
...
@@ -317,7 +317,7 @@ public class SystemSetup<T extends Task> {
...
@@ -317,7 +317,7 @@ public class SystemSetup<T extends Task> {
try
{
try
{
jobDag
.
addDagEdge
(
pairs
.
getKey
(),
pairs
.
getValue
());
jobDag
.
addDagEdge
(
pairs
.
getKey
(),
pairs
.
getValue
());
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
//
TODO: handle exception
//
nothing to do here
}
}
}
}
}
}
...
...
src/main/java/mvd/jester/utils/DagUtils.java
View file @
75736ee6
...
@@ -147,7 +147,7 @@ public class DagUtils {
...
@@ -147,7 +147,7 @@ public class DagUtils {
try
{
try
{
modifiedJobDag
.
addDagEdge
(
p
,
sink
);
modifiedJobDag
.
addDagEdge
(
p
,
sink
);
}
catch
(
final
Exception
exception
)
{
}
catch
(
final
Exception
exception
)
{
// TODO: handle exception
}
}
}
}
continue
nextEdge
;
continue
nextEdge
;
...
@@ -296,10 +296,11 @@ public class DagUtils {
...
@@ -296,10 +296,11 @@ public class DagUtils {
final
Job
forkNode
,
final
Job
sink
,
final
List
<
Job
>
joinNodes
)
{
final
Job
forkNode
,
final
Job
sink
,
final
List
<
Job
>
joinNodes
)
{
for
(
final
Job
j
:
joinNodes
)
{
for
(
final
Job
j
:
joinNodes
)
{
final
Set
<
Job
>
ancestorsOfJ
=
jobDag
.
getAncestors
(
jobDag
,
j
);
final
Set
<
Job
>
ancestorsOfJ
=
jobDag
.
getAncestors
(
jobDag
,
j
);
final
Set
<
Job
>
ances
o
torsOfFork
=
jobDag
.
getAncestors
(
jobDag
,
forkNode
);
final
Set
<
Job
>
ancestorsOfFork
=
jobDag
.
getAncestors
(
jobDag
,
forkNode
);
ances
o
torsOfFork
.
add
(
forkNode
);
ancestorsOfFork
.
add
(
forkNode
);
final
Set
<
Job
>
inbetweenJobs
=
new
HashSet
<>(
ancestorsOfJ
);
final
Set
<
Job
>
inbetweenJobs
=
new
HashSet
<>(
ancestorsOfJ
);
inbetweenJobs
.
removeAll
(
ancesotorsOfFork
);
inbetweenJobs
.
removeAll
(
ancestorsOfFork
);
inbetweenJobs
.
add
(
j
);
if
(
inbetweenJobs
.
isEmpty
())
{
if
(
inbetweenJobs
.
isEmpty
())
{
continue
;
continue
;
}
}
...
...
src/test/java/mvd/jester/model/TestDagUtils.java
View file @
75736ee6
package
mvd
.
jester
.
model
;
package
mvd
.
jester
.
model
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
java.util.List
;
import
java.util.concurrent.ThreadLocalRandom
;
import
java.util.Stack
;
import
org.jgrapht.Graphs
;
import
org.jgrapht.Graphs
;
import
org.jgrapht.experimental.dag.DirectedAcyclicGraph
;
import
org.jgrapht.experimental.dag.DirectedAcyclicGraph
;
import
org.jgrapht.graph.DefaultEdge
;
import
org.jgrapht.graph.DefaultEdge
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
mvd.jester.utils.DagUtils
;
import
mvd.jester.utils.DagUtils
;
import
mvd.jester.utils.BinaryDecompositionTree.Node
;
import
mvd.jester.utils.BinaryDecompositionTree.NodeType
;
import
mvd.jester.model.SystemSetup.DagTaskBuilder
;
import
mvd.jester.model.SystemSetup.DagTaskBuilder
;
import
mvd.jester.utils.BinaryDecompositionTree
;
import
mvd.jester.utils.BinaryDecompositionTree
;
...
@@ -38,7 +35,7 @@ public class TestDagUtils {
...
@@ -38,7 +35,7 @@ public class TestDagUtils {
@Test
@Test
@DisplayName
(
"Check if NFJ DAGs are created correctly."
)
@DisplayName
(
"Check if NFJ DAGs are created correctly."
)
void
checkNfjDagCreation
()
{
void
checkNfjDagCreation
()
{
for
(
int
i
=
0
;
i
<
100
00
;
++
i
)
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
DagTaskBuilder
b
=
new
DagTaskBuilder
();
DagTaskBuilder
b
=
new
DagTaskBuilder
();
DagTask
t
=
b
.
generateTask
();
DagTask
t
=
b
.
generateTask
();
...
@@ -49,55 +46,11 @@ public class TestDagUtils {
...
@@ -49,55 +46,11 @@ public class TestDagUtils {
}
}
private
long
countLeafs
(
BinaryDecompositionTree
<
Job
>
tree
)
{
Node
<
Job
>
node
=
tree
.
getRootNode
();
// Base Case
if
(
node
==
null
)
{
return
0
;
}
// Create an empty stack and push root to it
Stack
<
Node
<
Job
>>
nodeStack
=
new
Stack
<>();
nodeStack
.
push
(
node
);
long
count
=
0
;
while
(
nodeStack
.
empty
()
==
false
)
{
// Pop the top item from stack and print it
Node
<
Job
>
mynode
=
nodeStack
.
peek
();
if
(
mynode
.
getNodeType
()
==
NodeType
.
LEAF
)
{
count
++;
}
nodeStack
.
pop
();
// Push right and left children of the popped node to stack
if
(
mynode
.
getLeftNode
()
!=
null
)
{
nodeStack
.
push
(
mynode
.
getLeftNode
());
}
if
(
mynode
.
getRightNode
()
!=
null
)
{
nodeStack
.
push
(
mynode
.
getRightNode
());
}
}
return
count
;
}
private
void
drawGraph
(
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
nfjJobDag
)
{
for
(
Job
j
:
nfjJobDag
)
{
List
<
Job
>
predecessors
=
Graphs
.
predecessorListOf
(
nfjJobDag
,
j
);
List
<
Job
>
successors
=
Graphs
.
successorListOf
(
nfjJobDag
,
j
);
int
test
=
4
;
}
}
@Test
@Test
@DisplayName
(
"Check if Decomposition Tree is created correctly for NFJ Dag."
)
@DisplayName
(
"Check if Decomposition Tree is created correctly for NFJ Dag."
)
void
checkDecompositionTreeCreation
()
{
void
checkDecompositionTreeCreation
()
{
for
(
int
i
=
0
;
i
<
10000
;
++
i
)
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
// {
long
numberOfProcessors
=
ThreadLocalRandom
.
current
().
nextLong
(
4
,
16
);
// int i = 610;
// System.out.println(i);
// long numberOfProcessors = ThreadLocalRandom.current().nextLong(4, 16);
long
numberOfProcessors
=
4
;
DagTaskBuilder
b
=
new
DagTaskBuilder
().
setNumberOfProcessors
(
numberOfProcessors
);
DagTaskBuilder
b
=
new
DagTaskBuilder
().
setNumberOfProcessors
(
numberOfProcessors
);
DagTask
t
=
b
.
generateTask
();
DagTask
t
=
b
.
generateTask
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
=
t
.
getJobDag
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
=
t
.
getJobDag
();
...
@@ -107,22 +60,13 @@ public class TestDagUtils {
...
@@ -107,22 +60,13 @@ public class TestDagUtils {
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDagFromTree
=
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDagFromTree
=
DagUtils
.
createNFJfromDecompositionTree
(
tree
);
DagUtils
.
createNFJfromDecompositionTree
(
tree
);
// drawGraph(nfjJobDag);
// drawGraph(nfjJobDag);
boolean
ja
=
DagUtils
.
checkNFJProperty
(
nfjJobDag
);
System
.
out
.
println
(
"Bei i = "
+
i
+
": nfj = "
+
ja
);
assertTrue
(
jobDag
.
vertexSet
().
size
()
==
nfjJobDag
.
vertexSet
().
size
());
assertTrue
(
jobDag
.
vertexSet
().
size
()
==
nfjJobDag
.
vertexSet
().
size
());
assertTrue
(
jobDag
.
vertexSet
().
size
()
==
jobDagFromTree
.
vertexSet
().
size
());
assertTrue
(
jobDag
.
vertexSet
().
size
()
==
jobDagFromTree
.
vertexSet
().
size
());
assertTrue
(
jobDagFromTree
.
edgeSet
().
size
()
==
nfjJobDag
.
edgeSet
().
size
());
assertTrue
(
jobDagFromTree
.
edgeSet
().
size
()
==
nfjJobDag
.
edgeSet
().
size
());
for
(
DefaultEdge
e
:
nfjJobDag
.
edgeSet
())
{
for
(
DefaultEdge
e
:
nfjJobDag
.
edgeSet
())
{
Job
target
=
nfjJobDag
.
getEdgeTarget
(
e
);
Job
target
=
nfjJobDag
.
getEdgeTarget
(
e
);
Job
source
=
nfjJobDag
.
getEdgeSource
(
e
);
Job
source
=
nfjJobDag
.
getEdgeSource
(
e
);
if
(!
jobDagFromTree
.
containsEdge
(
source
,
target
))
{
drawGraph
(
jobDag
);
}
assertTrue
(
jobDagFromTree
.
containsEdge
(
source
,
target
));
assertTrue
(
jobDagFromTree
.
containsEdge
(
source
,
target
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment