Example #1
0
def pdf_points():
    topology = 'topos/eon.simpltopo.txt'
    wavelengths = 16
    iterations = 100000
    departures = 1

    curves = (
        ("FF", {}),
        ("FF - Adaptive", {}),
        ("FF/LF - Adaptive", {}),
        ("FF/LF/2 - Adaptive", {}),
        ("MinCost - Adaptive", {})
    )

    # Sulle x la distance
    # Sulle y interference

    x = []
    with open("pdf-all.txt", "w+") as f:
        for load in xrange(80, 151, 10):
            for idx, method in enumerate(curves):
                sim = Simulator(topology, wavelengths, iterations, load, departures, idx, None)
                distances, interferences = sim.run(wantpdf=True)

                for d, i in zip(distances, interferences):
                    f.write("%d %d %.20f\n" % (idx, d, i))
Example #2
0
def interference():
    topology = 'topos/eon.simpltopo.txt'
    wavelengths = 16
    iterations = 200000
    departures = 1

    curves = (
        ("FF", []),
        ("FF - Adaptive", []),
        ("FF/LF - Adaptive", []),
        ("FF/LF/2 - Adaptive", []),
        ("MinCost - Adaptive", [])
    )

    x = []

    #for i in xrange(64, 151):
    for i in xrange(80, 151, 10):
        x.append(i)

        for method, (label, points) in enumerate(curves):
            sim = Simulator(topology, wavelengths, iterations, i, departures, method, 0)
            stats = sim.run()

            points.append((stats[0], stats[-1]))

    f = open('graph.py', 'w+')
    f.write("from pylab import *\nfrom matplotlib import rc\n")
    f.write("rc('text', usetex=True)\nrc('font', family='serif')\nfigure()\n")
    f.write("x = " + repr(x) + "\n")

    colors = ('k', 'r', 'g', 'b', 'm')
    labels = map(lambda x: x[0], curves)

    for idx, (label, points) in enumerate(curves):
        y = map(lambda x: x[0], points)
        e = map(lambda x: x[1], points)
        f.write(("y%d = " % idx) + repr(y) + "\n")
        f.write(("e%d = " % idx) + repr(e) + "\n")
        f.write("errorbar(x, y%d, yerr=e%d, ls='-', fmt='%s.')\n" % (idx, idx, colors[idx]))

    f.write("grid(True)\n")
    f.write("xlabel(r'\\textit{Traffic load (Erlang)}')\n")
    f.write("ylabel(r'\\textit{Average interference level}')\n")
    f.write("legend(" + repr(labels) + ", loc=4)\n")
    f.write("savefig('graph.eps')\n")
    f.write("show()\n")
    f.close()