Exemple #1
0
def visualizeSets_5(
    cs=d.default_cs,
    env=d.default_env,
    agent=d.default_agent,
    k=d.default_k_visualization,
    ps=d.default_ps,
    colors=d.default_colors_sets,
    components=d.default_components,
    loc=d.default_loc,
    show=True,
    conf=None,
    test_chaos_theory=False,
):

    if conf is None:
        conf = Conf()
        conf.test_chaos_theory = test_chaos_theory

    trajs = []
    for p in ps:
        for c in cs:
            trajs.append(getTraj(c, env, agent, p, conf=conf))
    v = Visualisator()
    v.show = show
    name = tools.FileNaming.descrName(env, agent, c, conf)
    filename = tools.FileNaming.imageTrajName(env.name, agent.name,
                                              c, p, conf, k)
    v.plotCompGP(trajs, colors=colors, name=name, components=components,
                 loc=loc, k=k, filename=filename)
Exemple #2
0
def synthesize_4(
    c=d.default_c,
    env=d.default_env,
    agent=d.default_agent,
    k=d.default_k_prediction,
    p=d.default_p,
    save=d.default_save,
    test_chaos_theory=False,
):

    buf = getReplayBuffer(env=env, agent=agent)
    buf = buf.normalize()

    buf = buf.cut(c + k + 1)

    test = buf.slice([(0, k + 1)])
    train = buf.slice([(k + 1, c + k + 1)])

    conf = Conf(n=len(buf.x[0]), m=len(buf.u[0]))
    conf.test_chaos_theory = test_chaos_theory

    cgp = CompGP(conf)

    def convert(x):
        return list(np.array(x.T)[0])

    X = [convert(xx) for xx in train.x]
    U = [convert(uu) for uu in train.u]
    Y = [convert(yy) for yy in train.y]

    cgp.fit(X, U, Y)

    x_0 = convert(test.x[0])
    U = [convert(uu) for uu in test.u]

    traj = cgp.synthesizeSets(x_0, U, k, p)
    traj.addBuf(test)

    if save:
        f = tools.FileNaming.trajName(
            env.name, agent.name, c, p, conf)
        traj.save(f)

    return traj