Beispiel #1
0
def coverage_graphs(expcfgs_levels, dest='tmp.html', n_graphs=3):
    cwd = os.getcwd()
    graphs.output_file(dest)

    red = '#DF6464'

    for level in expcfgs_levels:
        for i, exp_cfg in enumerate(level):
            n = 0
            batch = jobfactory.make_jobgroup([exp_cfg])
            os.chdir(os.path.expanduser(exp_cfg.meta.rootpath))

            data_hub = hub.DataHub(batch, sensory_only=True)
            datas = data_hub.data()

            for j, data in enumerate(datas):
                if n_graphs is None or n < n_graphs:
                    for N in [200, 1000]:
                        print(exp_cfg.exploration.explorer)
                        n_reuse = exp_cfg.exploration.explorer.eras[0]
                        s_vectors = [
                            tools.to_vector(s_signal, data.s_channels)
                            for s_signal in data.s_signals
                        ][:N]

                        graphs.coverage(data.s_channels,
                                        exp_cfg.testscov.buffer_size,
                                        s_vectors=s_vectors,
                                        swap_xy=False,
                                        title_text_font_size='6pt',
                                        title='{} {}'.format(
                                            exp_cfg.exp.key, j))
                        graphs.hold(True)
                        graphs.spread(data.s_channels,
                                      s_vectors=s_vectors[n_reuse:],
                                      swap_xy=False,
                                      e_radius=2.0)
                        graphs.hold(True)
                        graphs.spread(data.s_channels,
                                      s_vectors=s_vectors[:n_reuse],
                                      swap_xy=False,
                                      e_radius=2.0,
                                      e_color=red)
                        n += 1

    os.chdir(cwd)
Beispiel #2
0
import dotdot
import exs
import envs
import factored
import graphs

DIM = 20
RES = 20
MB = 50
N = 5000

random.seed(0)

# making graphs
graphs.output_file('c5_fig5_2_reuse_picks.html')
timescale = [N]
mesh_colors = [
    '#E5E5E5'
]  #[graphs.rgb2hex(graphs.rgba2rgb((255, 255, 255), (233,  78, 119, 0.5)))]


def pick(meshgrid, n=1):
    assert n == 1
    picks = []
    for b in meshgrid.nonempty_bins:
        c, s_signal, m_signal = b.draw()
        picks.append((m_signal, s_signal))
    return picks

Beispiel #3
0
import explorers
import learners
import environments

import dotdot
import envs
import factored
import graphs

from c3_graphlib import adapt_graphs
import fig4_8_adapt_reach_ex

N = 5000

graphs.output_file('c4_figB_3_adaptg_reach.html')

for RES in [20, 40]:
    random.seed(0)

    # instanciating the environment
    env_name = 'kin20_150'
    env_cfg = envs.catalog[env_name]._deepcopy()
    env = environments.Environment.create(env_cfg)

    # instanciating the explorer
    ex_cfg = fig4_8_adapt_reach_ex.grid_cfg._deepcopy()
    ex_cfg.ex_1.div_algorithm = 'grid'
    ex_cfg.ex_1.res = RES
    ex_cfg.ex_1.ex_0.res = RES
    ex_cfg.ex_1.ex_1.res = RES
Beispiel #4
0
import random

from bokeh import plotting

import explorers
import environments

import dotdot
import exs
import envs
import factored
import graphs

N = 10000

graphs.output_file('c3_fig3_4_goal_distrib.html')

for env_name in ['kin2_150', 'kin20_150']:
    for ex_name, xy_range in [
        ('random.motor', 1.0),
        ('random.goal', 1.1),
        ('distrib_corner', 1.1),
        ('distrib0.5', 1.1),
        ('distrib2', 2.2),
        ('distrib10', 11.0),
    ]:
        random.seed(0)

        # instanciating the environment, and the Meshgrid
        env_cfg = envs.catalog[env_name]._deepcopy()
        env = environments.Environment.create(env_cfg)
Beispiel #5
0
# m_centers
random.seed(0)
m_centers = [(0, 0) * int(DIM / 2)]

milestones = [0, 500, N]
ranges = [80, 150, 150]

