Exemple #1
0
def interd_quiet_grids():

    graphs.GRAPH_OUTPUT_FORMAT = 'png'
    def init_simwrap():
        sim = SimWrap(ctrl, p, cdict, pdict);
        sim.set_all_nodisp()
        sim.TO_show_clusters = False
        sim.ctrl.saveall = False
        return sim

    def graph_mods():
        ax.set_xlabel('Meters')
        ax.set_ylabel('Meters')
        ax.set_aspect('equal')


    # Random grid
    graphs.change_fontsize(graphs.FONTSIZE + 2)
    ctrl, p, cdict, pdict = dec_grids()
    ctrl.quiet_selection = 'random'
    ctrl.quiet_nodes = ctrl.nodecount - 5
    ctrl.steps = 1
    sim = init_simwrap()
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore")
        sim.simulate()
    ax = graphs.spatial_grid(ctrl, unit='m', s=12, show_broadcast=True)
    graph_mods()
    graphs.save('interd_grid_random')
    graphs.show()

    # cluster grid
    ctrl, p, cdict, pdict = dec_grids()
    ctrl.quiet_selection = 'kmeans'
    ctrl.quiet_nodes = ctrl.nodecount - 5
    ctrl.steps = 1
    sim = init_simwrap()
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore")
        sim.simulate()
    ax = graphs.spatial_grid(ctrl, unit='m', s=12, show_broadcast=True)
    graph_mods()
    graphs.save('interd_grid_kmeans')
    graphs.show()

    # sensing grid
    ctrl, p, cdict, pdict = dec_grids()
    ctrl.quiet_selection = 'contention'
    ctrl.steps = 40
    sim = SimWrap(ctrl, p, cdict, pdict);
    sim.TO_show_clusters = False
    sim.ctrl.saveall = False
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore")
        sim.simulate()
    ax = graphs.spatial_grid(ctrl, unit='m', s=12, show_broadcast=True)
    graph_mods()
    graphs.save('interd_grid_sensing')
    graphs.show()
Exemple #2
0
def sample_theta():
    """Sample N=20 theta evolution"""
    ctrl, p, cdict, pdict = dec_regimes()
    sim = SimWrap(ctrl, p, cdict, pdict)

    sim.ctrl.keep_intermediate_values = True
    sim.show_CFO = False
    sim.set_all_nodisp()
    sim.show_TO = False
    sim.simulate()
    ax, _ = sim.post_sim_plots(save_TO='', save_CFO='')
Exemple #3
0
 def init_simwrap():
     sim = SimWrap(ctrl, p, cdict, pdict);
     sim.set_all_nodisp()
     sim.TO_show_clusters = False
     sim.ctrl.saveall = False
     return sim
Exemple #4
0
def interd_compare_r12():
    graphs.change_fontsize(graphs.FONTSIZE + 2)
    ctrl, p, cdict, pdict = dec_dpll()
    sim = SimWrap(ctrl, p, cdict, pdict)
    sim.TO_show_clusters = False

    sim.ctrl.saveall = False
    sim.simulate()
    sim.post_sim_plots(save_TO='dpll_theta_evol')

    ctrl, p, cdict, pdict = dec_r12()
    sim = SimWrap(ctrl, p, cdict, pdict)
    sim.TO_show_clusters = False
    sim.ctrl.saveall = False
    sim.simulate()
    sim.post_sim_plots(save_TO='r12_theta_evol')
