Ejemplo n.º 1
0
def run_configuration(argv):

    params = ParameterServer(
        filename="examples/example_params/iqn_params.json")
    params["ML"]["BaseAgent"][
        "SummaryPath"] = "/home/mansoor/Study/Werkstudent/fortiss/code/bark-ml/summaries"
    params["ML"]["BaseAgent"][
        "CheckpointPath"] = "/home/mansoor/Study/Werkstudent/fortiss/code/bark-ml/checkpoints"

    env = gym.make(FLAGS.env, params=params)
    agent = IQNAgent(env=env, test_env=env, params=params)

    if FLAGS.load and params["ML"]["BaseAgent"]["CheckpointPath"]:
        agent.load_models(
            os.path.join(params["ML"]["BaseAgent"]["CheckpointPath"], "best"))

    if FLAGS.mode == "train":
        agent.run()

    elif FLAGS.mode == "visualize":
        agent.visualize()

    elif FLAGS.mode == "evaluate":
        # writes evaluaion data using summary writer in summary path
        agent.evaluate()

    else:
        raise Exception("Invalid argument for --mode")
Ejemplo n.º 2
0
  behavior = BehaviorDiscreteMacroActionsML(params)
  observer = NearestAgentsObserver(params)

evaluator = GoalReached(params)

viewer = MPViewer(
  params=params,
  center= [960, 1000.8],
  enforce_x_length=True,
  x_length = 100.0,
  use_world_bounds=False)

# load env
env = HyDiscreteHighway(params=params,
                        scenario_generation=scenario_generator,
                        behavior=behavior,
                        evaluator=evaluator,
                        observer=observer,
                        viewer=viewer,
                        render=False)

# agent saved directory
agent_dir = os.path.join(exp_dir, 'agent')

# load agent
agent = IQNAgent(env=env, params=params, agent_save_dir=agent_dir, 
                 is_checkpoint_run=True, is_online_demo=False)
agent.load_models(IQNAgent.check_point_directory(agent.agent_save_dir, "best"))

agent.evaluate()