Exemplo n.º 1
0
def test_schedule():
    orders, jobson = schedule(dag, 'abc', compcost, commcost)
    a = jobson[4]
    b = jobson[3]
    c = (set('abc') - set((a, b))).pop()
    print a, b, c
    print orders
    assert orders == {a: [Event(4, 0, 4), Event(6, 4, 10),
                          Event(7, 11, 18), Event(9, 18, 27)],
                      b: [Event(3, 0, 3), Event(5, 3, 8), Event(8, 21, 29)],
                      c: []}
Exemplo n.º 2
0
def test_task_insertion_at_start():
    dag = {9: (10, 11), # some very high rank tasks which all depend on one
           10: (),      # initial task.
           11: (),

           1: (), # one low rank but cheap tasks
          }

    orders, _ = schedule(dag, 'ab', compcost, zero_commcost)

    # The cheap task 1 should be done on the spare processor while we are
    # waiting for task 9 to finish on the first one.
    assert find_job_event(1, orders).end == 1
Exemplo n.º 3
0
def test_task_insertion_at_start():
    dag = {
        9: (10, 11),  # some very high rank tasks which all depend on one
        10: (),  # initial task.
        11: (),
        1: (),  # one low rank but cheap tasks
    }

    orders, _ = schedule(dag, 'ab', compcost, zero_commcost)

    # The cheap task 1 should be done on the spare processor while we are
    # waiting for task 9 to finish on the first one.
    assert find_job_event(1, orders).end == 1
Exemplo n.º 4
0
def test_task_insertion_in_middle():
    dag = {
        9: (10, 11),  # some very high rank tasks which all depend on one
        10: (),  # initial task.
        11: (),
        1: (),  # multiple low rank but cheap tasks
        2: (),
    }

    orders, _ = schedule(dag, 'ab', compcost, zero_commcost)

    print(orders)
    print(find_job_event(2, orders))

    # Both of the cheap tasks (1 and 2) should be done on the second
    # processor while we are waiting for task 9 to finish on the first one
    assert find_job_event(1, orders).end == 3
    assert find_job_event(2, orders).end == 2
Exemplo n.º 5
0
def test_task_insertion_in_middle():
    dag = {9: (10, 11), # some very high rank tasks which all depend on one
           10: (),      # initial task.
           11: (),

           1: (), # multiple low rank but cheap tasks
           2: (),
          }

    orders, _ = schedule(dag, 'ab', compcost, zero_commcost)

    print orders
    print find_job_event(2, orders)

    # Both of the cheap tasks (1 and 2) should be done on the second
    # processor while we are waiting for task 9 to finish on the first one
    assert find_job_event(1, orders).end == 3
    assert find_job_event(2, orders).end == 2
Exemplo n.º 6
0
            return 11
        if(ni==1 and nj==6):
            return 14
        if(ni==2 and nj==8):
            return 19
        if(ni==2 and nj==9):
            return 16
        if(ni==3 and nj==7):
            return 23
        if(ni==4 and nj==8):
            return 27
        if(ni==4 and nj==9):
            return 23
        if(ni==5 and nj==9):
            return 13
        if(ni==6 and nj==8):
            return 15
        if(ni==7 and nj==10):
            return 17
        if(ni==8 and nj==10):
            return 11
        if(ni==9 and nj==10):
            return 13
        else:
            return 0

orders, jobson = schedule(dag, 'abc', compcost, commcost)
for eachP in sorted(orders):
    print(eachP,orders[eachP])
print(jobson)
Exemplo n.º 7
0
def test_one_agent():
    orders, jobson = schedule(dag, ['A'], compcost, commcost)
    assert orders.keys() == ['A']
    assert set(e.job for e in orders['A']) == set((3, 4, 5, 6, 7, 8, 9))
    assert jobson == {i: 'A' for i in (3, 4, 5, 6, 7, 8, 9)}
Exemplo n.º 8
0
def test_one_agent():
    orders, jobson = schedule(dag, ['A'], compcost, commcost)
    assert orders.keys() == ['A']
    assert set(e.job for e in orders['A']) == set((3,4,5,6,7,8,9))
    assert jobson == {i: 'A' for i in (3,4,5,6,7,8,9)}
Exemplo n.º 9
0
    19: (),
    20: (),
    21: ()
}


def compcost(job, agent):
    if (job == 0):
        return 1
    if (job == 1):
        return 1
    if (job == 2):
        return 1
    if (job == 3):
        return 1
    return 1


def commcost(ni, nj, A, B):
    if (A == B):
        return 0
    else:
        return 0


orders, jobson = schedule(a3, 'abcd', compcost, commcost)

for eachP in sorted(orders):
    print(eachP, orders[eachP])
print(jobson)
Exemplo n.º 10
0
                            if n['link'] == 'input':
                                jdict.update({n['file']: n['size']})
                for k in idict:
                    for p in jdict:
                        if k == p:
                            size += int(jdict[p])
                if size != 0:
                    break
        time = int(size/1024)
        return time
# print(commcost('ID00000','ID00005','A','B'))
        # link = "output" size="4167312" file="region.hdr

vm = 'abcdef'

orders, jobson = schedule(dag, vm, compcost, commcost)
"""print orders"""
for eachP in sorted(orders):
    print(eachP, orders[eachP])
# print(orders['a'][0][0],orders['a'][0][1],orders['a'][0][2])
# print(jobson)
# print(makespan(orders))

def getorders():
    return orders


def getvm():
    return vm