Ejemplo n.º 1
0
def reuse_perflines(results_trios, y_max=360000, extremes=(0, 100), show=True, **kwargs):
    figs = []
    for nor_results, src_results, tgt_results in results_trios:
        nor_cfg = nor_results.expcfg
        tgt_cfg = tgt_results.expcfg

        f = graphs.perf_lines(
            nor_results,
            color=graphs.NOREUSE_COLOR,
            plot_width=900,
            plot_height=450,
            x_range=(0, tgt_cfg.exploration.steps),
            y_range=(0, y_max),
            title="{}".format(tgt_results.key),
            minimalist=False,
            **kwargs
        )

        graphs.perf_lines(tgt_results, fig=f, color=graphs.REUSE_COLOR)
        figs.append(f)

    fig = graphs.vplot(figs)
    if show:
        graphs.show(fig)
    else:
        return fig
Ejemplo n.º 2
0
def reuse_coverage(data, milestones=(200, 1000), testname='tcov', e_radius=3.0,
                   nor=True, src=True, tgt=True, show=True, **kwargs):
    figs = []
    titles = ['no reuse', 'source', 'target']
    for i, (d, flag) in enumerate(zip(data, (nor, src, tgt))):
        if flag and d is not None:
            figs.append([])
            try:
                K_boot = d['jobcfg'].exploration.explorer.eras[0]
            except KeyError:
                K_boot = 200
            s_vectors = d['s_vectors']

            radius = d.expcfg.tests[testname].buffer_size
            for t in milestones:
                fig = graphs.coverage(d['s_channels'], radius,
                                      s_vectors=s_vectors[:t], swap_xy=False,
                                      plot_width=400, plot_height=400,
                                      title='{} {}'.format(titles[i], t), **kwargs)
                graphs.spread(d['s_channels'], s_vectors=s_vectors[:K_boot], fig=fig,
                              swap_xy=False, e_alpha=1.0, e_color=RED,
                              radius_units='data', e_radius=radius/4.0)
                graphs.spread(d['s_channels'], s_vectors=s_vectors[K_boot:t], fig=fig,
                              swap_xy=False, e_alpha=1.0,
                              radius_units='data', e_radius=radius/4.0)

                figs[-1].append(fig)

    if show:
        graphs.show(figs)
    else:
        return figs
Ejemplo n.º 3
0
def reuse_coverage(
    data, milestones=(200, 1000), testname="tcov", e_radius=3.0, nor=True, src=True, tgt=True, show=True, **kwargs
):
    figs = []
    titles = ["no reuse", "source", "target"]
    for i, (d, flag) in enumerate(zip(data, (nor, src, tgt))):
        if flag and d is not None:
            figs.append([])
            try:
                K_boot = d["jobcfg"].exploration.explorer.eras[0]
            except KeyError:
                K_boot = 200
            s_vectors = d["s_vectors"]

            radius = d.expcfg.tests[testname].buffer_size
            for t in milestones:
                fig = graphs.coverage(
                    d["s_channels"],
                    radius,
                    s_vectors=s_vectors[:t],
                    swap_xy=False,
                    plot_width=400,
                    plot_height=400,
                    title="{} {}".format(titles[i], t),
                    **kwargs
                )
                graphs.spread(
                    d["s_channels"],
                    s_vectors=s_vectors[:K_boot],
                    fig=fig,
                    swap_xy=False,
                    e_alpha=1.0,
                    e_color=RED,
                    radius_units="data",
                    e_radius=radius / 4.0,
                )
                graphs.spread(
                    d["s_channels"],
                    s_vectors=s_vectors[K_boot:t],
                    fig=fig,
                    swap_xy=False,
                    e_alpha=1.0,
                    radius_units="data",
                    e_radius=radius / 4.0,
                )

                figs[-1].append(fig)

    if show:
        graphs.show(figs)
    else:
        return figs
Ejemplo n.º 4
0
def reuse_quantiles(results_trios, y_max=360000, show=True,
                    src_quantiles=(0, 100), tgt_quantiles=(0, 100)):
    figs = []

    for nor_results, src_results, tgt_results in results_trios:
        nor_cfg = nor_results.expcfg
        tgt_cfg = tgt_results.expcfg

        f = graphs.perf_quantiles(nor_results, dashed_quant=src_quantiles,
                                  color=graphs.NOREUSE_COLOR, plot_width=900, plot_height=450,
                                  x_range=(0, tgt_cfg.exploration.steps), y_range=(0, y_max),#3.268),
                                  title='{}'.format(tgt_results.job.key))
        graphs.perf_quantiles(tgt_results, fig=f, dashed_quant=tgt_quantiles, color=graphs.REUSE_COLOR)
        figs.append([f])

    if show:
        graphs.show(figs)
    else:
        return figs
