def run(args):
    # logger
    make_logger(args.result_dir)

    # make envs
    env = make_env(args)

    # make config
    config = make_config(args)

    # make planner
    planner = make_planner(args, config)

    # make model
    model = make_model(args, config)

    # make controller
    controller = make_controller(args, config, model)

    # make simulator
    runner = make_runner(args)

    # run experiment
    history_x, history_u, history_g = runner.run(env, controller, planner)

    # plot results
    plot_results(args, history_x, history_u, history_g=history_g)
    save_plot_data(args, history_x, history_u, history_g=history_g)
Example #2
0
    def __init__(self, params):
        self.params = params
        self.env = make_env(params)
        self.IL = ILNetwork(params)
        self.collect_policy = MLPolicy(self.IL, params)

        if self.params.env == "CartPole":
            self.expert_policy = iLQRPolicy()

        elif self.params.env == "TwoWheeledTrack":
            self.expert_policy = NMPCCGMRESPolicy()

        self.x_training_data = np.zeros((1, self.env.config['state_size']),
                                        dtype=np.float32)
        self.u_training_data = np.zeros((1, self.env.config['input_size']),
                                        dtype=np.float32)
Example #3
0
def run(args):
    make_logger(args.result_dir)

    env = make_env(args)

    config = make_config(args)

    planner = make_planner(args, config)

    model = make_model(args, config)

    controller = make_controller(args, config, model)

    runner = make_runner(args)

    history_x_all, history_u_all, history_g_all, history_cost_all = [], [], [], [
    ]  # this is the collection list of n_sample trajectories
    for iter_sample in range(args.n_sample):
        print("Sampling {} th trajectory generated by expert policy:".format(
            iter_sample))
        history_x, history_u, history_g, cost = runner.run(
            env, controller, planner)
        history_x_all.append(history_x)
        history_u_all.append(history_u)
        history_g_all.append(history_g)
        history_cost_all.append(cost)

    plot_results(
        history_x, history_u, history_g=history_g,
        args=args)  # no need to change now, just see the plot of the last traj
    save_plot_data(history_x_all,
                   history_u_all,
                   history_g=history_g_all,
                   cost=history_cost_all,
                   args=args)  # save lists

    if args.save_anim:
        animator = Animator(env, args=args)
        animator.draw(history_x, history_g)
Example #4
0
 def __init__(self, params):
     self.sess = tf.Session()
     # build net and initialize variables when instantiate this class
     self.env = make_env(params)
     self.build_net()
     self.sess.run(tf.global_variables_initializer())
Example #5
0
 def __init__(self, ILNet, params):
     self.ILNet = ILNet
     self.env = make_env(params)