from __future__ import division

# modify from https://github.com/udacity/deep-reinforcement-learning/blob/master/cross-entropy/CEM.ipynb
import numpy as np
import gym
from gym import wrappers
from collections import deque
import torch
import torch.nn as nn

from CAVSimulator0910 import Simulator

env = Simulator(3, 0)

import argparse
import sys
sys.path.append('../../keras-rl')
from PIL import Image
import numpy as np
import gym
from keras.models import Model
from keras.layers import Flatten, Convolution2D, Input, Dense
from keras.optimizers import Adam
import keras.backend as K
from rl.agents.dqn import DQNAgent
from rl.policy import EpsGreedyQPolicy, LinearAnnealedPolicy
from rl.memory import SequentialMemory
from rl.core import Processor
from rl.callbacks import TrainEpisodeLogger, ModelIntervalCheckpoint

from keras.models import Sequential
    plt.title("Location Graph")

    for n in range(env.num_vehicles):
        if (n < env.num_leading_cars):
            plt.plot(np.array(data_d)[:, n] + start_disp[n * 3 + 1], color='b')
        elif (n == env.num_leading_cars):
            plt.plot(np.array(data_d)[:, n] + start_disp[n * 3 + 1], "g")
        else:
            plt.plot(np.array(data_d)[:, n] + start_disp[n * 3 + 1], "r")
    plt.ylabel("Location")
    plt.xlabel("Time")
    plt.show()


# CAV Simulator (Generates Fake Data now)
env = Simulator(num_leading_vehicle, num_following_vehicle)
env.normalize = False
#env.verbose = True
num_episodes = num_eps
rewards = []

for i in range(num_episodes):
    #
    data_t = []
    data_d = []
    start_disp = None
    #
    s = env.reset()
    #
    env.normalize = True
    start_disp = env.center_state(env.current_states[0])
Ejemplo n.º 3
0
from __future__ import division

# modify from https://github.com/udacity/deep-reinforcement-learning/blob/master/cross-entropy/CEM.ipynb
import numpy as np
import gym
from gym import wrappers
from collections import deque
import torch
import torch.nn as nn

from CAVSimulator0910 import Simulator

num_leading_vehicle = 3
env = Simulator(num_leading_vehicle, 0)

#!/usr/bin/env python

import pickle
import tensorflow as tf
import numpy as np
import tf_util
import gym


def main():
    #===========================================================================
    # generate expert data
    #===========================================================================
    # param
    envname = 'CAV_Controller'
    render = 0