Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
User expired
2018s-advanced-distributed-systems
Commits
d77735cf
Unverified
Commit
d77735cf
authored
Dec 03, 2018
by
Bennett Piater
Browse files
add working parser to build the graph
parent
673a597b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
+99
-0
schedulor/dependencies.dot
schedulor/dependencies.dot
+19
-0
schedulor/parser.py
schedulor/parser.py
+60
-0
schedulor/taskgraph.py
schedulor/taskgraph.py
+20
-0
No files found.
schedulor/dependencies.dot
0 → 100644
View file @
d77735cf
digraph
dependencies
{
0
->
7
1
->
8
2
->
9
3
->
10
4
->
11
5
->
12
6
->
13
{
7
,
8
,
9
,
10
,
11
,
12
,
13
}
->
14
14
->
{
15
,
16
,
17
,
18
,
19
,
20
,
21
}
15
->
22
16
->
23
17
->
24
18
->
25
19
->
26
20
->
27
21
->
28
{
22
,
23
,
24
,
25
,
26
,
27
,
28
}
->
29
}
schedulor/parser.py
0 → 100644
View file @
d77735cf
#!/usr/bin/env python3
# use http://www.mypy-lang.org/ for static type checking
from
taskgraph
import
Task
from
typing
import
List
def
parse_machine_prices
(
fname
:
str
)
->
List
[
float
]:
with
open
(
fname
,
"r"
)
as
f
:
f
.
readline
()
# ignore header
lines
=
f
.
readlines
()
# ignore machine type
return
[
float
(
line
.
split
(
','
)[
1
])
for
line
in
lines
]
def
parse_durations_on_machines
(
fname
:
str
)
->
List
[
List
[
float
]]:
result
=
[]
with
open
(
fname
,
"r"
)
as
f
:
f
.
readline
()
# ignore header
lines
=
f
.
readlines
()
for
line
in
lines
:
line_list
=
line
.
split
(
','
)
line_list
.
pop
(
0
)
# ignore task id
result
.
append
([
float
(
i
)
for
i
in
line_list
])
return
result
def
parse_traffic_relation
(
fname
:
str
)
->
List
[
List
[
int
]]:
result
=
[]
with
open
(
fname
,
'r'
)
as
f
:
f
.
readline
()
# ignore header
lines
=
f
.
readlines
()
for
line
in
lines
:
line_list
=
line
.
split
(
','
)
line_list
.
pop
(
0
)
# ignore task id
result
.
append
([
int
(
i
)
if
not
i
in
[
""
,
"
\n
"
]
else
0
for
i
in
line_list
])
return
result
def
parse_tasks
()
->
List
[
Task
]:
durations
=
parse_durations_on_machines
(
"task_time_instance.csv"
)
traffic
=
parse_traffic_relation
(
"traffic_relation.csv"
)
# transpose traffic to get predecessors
trafficT
:
List
[
List
[
int
]]
=
list
(
map
(
list
,
zip
(
*
traffic
)))
tasks
=
[]
for
node
,
parents
in
enumerate
(
trafficT
):
durationList
=
durations
[
node
]
predecessors
=
[(
p
,
b
)
for
p
,
b
in
enumerate
(
parents
)
if
b
>
0
]
tasks
.
append
(
Task
(
node
,
durationList
,
predecessors
))
return
tasks
if
__name__
==
"__main__"
:
print
(
parse_tasks
())
schedulor/taskgraph.py
0 → 100644
View file @
d77735cf
from
typing
import
List
,
Tuple
Node
=
int
class
Task
(
object
):
"""Docstring for Task. """
def
__init__
(
self
,
node
:
Node
,
durationOnMachines
:
List
[
float
],
predecessorsAndBandwidth
:
List
[
Tuple
[
Node
,
int
]]):
self
.
node
=
node
self
.
durationOnMachines
=
durationOnMachines
self
.
predecessors
=
predecessorsAndBandwidth
self
.
inDegree
:
int
=
len
(
predecessorsAndBandwidth
)
self
.
scheduledOn
=
None
self
.
startTime
=
None
self
.
endTime
=
None
def
__repr__
(
self
):
return
"{}: {}"
.
format
(
self
.
node
,
self
.
predecessors
)
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