lrns = {
    'disturb': exs.learn_cfg._deepcopy(),
    #'plwlr'  : exs.plwlr_cfg._deepcopy()
}

ex_name = 'random.goal'

if __name__ == '__main__':
    graphs.output_file('c3_fig3_18_develop_random_{}.html'.format(DIM))

    for rep, m_center in enumerate(m_centers):
        for lrn_name, lrn_cfg in lrns.items():
            for milestones, ranges in [([0, 500, N], [150, 150, 150]),
                                       ([0, 500, N], [80, 150, 150])]:
                random.seed(0)

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

                ex_cfg = exs.catalog[ex_name]._deepcopy()
                ex_cfg.ex_1.learner = lrn_cfg
                ex_cfg.m_channels = env.m_channels
                ex_cfg.s_channels = env.s_channels
Beispiel #6
0
import explorers
import environments

import dotdot
import exs
import envs
import graphs
import factored

DIM = 20
RES = 20
N = 10000

# making graphs
graphs.output_file('c3_fig3_15_synergy.html')
timescale = [20000]
mesh_colors = ['#e5e5e5']

for ex_name in ['random.motor', 'random.goal']:
    for synergy in [2, None]:
        random.seed(0)

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

        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)
Beispiel #7
0
                    min_avgs[env_key] = data['avg'][index]
                    min_stds[env_key] = data['std'][index]

    for env_key in env_keys:
        ps[env_key] = sorted(ps[env_key])
        avgs[env_key] = np.array([avgs[env_key][p] for p in ps[env_key]])
        stds[env_key] = np.array([stds[env_key][p] for p in ps[env_key]])

    os.chdir(cwd)

    return env_keys, ps, avgs, stds, min_avgs, min_stds



if __name__ == '__main__':
    env_keys, ps, avgs, stds, min_avgs, min_stds = load_data('nn')

    colors = [graphs.BLUE, graphs.PINK, graphs.GREEN]
    graphs.output_file('c4_fig4_2_mbratio_perf.html')

    env_displayed = [env_key for env_key in env_keys if env_key[0] == 'kin20_150' and env_key[2] == 10000]

    for color, envd in zip(colors, env_displayed):
        print(avgs[envd])
        y_max = max(avgs[envd] + stds[envd])
        graphs.perf_std_discrete(ps[envd], avgs[envd], stds[envd], std_width=0.0035, color=color,
                                 y_range=[0.0, y_max+0.02], plot_width=1000, plot_height=500, title='{} {}'.format(*envd))
        graphs.hold(True)

    graphs.show()
Beispiel #8
0
import dotdot
import exs
import envs
import factored
import graphs

import ddmab_ex


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)
Beispiel #9
0
import copy

import explorers
import environments

import dotdot
import envs
import exs
import factored
import graphs

N = 10000
P_NOISE = 0.01

# making graphs
graphs.output_file('c3_noise.html')


def add_noise(signal, channels, p):
    """Return a noisy signal"""
    noisy_signal = copy.deepcopy(signal)
    for c, v in noisy_signal.items():
        v_min, v_max = channels[0].bounds
        noisy_signal[c] = random.uniform(max(v_min, v - p * (v_max - v_min)),
                                         min(v_max, v + p * (v_max - v_min)))
    return noisy_signal


env_name = 'kin20_150'

