Esempio n. 1
0
    def test_julia_env(self):
        env = JuliaEnv(env_id='DeterministicSingleStepDebugEnv',
                       env_params={},
                       using='AutoEnvs')
        x = env.reset()
        nx, r, t, info = env.step(1)

        self.assertEqual(x, 0)
        self.assertEqual(nx, 0)
        self.assertEqual(r, 1)
        self.assertEqual(t, True)
Esempio n. 2
0
def perf_ngsim_env_step():
    basedir = os.path.expanduser('~/.julia/packages/NGSIM/9OYUa/data')
    filename = 'trajdata_i101_trajectories-0750am-0805am.txt'
    filepaths = [os.path.join(basedir, filename)]
    env = JuliaEnv(env_id='NGSIMEnv',
                   env_params=dict(trajectory_filepaths=filepaths, ),
                   using='AutoEnvs')
    n_steps = 10000
    action = np.array([1., 0.])
    env.reset()
    with ContextTimer():
        for _ in range(n_steps):
            _, _, terminal, _ = env.step(action)
            if terminal:
                env.reset()
Esempio n. 3
0
    def test_ngsim_env(self):
        basedir = os.path.expanduser('~/.julia/packages/NGSIM/9OYUa/data')
        filename = 'trajdata_i80_trajectories-0400-0415.txt'
        filepaths = [os.path.join(basedir, filename)]
        env = JuliaEnv(env_id='NGSIMEnv',
                       env_params=dict(trajectory_filepaths=filepaths),
                       using='AutoEnvs')
        x = env.reset()
        nx, r, t, info = env.step(np.array([0., 0.]))
        self.assertTrue(np.sum(np.abs(x - nx)) > 1e-1)

        # complex reset
        x = env.reset(offset=250, egoid=3194, start=8886)
        nx = env.reset(offset=250, egoid=3194, start=8886)
        np.testing.assert_array_almost_equal(x, nx, 4)
Esempio n. 4
0
def perf_vectorized_ngsim_env_step():
    basedir = os.path.expanduser('~/.julia/packages/NGSIM/9OYUa/data')
    filename = 'trajdata_i101_trajectories-0750am-0805am.txt'
    filepaths = [os.path.join(basedir, filename)]
    n_envs = 100
    env = JuliaEnv(env_id='VectorizedNGSIMEnv',
                   env_params=dict(
                       n_envs=n_envs,
                       trajectory_filepaths=filepaths,
                   ),
                   using='AutoEnvs')
    n_steps = 10000
    action = np.zeros((n_envs, 2))
    action[:, 0] = 1.
    env.reset()
    with ContextTimer():
        for _ in range(0, n_steps, n_envs):
            _, _, terminal, _ = env.step(action)
            env.reset(terminal)