Unverified Commit c73c9883 authored by Bennett Piater's avatar Bennett Piater
Browse files

formatting

parent 1582cde1
......@@ -3,10 +3,12 @@ from typing import List
from parser import parse_tasks, parse_machine_prices
from preprocessing import *
def main():
tasks = parse_tasks()
parallel_width_estimate = parallel_width_assuming_mapreduce(tasks)
# print(parallel_width_estimate)
if __name__ == "__main__":
main()
......@@ -4,42 +4,47 @@ 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
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
f.readline() # ignore header
lines = f.readlines()
for line in lines:
line_list = line.split(',')
line_list.pop(0) # ignore task id
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
f.readline() # ignore header
lines = f.readlines()
for line in lines:
line_list = line.split(',')
line_list.pop(0) # ignore task id
line_list.pop(0) # ignore task id
result.append([int(i) if not i in ["", "\n"] else 0 for i in line_list])
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")
......
from typing import List, Tuple
Node = int
class Task(object):
class Task(object):
"""Docstring for Task. """
def __init__(self, node: Node, durationOnMachines: List[float], predecessorsAndBandwidth: List[Tuple[Node, int]]):
def __init__(self, node: Node, durationOnMachines: List[float],
predecessorsAndBandwidth: List[Tuple[Node, int]]):
self.node = node
self.durationOnMachines = durationOnMachines
......
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 to comment