sm_noises = [[0.0, 0.0], [0.0, 0.01], [0.0, 0.02], [0.0, 0.05], [0.0, 0.1],
Beispiel #10
0
    batch = jobfactory.make_jobgroup([exp_cfg])
    os.chdir(os.path.expanduser(exp_cfg.meta.rootpath))

    data = hub.ResultsHub(batch, kind='nn').data()[0]
    window = exp_cfg.exploration.explorer.ex_1.window
    for N in Ns:
        index = data['ticks'].index(N)
        adapt_avgs[(window, N)] = data['avg'][index]
        adapt_stds[(window, N)] = data['std'][index]

os.chdir(cwd)

for N in Ns:
    for w in windows:
        print('N={}, w={} :  {} +- {}'.format(N, w, adapt_avgs[(w, N)], adapt_stds[(w, N)]))
    print()

if __name__ == '__main__':
    graphs.output_file('c4_fig4_9_adapt_reach_graph.html')
    for N in Ns:
        y_max = max(np.array(avgs[N]) + np.array(stds[N]))

        graphs.perf_std_discrete(ratios[N], avgs[N], stds[N], std_width=0.25, alpha=0.5,
                                 y_range=[0, y_max*1.05], title='adaptative reach performance, t = {}'.format(N))

        graphs.hold(True)
        graphs.line([0, 100], adapt_avgs[(W, N)], adapt_stds[(W, N)])
        graphs.hold(False)

    graphs.show()
Beispiel #11
0
import learners
import explorers
import environments

import dotdot
import exs
import envs
import factored
import graphs

DIM = 20
RES = 40
N = 10000

# preparing graphs
graphs.output_file('c3_fig3_11_frontier_{}.html'.format(RES))
timescale = [10, 100, 250, 500, 2000, 10000]
mesh_colors = graphs.colorscale(timescale, graphs.hex2rgb(graphs.C_COLOR),
                                0.16)

# common explorer configuration
learn_cfg = learners.DisturbLearner.defcfg._deepcopy()
learn_cfg.m_disturb = 0.05

RES = 40
_ex_cfg = explorers.MetaExplorer.defcfg._deepcopy()
_ex_cfg.eras = (10, None)

_ex_cfg.ex_0 = explorers.RandomMotorExplorer.defcfg._deepcopy()

_ex_cfg.ex_1 = explorers.MeshgridGoalExplorer.defcfg._deepcopy()
Beispiel #12
0
import explorers
import environments

import dotdot
import exs
import envs
import factored
import graphs

from c3_graphlib import adapt_graphs
import fig4_4_adapt_ex

N = 5000

# making graphs
graphs.output_file('c4_figB_1_adapt_grid.html')

#for disturb in [0.001, 0.005, 0.025, 0.05, 0.1, 0.2, 0.5, 1.0]:
for disturb in [0.001, 0.05, 0.5]:
    for res in [20, 40]:
        random.seed(0)

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

        # instanciating the explorer
        ex_cfg = fig4_4_adapt_ex.grid_cfg._deepcopy()
        ex_cfg.res = res
        ex_cfg.ex_1.learner.m_disturb = disturb
        ex_cfg.m_channels = env.m_channels
Beispiel #13
0
import explorers
import environments

import dotdot
import exs
import envs
import graphs
import factored


N        = 50000
env_name = 'kin2_150'
ex_name  = 'random.goal'

graphs.output_file('c0_fig6_kin2_gb.html'.format(int(N/1000)))


random.seed(0)

# instanciating the environment
env_cfg = envs.catalog[env_name]._deepcopy()
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)
Beispiel #14
0
        data = results_hub.data()[0]

        ex_name = exp_cfg.exp.explorer_name

        dims.setdefault(ex_name, [])
        avgs.setdefault(ex_name, [])
        stds.setdefault(ex_name, [])

        dims[ex_name].append(dim)
        avgs[ex_name].append(data['avg'][-1])
        stds[ex_name].append(data['std'][-1])
        y_max = max(y_max, data['avg'][-1] + data['std'][-1])

os.chdir(cwd)
colors = ['#2577B2', '#E84A5F']
graphs.output_file('c3_fig3_3_eval_perf.html')

for color, ex_name in zip(colors, dims.keys()):
    graphs.perf_std_discrete(dims[ex_name],
                             avgs[ex_name],
                             stds[ex_name],
                             std_width=0.25,
                             color=color,
                             title=str(ex_name),
                             x_range=[0.0, 110.0],
                             y_range=[0.0, y_max + 0.1],
                             plot_width=1000,
                             plot_height=300)
    graphs.hold(True)

graphs.show()
Beispiel #15
0
import random
import copy

import environments
import explorers

import dotdot
import factored
import graphs
import envs
import exs


N = 5000

graphs.output_file('c3_fig3_5_grid_fit.html')


for res, b, radius, tile_ratio in [(  3, 2.0, 1.3, 0.985),
                                   ( 20, 1.0, 1.3, 0.95 ),
                                   ( 40, 1.0, 1.3, 0.95 ),
                                   (100, 1.0, 1.0, 1.0  )]:
    random.seed(0)

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

    # instanciating the explorer
    ex_cfg            = exs.catalog['random.goal']._deepcopy()
    ex_cfg.eras       = (10, None)
