Esempio n. 1
0
def exp_5_profile():
    """

    """
    scales = lab.linspace(0.0, 0.1, 10)
    route_tts = defaultdict(lambda: list())
    for scale in scales:
        net = MinTTTFlowLinkComplacencyProblem.load('../networks/exps/exp5/net_nash.json')
        net.scale = scale
        net.get_program().cr_solve()
        net.realize()
        for route in net.all_routes():
            route_tts[tuple(route.name())].append(net.route_travel_time(route))
    latex_figure()
    # lab.xscale("log")
    lab.hold(True)
    for route, values in route_tts.iteritems():
        lab.plot(scales, values,next(line_cycler), label='rte {0}'.format(route[1]), linewidth=3.0)
    route_tts = defaultdict(lambda: list())
    for scale in scales:
        net = MinTTTFlowLinkComparativeComplacencyProblem.load('../networks/exps/exp5/net_nash.json')
        net.scale = scale
        net.get_program().cr_print()
        net.get_program().cr_solve()
        net.realize()
        for route in net.all_routes():
            route_tts[tuple(route.name())].append(net.route_travel_time(route))
    for route, values in route_tts.iteritems():
        lab.plot(scales, values,next(line_cycler), label='rte {0}: comp.'.format(route[1]))
    lab.ylabel('Route latency $\\ell_r$ (s)')
    lab.xlabel('Complacency scale factor $\\alpha$ (-)')
    lab.title('Comparison of route latencies')
    lab.legend(loc=7)
    lab.savefig('figures/complacency_models_simple_network.pdf')
Esempio n. 2
0
def n_routes():
    net = CTMStaticProblem.load("data/data_fixed.json")
    net.cache_props()
    latex_figure()
    pylab.hist([len(routes) for routes in net.od_routes.itervalues()], bins=7, align="mid", range=(-0.5, 6.5))
    pylab.title("Number of available routes between o-d pairs")
    pylab.xlabel("Number of routes between o-d pair (-)")
    pylab.ylabel("Count (-)")
    pylab.savefig("figures/available_routes.pdf")
Esempio n. 3
0
def congestion_level():
    net = CTMStaticProblem.load("data/data_fixed_again.json")
    net.cache_props()
    latex_figure()
    pylab.hist([link.congestion_level() for link in net.get_links()], bins=50, range=(0, 1), normed=True)
    pylab.title("Congestion levels of input data")
    pylab.xlabel("Congestion level (-)")
    pylab.ylabel("Normalized counts (-)")
    pylab.savefig("figures/congestion_level.pdf")
Esempio n. 4
0
def difference_stuff():
    prev = CTMStaticProblem.load("data/jdr_with_state.json")
    final = CTMStaticProblem.load("data/data_fixed_again.json")
    latex_figure()
    pylab.hist(
        [
            abs(p.state.flow - f.state.flow) / (p.state.flow)
            for p, f in [
                (prev.link_by_name(lid), final.link_by_name(lid))
                for lid in set([link.name for link in prev.get_links()])
            ]
        ],
        bins=20,
    )
    pylab.title("Relative change in link flow input")
    pylab.xlabel("Relative change (-)")
    pylab.ylabel("Count (-)")
    pylab.savefig("figures/data_fixer_difference_flow.pdf")
    latex_figure()
    pylab.hist(
        [
            abs(p.state.density - f.state.density) / (p.state.density)
            for p, f in [
                (prev.link_by_name(lid), final.link_by_name(lid))
                for lid in set([link.name for link in prev.get_links()])
            ]
        ],
        bins=20,
    )
    pylab.title("Relative change in link density input")
    pylab.xlabel("Relative change (-)")
    pylab.ylabel("Count (-)")
    pylab.savefig("figures/data_fixer_difference_density.pdf")

    routes = [route.name() for route in prev.all_routes()]
    latex_figure()
    pylab.hist(
        [
            abs(prev.route_travel_time(route) - final.route_travel_time(route)) / prev.route_travel_time(route)
            for route in routes
        ],
        bins=20,
        range=(0, 0.3),
    )
    pylab.title("Relative change in route travel times after data preparation")
    pylab.xlabel("Relative change (-)")
    pylab.ylabel("Count (-)")
    pylab.savefig("figures/data_fixer_difference_route.pdf")