コード例 #1
0
ファイル: test_MakeEnv.py プロジェクト: KishanGitASU/Grid2Op
 def test_l2rpn_2019(self):
     try:
         with warnings.catch_warnings():
             warnings.filterwarnings("ignore")
             env = make("l2rpn_2019")
     except EnvError as e:
         pass
コード例 #2
0
    def test_load_still(self):
        max_iter = 10
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore")
            with make("case5_example",
                      chronics_path=os.path.join(PATH_CHRONICS, "5bus_example_some_missing", "chronics")) as env:
                # test a first time without chunks
                env.set_id(0)
                env.chronics_handler.set_max_iter(max_iter)
                obs = env.reset()

                # check that simulate is working
                simul_obs, *_ = obs.simulate(env.action_space())
                # check that load_p is indeed modified
                assert np.all(simul_obs.load_p == env.chronics_handler.real_data.data.load_p_forecast[1, :])

                # check that the environment goes till the end
                nb_it, final_obs = self.run_env_till_over(env, max_iter)
                assert nb_it == max_iter
                # check the that the "missing" files is properly handled: data is not modified
                assert np.all(obs.load_q == final_obs.load_q)
                # check that other data are modified properly
                assert np.any(obs.prod_p != final_obs.prod_p)

                # test a second time with chunk
                env.set_id(0)
                env.set_chunk_size(3)
                obs = env.reset()
                nb_it, obs = self.run_env_till_over(env, max_iter)
                assert nb_it == max_iter
                pass
コード例 #3
0
ファイル: test_MakeEnv.py プロジェクト: gondorh/Grid2Op
 def test_case14realistic_can_simulate(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         with make("case14_realistic") as env:
             obs = env.reset()
             sim_obs, reward, done, info = obs.simulate(env.action_space())
             assert sim_obs != obs
コード例 #4
0
 def setUp(self):
     # powergrid
     self.tolvect = 1e-2
     self.tol_one = 1e-5
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         self.env = make("case14_test")
コード例 #5
0
 def setUp(self):
     """
     The case file is a representation of the case14 as found in the ieee14 powergrid.
     :return:
     """
     param = Parameters()
     param.init_from_dict({"NO_OVERFLOW_DISCONNECTION": True})
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         self.env = make("case14_redisp", param=param)
コード例 #6
0
ファイル: test_RedispatchEnv.py プロジェクト: gondorh/Grid2Op
    def setUp(self) -> None:
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore")
            self.env = make("case14_redisp")

        # i don't want to be bother by ramps in these test (note that is NOT recommended to change that)
        self.env.gen_max_ramp_down[:] = 5000
        self.env.gen_max_ramp_up[:] = 5000
        self.msg_ = 'Grid2OpException AmbiguousAction InvalidRedispatching NotEnoughGenerators "Attempt to use a ' \
               'redispatch action that does not sum to 0., but a'
コード例 #7
0
 def test_change_bus(self):
     env = make()
     env.reset()
     action = env.helper_action_player(
         {"change_bus": {
             "lines_or_id": [17]
         }})
     obs, reward, done, info = env.step(action)
     assert np.all(np.isfinite(obs.v_or))
     assert np.sum(env.backend._grid["bus"]["in_service"]) == 15
コード例 #8
0
 def test_change_bustwice(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         env = make()
     env.reset()
     action = env.helper_action_player(
         {"change_bus": {
             "lines_or_id": [17]
         }})
     obs, reward, done, info = env.step(action)
     obs, reward, done, info = env.step(action)
     assert np.all(np.isfinite(obs.v_or))
     assert np.sum(env.backend._grid["bus"]["in_service"]) == 14
コード例 #9
0
 def test_load_error(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         with self.assertRaises(ChronicsError):
             with make("case14_realistic", chronics_path="/answer/life/42"):
                 pass
コード例 #10
0
 def setUp(self):
     self.max_iter = 10
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         self.env = make("case14_realistic")
         self.env.chronics_handler.set_max_iter(self.max_iter)
コード例 #11
0
 def test_init_from_env(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         with make("case14_test") as env:
             runner = Runner(**env.get_params_for_runner())
コード例 #12
0
ファイル: test_MakeEnv.py プロジェクト: KishanGitASU/Grid2Op
 def test_case14_test(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         env = make("case14_test")
         obs = env.reset()
コード例 #13
0
ファイル: test_MakeEnv.py プロジェクト: KishanGitASU/Grid2Op
 def test_case5_example(self):
     env = make("case5_example")
     obs = env.reset()
コード例 #14
0
ファイル: test_MakeEnv.py プロジェクト: gondorh/Grid2Op
 def test_case14realistic_test_thermals(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         with make("case14_realistic") as env:
             obs = env.reset()
             assert np.all(env._thermal_limit_a == case14_real_TH_LIM)
コード例 #15
0
ファイル: test_MakeEnv.py プロジェクト: KishanGitASU/Grid2Op
 def test_case14_fromfile(self):
     env = make("case14_fromfile")
     obs = env.reset()
コード例 #16
0
ファイル: MultiEnv.py プロジェクト: luvf/Grid2Op
            remote.send(('r', None))
        res = [remote.recv() for remote in self._remotes]
        return np.stack(res)

    def close(self):
        """
        Close all the environments and all the processes.
        """
        for remote in self._remotes:
            remote.send(('c', None))


if __name__ == "__main__":
    from tqdm import tqdm

    env = make()

    nb_env = 8  # change that to adapt to your system
    NB_STEP = 1000  # number of step for each environment

    agent = DoNothingAgent(env.action_space)
    multi_envs = MultiEnvironment(env=env, nb_env=nb_env)

    obs = multi_envs.reset()
    rews = [env.reward_range[0] for i in range(nb_env)]
    dones = [False for i in range(nb_env)]

    total_reward = 0.
    for i in tqdm(range(NB_STEP)):
        acts = [None for _ in range(nb_env)]
        for env_act_id in range(nb_env):
コード例 #17
0
 def test_case5_example(self):
     env = make("case5_example")
コード例 #18
0
 def test_l2rpn_2019(self):
     try:
         env = make("l2rpn_2019")
     except EnvError as e:
         pass
コード例 #19
0
 def test_case14_fromfile(self):
     env = make("case14_fromfile")
コード例 #20
0
ファイル: test_MakeEnv.py プロジェクト: gondorh/Grid2Op
 def test_case5_redispatch_available(self):
     with make("case5_example") as env:
         obs = env.reset()
         assert env.redispatching_unit_commitment_availble == True
コード例 #21
0
ファイル: test_MakeEnv.py プロジェクト: gondorh/Grid2Op
 def test_case5_can_simulate(self):
     with make("case5_example") as env:
         obs = env.reset()
         sim_obs, reward, done, info = obs.simulate(env.action_space())
         assert sim_obs != obs
コード例 #22
0
 def setUp(self):
     # powergrid
     self.tolvect = 1e-2
     self.tol_one = 1e-4
     self.env = make("case5_example")
コード例 #23
0
ファイル: test_MakeEnv.py プロジェクト: gondorh/Grid2Op
 def test_case14realistic_redispatch_available(self):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         with make("case14_realistic") as env:
             obs = env.reset()
             assert env.redispatching_unit_commitment_availble == True