Beispiel #16
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 = exs.catalog['random.goal']._deepcopy()
ex_cfg.m_channels = env.m_channels
ex_cfg.s_channels = env.s_channels
ex = explorers.Explorer.create(ex_cfg)

# instanciating the grid
mesh_s_channels = copy.deepcopy(env.s_channels)
mesh = explorers.ExplorerMeshGrid({'res': RES}, env.s_channels, env.m_channels)

# preparing graphs
graphs.output_file('c3_fig3_6_mesh_progression.html')
timescale = [10, 100, 250, 500, 2000, 10000]
colors = graphs.colorscale(timescale, graphs.hex2rgb(graphs.C_COLOR), 0.16)

# running the exploration
explorations, s_vectors = [], []
for t in range(N):
    exploration = ex.explore()
    feedback = env.execute(exploration['m_signal'])
    ex.receive(exploration, feedback)
    s_vectors.append(
        environments.tools.to_vector(feedback['s_signal'], env.s_channels))
    explorations.append((exploration, feedback))
    mesh.add(feedback['s_signal'])

    # making graphs
Beispiel #17
0
ex = explorers.Explorer.create(ex_cfg)

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


# Splitting the trials
s_vectors_pos, s_vectors_neg = [], []
for explo, s_vector in zip(explorations, s_vectors):
    if explo[0]['m_signal']['j0'] > 0:
        s_vectors_pos.append(s_vector)
    else:
        s_vectors_neg.append(s_vector)


graphs.output_file('c0_fig4_kin2_decomp.html')

# Positive Graph
graphs.spread(env.s_channels, s_vectors=s_vectors_pos,
              e_radius=1.0, e_alpha=0.5,
              title='{}::{} [positive]'.format(env_name, ex_name))
graphs.hold(True)
graphs.posture_signals(env, [{'j0': i, 'j1':-150+2*i} for i in range(150, -1, -10)],
                       color='#333333', alpha=0.5, swap_xy=True)
graphs.hold(False)

# Negative Graph
graphs.spread(env.s_channels, s_vectors=s_vectors_neg,
              e_radius=1.0, e_alpha=0.5,
              title='{}::{} [negative]'.format(env_name, ex_name))
graphs.hold(True)
Beispiel #18
0
import random

import explorers
import environments

import dotdot
import factored
import graphs
import exs
import envs

DIM = 100
N = 10000

graphs.output_file('c3_fig3_17_constraints.html')

for ex_name in ['random.motor']:
    for limit in [1, 2.5, 5, 10, 20, 45, 90, 150, 180]:
        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)
Beispiel #19
0
import explorers
import environments

import dotdot
import exs
import envs
import graphs
import factored

N = 10000
milestones = [
    100, 200, 500, 1000, 2000, 3000, 4000, 5000, 5500, 6000, 7000, 8000, 9000,
    100000
]

graphs.output_file('c0_fig7_kin7_progress.html')


def find_rightmost(s_vectors, x_min, x_max):
    max_y, max_idx = -1, -1
    for i, (x, y) in enumerate(s_vectors):
        if x_min < x < x_max:
            if y > max_y:
                max_y = y
                max_idx = i
    return max_idx


for env_name in ['kin7_150']:
    for ex_name in ['random.goal']:
        random.seed(0)
Beispiel #20
0
import random

import explorers
import environments

import dotdot
import exs
import envs
import factored
import graphs

DIM = 20
RES = 20
N = 10000

graphs.output_file('c3_fig3_13_inverse.html')

for disturb in [0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.2, 0.5, 1.0]:
    for env_name in ['kin2_150', 'kin7_150', 'kin20_150']:
        random.seed(0)

        print(disturb, env_name)

        # instanciating the environment
        env_cfg = envs.catalog[env_name]
        env = environments.Environment.create(env_cfg)

        # instanciating the explorer
        ex_cfg = exs.catalog['random.goal']._deepcopy()
        ex_cfg.ex_1.learner.m_disturb = disturb
        ex_cfg.m_channels = env.m_channels