Ejemplo n.º 5
0
def reuse_perflines(results_trios, y_max=360000, extremes=(0, 100), show=True, **kwargs):
    figs = []
    for nor_results, src_results, tgt_results in results_trios:
        nor_cfg = nor_results.expcfg
        tgt_cfg = tgt_results.expcfg

        f = graphs.perf_lines(nor_results,
                              color=graphs.NOREUSE_COLOR, plot_width=900, plot_height=450,
                              x_range=(0, tgt_cfg.exploration.steps), y_range=(0, y_max),
                              title='{}'.format(tgt_results.key), minimalist=False, **kwargs)

        graphs.perf_lines(tgt_results, fig=f,
                           color=graphs.REUSE_COLOR)
        figs.append(f)

    fig = graphs.vplot(figs)
    if show:
        graphs.show(fig)
    else:
        return fig
Ejemplo n.º 6
0
def reuse_quantiles(results_trios, y_max=360000, show=True, src_quantiles=(0, 100), tgt_quantiles=(0, 100)):
    figs = []

    for nor_results, src_results, tgt_results in results_trios:
        nor_cfg = nor_results.expcfg
        tgt_cfg = tgt_results.expcfg

        f = graphs.perf_quantiles(
            nor_results,
            dashed_quant=src_quantiles,
            color=graphs.NOREUSE_COLOR,
            plot_width=900,
            plot_height=450,
            x_range=(0, tgt_cfg.exploration.steps),
            y_range=(0, y_max),  # 3.268),
            title="{}".format(tgt_results.job.key),
        )
        graphs.perf_quantiles(tgt_results, fig=f, dashed_quant=tgt_quantiles, color=graphs.REUSE_COLOR)
        figs.append([f])

    if show:
        graphs.show(figs)
    else:
        return figs
Ejemplo n.º 7
0

for ex_name in ['random.goal']:
    random.seed(0)

    # instanciating the environment
    env_name, env_cfg = envs.kin(dim=DIM, limit=LIMIT)
    env = environments.Environment.create(env_cfg)

    # instanciating the explorer
    ex_cfg = exs.catalog[ex_name]._deepcopy()
    ex_cfg.m_channels = env.m_channels
    ex_cfg.s_channels = env.s_channels
    ex = explorers.Explorer.create(ex_cfg)

    # running exploration
    explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N, verbose=True)

    # making graphs
    for t1, t2 in [(0, 100), (100, N)]:
        alpha = 1.0 if t2 == 100 else 0.25
        graphs.posture_random(env, explorations[t1:t2], n=10,
                              alpha=0.75, radius_factor=0.35)
        graphs.hold(True)
        graphs.bokeh_spread(env.s_channels, s_vectors=s_vectors[:t2],
                            e_radius=1.5, e_alpha=alpha,
                            x_range=(-1.05, 1.05), y_range=(-1.05, 1.05),
                            title='{}::{}'.format(ex_name, env_name))

graphs.show()
Ejemplo n.º 8
0
def main():
    g = gr.import_graph("graph.txt")
    g1 = gr.random_graph()
    s = antenes(g1)
    print(s)
    gr.show(g1)
Ejemplo n.º 9
0
DIM = 20
N   = 5000


# preparing graphs
graphs.output_file('ddmab.html')

for disturb in [0.001, 0.002, 0.05, 0.5]:
    random.seed(0)

    # instanciating the environment
    env_name, env_cfg = envs.kin(dim=DIM, limit=150)
    env = environments.Environment.create(env_cfg)

    # instanciating the explorer
    ex_cfg = ddmab_ex.ex_cfg._deepcopy()
    ex_cfg.ex_1.learner.m_disturb = disturb
    ex_cfg.m_channels = env.m_channels
    ex_cfg.s_channels = env.s_channels
    ex = explorers.Explorer.create(ex_cfg)

    # running the exploration
    explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

    # making graphs
    for i, weights in enumerate(ex.weight_history['data']):
        ex.weight_history['data'][i] = [1000*w for w in weights]
    graphs.adapt_graphs(ex.cfg, explorations, s_vectors, ex.weight_history, title='{}'.format(disturb))

graphs.show()
Ejemplo n.º 10
0
# In[ ]:

figures = []

for arm in [arm2, arm7, arm20, arm100]:
    history = explore_rmb(
        arm, N)  # running the RMB exploration strategy for N steps.

    figures.append(
        graphs.effects(history,
                       show=False,
                       title='motor babbling, {}-joint arm'.format(arm.dim)))

graphs.show([
    [figures[0], figures[1]],  # displaying figures.
    [figures[2], figures[3]]
])

# Each blue dot is the position reached by the tip of the arm during the execution of a motor command.
#
# The random motor babbling strategy does rather well on the 2-joint arm. But as the number of joints increases, the distribution of the effects covers less and less of the approximate reachable area represented by the grey disk. Even after numerous samples of the 7, 20 and 100-joint arms, we don't have a good empirical estimation of the reachable space.

# ## Goal Babbling

# Motor babbling explores the possibilities offered by the arm by exploring the *motor space*: the choice of which motor command to execute is done by choosing a point in the motor space.
#
# Another strategy is to explore not the motor space but the sensory space, i.e., the space of effects. *Goal babbling* does exactly this: choose a point in the effect space, consider it as a goal to be reached, and try to find a motor command to reach that goal. We still produce a motor command to execute, but the *choice* of that motor command is done in the sensory space.
#
# Implementing the goal babbling strategy raises two problems:
# 1. How to find a motor command to reach a specific goal?
# 2. How goals are chosen?