<commit_before>"""Runs the environments located in flow/benchmarks.
The environment file can be modified in the imports to change the environment
this runner script is executed on. This file runs the PPO algorithm in rllib
and utilizes the hyper-parameters specified in:
Proximal Policy Optimization Algorithms by Schulman et. al.
"""
import json

import ray
import ray.rllib.agents.ppo as ppo
from ray.tune import run_experiments
from ray.tune.registry import register_env
from ray.tune import grid_search

from flow.utils.registry import make_create_env
from flow.utils.rllib import FlowParamsEncoder

# use this to specify the environment to run
from flow.benchmarks.grid0 import flow_params

# number of rollouts per training iteration
N_ROLLOUTS = 46
# number of parallel workers
N_CPUS = 48

if __name__ == "__main__":
    # get the env name and a creator for the environment
    create_env, env_name = make_create_env(params=flow_params, version=0)

    # initialize a ray instance
    ray.init(redirect_output=True)

    horizon = flow_params["env"].horizon
    config = ppo.DEFAULT_CONFIG.copy()
    config["num_workers"] = min(N_CPUS, N_ROLLOUTS)
    config["train_batch_size"] = horizon * N_ROLLOUTS
    config["use_gae"] = True
    config["horizon"] = horizon
    config["lambda"] = grid_search([0.97, 1.0])
    config["lr"] = grid_search([5e-4])<commit_msg>commit for grid0 lr5e-5 ppo<commit_after>"""Runs the environments located in flow/benchmarks.
The environment file can be modified in the imports to change the environment
this runner script is executed on. This file runs the PPO algorithm in rllib
and utilizes the hyper-parameters specified in:
Proximal Policy Optimization Algorithms by Schulman et. al.
"""
import json

import ray
import ray.rllib.agents.ppo as ppo
from ray.tune import run_experiments
from ray.tune.registry import register_env
from ray.tune import grid_search

from flow.utils.registry import make_create_env
from flow.utils.rllib import FlowParamsEncoder

# use this to specify the environment to run
from flow.benchmarks.grid0 import flow_params

# number of rollouts per training iteration
N_ROLLOUTS = 46
# number of parallel workers
N_CPUS = 48

if __name__ == "__main__":
    # get the env name and a creator for the environment
    create_env, env_name = make_create_env(params=flow_params, version=0)

    # initialize a ray instance
    ray.init(redirect_output=True)

    horizon = flow_params["env"].horizon
    config = ppo.DEFAULT_CONFIG.copy()
    config["num_workers"] = min(N_CPUS, N_ROLLOUTS)
    config["train_batch_size"] = horizon * N_ROLLOUTS
    config["use_gae"] = True
    config["horizon"] = horizon
    config["lambda"] = grid_search([0.97, 1.0])
    config["lr"] = grid_search([5e-5])
{'fraction_non_alphanumeric': 0.07952069716775599, 'fraction_numerical': 0.010530137981118372, 'mean_word_length': 4.645491803278689, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '347367', 'n_tokens_mistral': 850, 'n_tokens_neox': 831, 'n_words': 287}