コード例 #1
0
    def testActualLoad(self):
        env = BatteryEnv(reward_func=reward_equationMAX)
        self.assertEqual(len(env.actual_load_list), 0)

        for i in range(10):
            action = 0
            observation, reward, done, info = env.step(action)
        self.assertEqual(len(env.actual_load_list), 10)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.sum(), 158838.65)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.min(), 15226.48)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.max(), 16997.13)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.mean(), 15883.865)

        env.restart_env()
        self.assertEqual(len(env.actual_load_list), 0)

        for i in range(10):
            action = 1
            observation, reward, done, info = env.step(action)
        self.assertEqual(len(env.actual_load_list), 10)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.sum(), 159238.65)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.min(), 15326.48)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.max(), 16997.13)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.mean(), 15923.865)

        env.restart_env()
        self.assertEqual(len(env.actual_load_list), 0)

        for i in range(10):
            action = 2
            observation, reward, done, info = env.step(action)
        self.assertEqual(len(env.actual_load_list), 10)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.sum(), 159238.65)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.min(), 15326.48)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.max(), 16997.13)

        arr = np.array(env.actual_load_list)
        self.assertEqual(arr.mean(), 15923.865)
コード例 #2
0
    def testEnvIndex(self):
        env = BatteryEnv(reward_func=reward_equationMAX)
        self.assertEqual(env.state_idx, 0)

        for i in range(10):
            action = env.action_space.sample()
            observation, reward, done, info = env.step(action)
        self.assertEqual(env.state_idx, 10)

        env.restart_env()
        self.assertEqual(env.state_idx, 0)
コード例 #3
0
 def testCOND(self):
     env = BatteryEnv(reward_func=reward_equationCOND)
     lst = [1,2,3,3,10,-50]
     self.assertEqual(env.reward_func(lst), 0)
コード例 #4
0
 def testLAST(self):
     env = BatteryEnv(reward_func=reward_equationLAST)
     lst = [1,2,3,3,10,-50]
     self.assertEqual(env.reward_func(lst), -50)
コード例 #5
0
 def testSUM(self):
     env = BatteryEnv(reward_func=reward_equationSUM)
     lst = [1,2,3,3,10,-50]
     self.assertEqual(env.reward_func(lst), -31)
コード例 #6
0
 def testMAX(self):
     env = BatteryEnv(reward_func=reward_equationMAX)
     lst = [1,2,3,3,10,-50]
     self.assertEqual(env.reward_func(lst), 10)
コード例 #7
0
 def testEnvActionSpace(self):
     env = BatteryEnv(reward_func=reward_equationMAX)
     self.assertIn(env.action_space.sample(), [0, 1, 2])