Beispiel #21
0
    d = exp_cfg.exploration.explorer.ex_1.learner.m_disturb

    # for N in cfg.testsnn.ticks:
    for N in Ns:
        index = data['ticks'].index(N)
        adapt_avgs[(d, res, N)] = data['avg'][index]
        adapt_stds[(d, res, N)] = data['std'][index]

os.chdir(cwd)

# for d in disturbs:
#     for N in Ns:
#         print('N={}:  {} +- {}'.format(N, adapt_avgs[(d, res, N)], adapt_stds[(d, res N)]))

if __name__ == '__main__':
    graphs.output_file('c4_fig4_5_adapt_graph_{}.html'.format(KIND))
    y_ranges = [(0.075, 0.3), (0.0, 0.1), (0.08, 0.14)]

    for i, d in enumerate(disturbs):
        y_range = y_ranges[i]
        for N in Ns:
            for res in RESS:
                graphs.perf_std_discrete(
                    [100 * i * 0.05 for i in range(21)],
                    avgs[('kin20_150', d, N)],
                    stds[('kin20_150', d, N)],
                    std_width=0.25,
                    color='#2577B2',
                    alpha=0.5,
                    y_range=y_range,  #y_range=[y_min-0.1, y_max+0.1],
                    plot_width=1000,
Beispiel #22
0
                    min_avgs[env_key] = data['avg'][index]
                    min_stds[env_key] = data['std'][index]

    for env_key in env_keys:
        ps[env_key] = sorted(ps[env_key])
        avgs[env_key] = np.array([avgs[env_key][p] for p in ps[env_key]])
        stds[env_key] = np.array([stds[env_key][p] for p in ps[env_key]])

    os.chdir(cwd)

    return env_keys, ps, avgs, stds, min_avgs, min_stds



if __name__ == '__main__':
    env_keys, ps, avgs, stds, min_avgs, min_stds = load_data('nn')

    colors = [graphs.BLUE, graphs.PINK, graphs.GREEN]
    graphs.output_file('fixed_graph.html')

    env_displayed = [env_key for env_key in env_keys if env_key[0] == 'kin20_150' and env_key[2] == 5000]

    for color, envd in zip(colors, env_displayed):
        print(avgs[envd])
        y_max = max(avgs[envd] + stds[envd])
        graphs.perf_std_discrete(ps[envd], avgs[envd], stds[envd], std_width=0.0035, color=color,
                                 y_range=[0.0, y_max+0.02], plot_width=1000, plot_height=500, title='{} {}'.format(*envd))
        graphs.hold(True)

    graphs.show()
Beispiel #23
0
kin_cfg = envs.catalog['kin20_150']
kin = environments.Environment.create(kin_cfg)

dataset = {'s_channels': kin.s_channels, 's_signals': []}
s_vectors = []

RES = 70

for i in range(RES):
    for j in range(RES):
        s_vector = [(k + 0.5) / RES * (c.bounds[1] - c.bounds[0]) + c.bounds[0]
                    for k, c in zip([i, j], kin.s_channels)]
        if s_vector[0]**2 + s_vector[1]**2 <= 1.0:
            s_signal = environments.tools.to_signal(s_vector, kin.s_channels)
            dataset['s_signals'].append(s_signal)
            s_vectors.append(s_vector)

datafile.save_file(dataset, '../../testsets/testset_kinone')

if __name__ == '__main__':
    import graphs
    graphs.output_file('c3_fig3_1_kin_testset.html')
    graphs.spread(kin.s_channels,
                  s_vectors=s_vectors,
                  e_radius=1.5,
                  e_alpha=0.75,
                  title='{} tests'.format(len(s_vectors)))
    graphs.grid().grid_line_color = 'white'
    graphs.show()
Beispiel #24
0
cwd = os.getcwd()

ticks, avgs, stds = [], [], []
for i, exp_cfg in enumerate(exp_cfgs):
    batch = jobfactory.make_jobgroup([exp_cfg])
    os.chdir(os.path.expanduser(exp_cfg.meta.rootpath))

    results_hub = hub.ResultsHub(batch, kind='nn')
    src_data = results_hub.data()
    assert len(src_data) == 1

    ticks.append(src_data[0]['ticks'])
    avgs.append(src_data[0]['avg'])
    stds.append(src_data[0]['std'])

os.chdir(cwd)


colors = [graphs.NOREUSE_COLOR, graphs.NOREUSE_COLOR]
graphs.output_file('c3_fig3_16_synergy_perf.html')

for color, tick, avg, std, exp_cfg in zip(colors, ticks, avgs, stds, exp_cfgs):
    print('{}::{} {}'.format(exp_cfg.exp.env_name, exp_cfg.exp.explorer_name, avg[-1]))
    graphs.perf_std(tick, avg, std, color=color, plot_width=1000, plot_height=300,
                    x_range=(0, exp_cfg.job.steps), y_range=(0.0, 0.4), title='motor synergies',
                    legend='{} {}'.format(exp_cfg.exp.env_name, exp_cfg.exp.explorer_name))
    graphs.hold(True)

graphs.show()
Beispiel #25
0
# Licensed under the Open Science License (see http://fabien.benureau.com/openscience.html)

import random

import explorers
import environments

import dotdot
import exs
import envs
import graphs
import factored

N = 10000

graphs.output_file('c0_fig2_mb_vs_gb.html')

for env_name in ['kin2_150', 'kin7_150', 'kin20_150', 'kin100_150']:
    for ex_name in ['random.motor', 'random.goal']:
        random.seed(0)

        # instanciating the environment
        env_cfg = envs.catalog[env_name]._deepcopy()
        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)
