Ejemplo n.º 1
0
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)

    # 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,
Ejemplo n.º 2
0
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


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

ex_cfg = exs.catalog['random.goal']._deepcopy()
ex_cfg.eras = (MB, None)
ex_cfg.m_channels = env.m_channels
ex_cfg.s_channels = env.s_channels
ex = explorers.Explorer.create(ex_cfg)

mesh = explorers.ExplorerMeshGrid({'res': RES}, env.s_channels, env.m_channels)

# running the exploration
explorations, s_vectors, s_goals = factored.run_exploration(env,
                                                            ex,
                                                            N,
                                                            mesh=mesh)
Ejemplo n.º 3
0
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)

        mesh = explorers.ExplorerMeshGrid({'res': RES}, env.s_channels,
                                          env.m_channels)

        # running the exploration
        prefix = '{} {}'.format(env_name, ex_name)
        explorations, s_vectors, s_goals = factored.run_exploration(
            env, ex, N, mesh=mesh, prefix=prefix)
Ejemplo n.º 4
0
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)

    # 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]
Ejemplo n.º 5
0
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
        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, verbose=False)

        # making graphs
Ejemplo n.º 6
0
# Licensed under the Open Science License (see http://fabien.benureau.com/openscience.html)

import random
import copy

import environments

import dotdot
import envs
import graphs

DIM = 20
RANGE = 150

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

lengths = [0.9**i for i in range(DIM)]
lengths = [s / sum(lengths) for s in lengths]
env2_name, env2_cfg = envs.kin(dim=DIM, limit=RANGE, lengths=lengths)
env2 = environments.Environment.create(env2_cfg)

# defining postures
random.seed(0)
m_channels = copy.deepcopy(env.m_channels)
for i in range(DIM - 1):
    m_channels[i].bounds = (-45, 45)
m_signals = [environments.tools.random_signal(m_channels) for _ in range(50)]

# selecting some proeminent postures