Exemple #5
0
def highlited_regimes():
    """Highlights the converging vs the drift regime"""
    compare_fontsize = 15
    compare_aspect=12
    props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)

    fontsize_tmp = graphs.FONTSIZE
    def run_hair_graph(aspect='auto'):
        hair_kwargs = {'y_label':r'$\theta_i$ $(T_0)$', 'show_clusters':False, 'savename':''}
        hair_args = (
                (ctrl.sample_inter , ctrl.theta_inter, ctrl),
                hair_kwargs,
        )
        ax =  graphs.hair(*hair_args[0], **hair_args[1])
        ax.set_aspect(aspect)
        return ax

    # DRIFT REGIME
    graphs.change_fontsize(compare_fontsize)
    ctrl, p, cdict, pdict = dec_sample_theta()
    sim = SimWrap(ctrl, p, cdict, pdict)

    sim.conv_min_slope_samples = 15 
    sim.ctrl.keep_intermediate_values = True
    sim.simulate()
    ax = run_hair_graph(aspect=compare_aspect)
    ax.text(0.85, 0.9, 'No DC', transform=ax.transAxes, fontsize=compare_fontsize, verticalalignment='top', bbox=props) 
    xmid = 12
    xmax = ctrl.steps-13
    xmin = 0
    ymin, ymax = ax.get_ylim()
    ya = ymin-0.06
    ax.set_xlim([xmin,xmax])
    ax.set_ylim([ya,ymax])
    fname = 'latex_figures/init_theta'
    graphs.save(fname)
    graphs.show()

    del ax
    graphs.change_fontsize(15)
    ax = run_hair_graph()
    
    # Draw biarrows
    ax.annotate('', xy=(xmid, ya), xycoords='data',
                xytext=(xmin, ya), textcoords='data',
                arrowprops=dict(arrowstyle="<->"))
    ax.annotate('', xy=(xmax, ya), xycoords='data',
                xytext=(xmid, ya), textcoords='data',
                arrowprops=dict(arrowstyle="<->"))
    ax.plot([xmid, xmid], [ya-1, ymax], 'k--')

    # text
    ax.text(xmid/2, ya, 'Transient', ha='center', va='bottom' )
    ax.text((xmax-xmid)/2 +xmid, ya, 'Drifting', ha='center', va='bottom' )

    ax.set_xlim([xmin,xmax])
    ax.set_ylim([ya-0.03,ymax])

    fname = 'latex_figures/highlighted_regimes'
    graphs.save(fname)
    graphs.show()

    # THETA EXAMPLE
    graphs.change_fontsize(compare_fontsize)
    ctrl, p, cdict, pdict = dec_sample_theta()
    ctrl.prop_correction = True
    sim = SimWrap(ctrl, p, cdict, pdict)

    sim.conv_min_slope_samples = 15 
    sim.ctrl.keep_intermediate_values = True
    sim.show_CFO = False
    sim.show_TO = False
    sim.make_cat = False
    sim.simulate()
    ax = run_hair_graph(aspect=compare_aspect)
    ax.text(0.85, 0.9, 'Q = 7', transform=ax.transAxes, fontsize=compare_fontsize, verticalalignment='top', bbox=props) 

    ax.set_xlim([xmin,xmax])
    ax.set_ylim([ya,ymax])

    fname = 'latex_figures/example_theta'
    graphs.save(fname)
    graphs.show()

    # THETA EXAMPLE with Q=14
    graphs.change_fontsize(compare_fontsize)
    ctrl, p, cdict, pdict = dec_sample_theta()
    ctrl.prop_correction = True
    ctrl.pc_b, ctrl.pc_a = lib.hipass_avg(14)
    sim = SimWrap(ctrl, p, cdict, pdict)

    sim.conv_min_slope_samples = 15 
    sim.ctrl.keep_intermediate_values = True
    sim.show_CFO = False
    sim.show_TO = False
    sim.make_cat = False
    sim.simulate()
    ax = run_hair_graph(aspect=compare_aspect)
    ax.text(0.85, 0.9, 'Q = 14', transform=ax.transAxes, fontsize=compare_fontsize, verticalalignment='top', bbox=props) 

    ax.set_xlim([xmin,xmax])
    ax.set_ylim([ya,ymax])

    fname = 'latex_figures/example_theta_q14'
    graphs.save(fname)
    graphs.show()


    
    graphs.change_fontsize(fontsize_tmp)