Beispiel #26
0
# Code for generating figures of the the PhD thesis:
# 'Self-Exploration of Sensorimotor Spaces in Robots' by Fabien C. Y. Benureau
# Licensed under the Open Science License (see http://fabien.benureau.com/openscience.html)

from reuse_perf_graphs import perf_graphs, load_results
from fig7_17_dov_reuse_45_nn_300_a20_cluster import expcfgs_levels

import dotdot
import graphs

# look at fig7_17_dov_reuse_45_nn_300_a20_cluster.py for full configuration details
sources, targets = load_results(expcfgs_levels)

graphs.output_file('c7_fig7_17_graph.html')
perf_graphs(sources, targets, mb_steps=300, y_maxs=(1000000, 400000))
graphs.show()
Beispiel #27
0
import learners
import explorers
import environments

import dotdot
import exs
import envs
import factored
import graphs

DIM = 20
RES = 40
N = 10000

# making graphs
graphs.output_file('c3_fig3_12_frontier_params_{}.html'.format(RES))
timescale = [10, 100, 250, 500, 2000, 10000]
#timescale = [20000]
mesh_colors = graphs.colorscale(timescale, graphs.hex2rgb(graphs.C_COLOR),
                                0.16)

learn_cfg = learners.DisturbLearner.defcfg._deepcopy()
learn_cfg.m_disturb = 0.05

RES = 40
_ex_cfg = explorers.MetaExplorer.defcfg._deepcopy()
_ex_cfg.eras = (10, None)

_ex_cfg.ex_0 = explorers.RandomMotorExplorer.defcfg._deepcopy()

_ex_cfg.ex_1 = explorers.MeshgridGoalExplorer.defcfg._deepcopy()
Beispiel #28
0
# 'Self-Exploration of Sensorimotor Spaces in Robots' by Fabien C. Y. Benureau
# Licensed under the Open Science License (see http://fabien.benureau.com/openscience.html)

import environments

import dotdot
import envs
import graphs

# instanciating the environment
env_cfg = envs.catalog['kin7_150']._deepcopy()
env = environments.Environment.create(env_cfg)

# defining postures
m_vectors = [
    (132.654, -108.829, -100.829, 12.724, 133.011, -76.348, -118.995),
    (-19.163, 69.503, 44.059, -88.545, -36.027, 76.281, 8.720),
    (138.239, 39.661, -84.211, 15.735, -33.844, 104.375, 26.110),
    (19.678, -95.130, 96.038, -7.118, 56.496, 10.632, 111.627),
    (135.685, 70.589, -69.667, -7.244, 149.627, -42.752, -54.894),
]
m_signals = [
    environments.tools.to_signal(m_vector, env.m_channels)
    for m_vector in m_vectors
]

