def test_env_save_state(self): env = SLGEnv(ExampleState(), LevelCondition(1), ExampleReward(), TimeHandler()) env.setup('test_client') env.save_state() import json with open(get_data_path() + '/' + 'state.json', 'r+') as f: usr_data = json.load(f) self.assertEqual(ExampleState().get_state(usr_data), [1])
def main(): l = init_logger('ExampleAgent') sh = ExampleState() th = LevelCondition(2) time_h = TimeHandler() rh = ExampleReward() env = SLGEnv(sh, th, rh, time_h) env.setup(generate_user_name()) agent = ExampleAgent(env) agent.run()
def main(): l = init_logger('MLPQAgent') sess = tf.Session() sh = ResourceOnly() th = LevelCondition(3) time_h = CountActionTime(60 * 60 * 24 * 5) rh = StepTimeRelated(time_h) env = SLGEnv(sh, th, rh, time_h) agent = FAQAgent(env, 'MLPQAgent', MLP, sess) agent.train(1000000, 20, 10, 10000)
def main(): l = init_logger('QUKAgent') goal_time = 468000 sh = ResourceOnly() th = LevelCondition(3) time_h = CountActionTime(60 * 60 * 24 * 6) rh = TotalTimeRelated(time_h, goal_time) env = SLGEnv(sh, th, rh, time_h) fa = MLP((len(sh) + 1, 20, 20, 1)) agent = FAQAgent(env, 'QUKAgent', fa) agent.train(10000, 20, 1000)
def test_env_get_state(self): env = SLGEnv(ExampleState(), LevelCondition(1), ExampleReward(), TimeHandler()) env.setup('test_client') self.assertEqual(env.get_state(), [1])
def test_env_setup(self): env = SLGEnv(ExampleState(), LevelCondition(1), ExampleReward(), TimeHandler()) self.assertTrue(env.setup('test_client'))
def test_env_init(self): env = SLGEnv(ExampleState(), LevelCondition(1), ExampleReward(), TimeHandler()) self.assertTrue(True)