run_simple_tests.py 2.65 KB
Newer Older
Thomas Fenz's avatar
Thomas Fenz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
"""
ENVIRONMENT DEFINITION:
 - solution (objective) := sum of path length d[i,j] * demand size D[i,j]
 - static topology 's' := {(i, j): link_weight}
        NOTE: if (i,j) not in topology_static => link is not existing (link_weight is infinite)
 - optical topology 'o' := {(R, i, j): link_weight}
        with optical switch index R;
        NOTE: Optical links are treated as directed links
        NOTE: if (i,j) not in topology_optical => link is not existing (link_weight is infinite)
 - demands 'D' := {(i, j): packet_length}
 """

import simple_data_set1 as data1
import simple_data_set2 as data2

import ilp_undirected
import ilp_directed
import demand_first_directed
import gain_demand_directed
import gain_update_directed
import greedy_links_directed
import demand_first_undirected
import gain_demand_undirected
import gain_update_undirected
import greedy_links_undirected
import segregated_directed
import segregated_undirected

data_mapping = [
    {
        'name': 'DATA SET 1',
        'data': data1
    },
    {
        'name': 'DATA SET 2',
        'data': data2
    }
]

algorithm_mapping = [
    {
        'name': 'Demand First (directed)',
        'algorithm': demand_first_directed
    },
    {
        'name': 'Gain Demand (directed)',
        'algorithm': gain_demand_directed
    },
    {
        'name': 'Gain Update (directed)',
        'algorithm': gain_update_directed
    },
    {
        'name': 'Greedy Links (directed)',
        'algorithm': greedy_links_directed
    },
    {
        'name': 'Heuristics Segregated (directed)',
        'algorithm': segregated_directed
    },
    {
        'name': 'Ilp (directed)',
        'algorithm': ilp_directed
    },
    {
        'name': 'Demand First (undirected)',
        'algorithm': demand_first_undirected
    },
    {
        'name': 'Gain Demand (undirected)',
        'algorithm': gain_demand_undirected
    },
    {
        'name': 'Gain Update (undirected)',
        'algorithm': gain_update_undirected
    },
    {
        'name': 'Greedy Links (undirected)',
        'algorithm': greedy_links_undirected
    },
    {
        'name': 'Heuristics Segregated (undirected)',
        'algorithm': segregated_undirected
    },
    {
        'name': 'Ilp (undirected)',
        'algorithm': ilp_undirected
    }
]

for data_item in data_mapping:
    print(data_item['name'])
    D = data_item['data'].get_demands()
    s = data_item['data'].get_static_topology()
    o = data_item['data'].get_optical_topology()

    for algorithm_item in algorithm_mapping:
        success, error_msg, solution = algorithm_item['algorithm'].solve(s, o, D)
        print('\t%s' % algorithm_item['name'])
        print('\tsolution: %.1f' % solution)