# making graphs
graphs.output_file('c0_fig1_kin7_example.html')
graphs.posture_signals(env, m_signals, color='#666666', alpha=0.5)
graphs.show()
Beispiel #29
0
ex_cfg.weights = ((1.0, 0.0), (0.0, 1.0))
ex_cfg.fallback = 0

ex_cfg.ex_0 = explorers.ReuseExplorer.defcfg._deepcopy()
ex_cfg.ex_0.reuse.res = RES
ex_cfg.ex_1 = explorers.RandomGoalExplorer.defcfg._deepcopy()
ex_cfg.ex_1.learner = exs.catalog['random.goal'].ex_1.learner._deepcopy()

# instanciating the environment and the Explorer
ex_cfg.m_channels = env.m_channels
ex_cfg.s_channels = env.s_channels
ex = explorers.Explorer.create(ex_cfg, datasets=[dataset])

explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

graphs.output_file('c5_fig5_2.3.4_reuse.html')

# Graph of reused effects in first env
s_vectors0 = []
for explo in explorations[:MB]:
    feedback = env0.execute(explo[0]['m_signal'])
    s_vectors0.append(
        explorers.tools.to_vector(feedback['s_signal'], env0.s_channels))

graphs.spread(env.s_channels,
              s_vectors=s_vectors0[:MB],
              e_radius=3.0,
              e_alpha=1.0,
              e_color='#DF6464',
              title='first arm - reused effects')
for e in explorations[:MB]:
Beispiel #30
0
        try:
            index = src_data[0]['ticks'].index(tick)
            ratios[tick].append(ratios_[i])
            avgs[tick].append(src_data[0]['avg'][index])
            stds[tick].append(src_data[0]['std'][index])
            y_max = max(y_max, max(avgs[tick]) + max(stds[tick]))
        except ValueError:
            pass

os.chdir(cwd)

if __name__ == "__main__":
    print('  '.join('{:6.3f}|{:6.3f}'.format(a, s)
                    for a, s in zip(avgs, stds)))
    graphs.output_file('c3_fig3_8_unreach_perf.html')
    colors = ['#2577B2', '#E84A5F']

    for color, tick in zip(colors, [2000, 10000]):
        graphs.perf_std_discrete(
            ratios[tick],
            avgs[tick],
            stds[tick],
            std_width=0.25,
            color=color,
            alpha=0.75,
            y_range=[0.0, y_max + 0.01],  #y_range=[y_min-0.1, y_max+0.1],
            plot_width=1000,
            plot_height=400,
            title='t={}'.format(tick))
        graphs.hold(True)
Beispiel #31
0
import explorers
import environments

import dotdot
import exs
import envs
import graphs
import factored


N     = 10000 # number of steps
DIM   = 100   # number of joints
LIMIT = 150   # joint range = [-LIMIT, +LIMIT]

graphs.output_file('c3_fig3_19_demo_control_{}.html'.format(DIM))


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)
Beispiel #32
0
kin_cfg = envs.catalog['kin20_150']
kin = environments.Environment.create(kin_cfg)

dataset = {'s_channels': kin.s_channels, 's_signals': []}
s_vectors = []

RES = 70

for i in range(RES):
    for j in range(RES):
        s_vector = [(k+0.5)/RES*(c.bounds[1]-c.bounds[0])+ c.bounds[0] for k, c in zip([i, j], kin.s_channels)]
        if s_vector[0]**2 + s_vector[1]**2 <= 1.0:
            dataset['s_signals'].append(environments.tools.to_signal(s_vector, kin.s_channels))
            s_vectors.append(s_vector)

from clusterjobs import datafile
datafile.save_file(dataset, '../../testsets/testset_kinone')


if __name__ == '__main__':
    import graphs
        graphs.output_file('testset_kinone.html')

    graphs.bokeh_spread(kin.s_channels, s_vectors=s_vectors,
                        e_radius=1.5, e_alpha=0.75,
                        title='{} tests'.format(len(s_vectors)))
    plotting.grid().grid_line_color = 'white'

    graphs.show()