Ejemplo n.º 1
0
import environments
import experiments
from experiments.plotting import plot_policy_map, plot_policy_map1, \
    plot_policy_map_combined, plot_value_map, plot_value_map1, plot_value_map2

base_dir = 'output/Q'
#base_dir = 'test-heatmap'
output_dir = 'output/images/Q'
#output_dir = 'test-heatmap'

envs = {}
envs['4x4']   = environments.get_small_frozen_lake_environment()
envs['8x8']   = environments.get_medium_rewarding_frozen_lake_environment()
envs['15x15'] = environments.get_large_frozen_lake_environment()
envs['4x12']  = environments.get_windy_cliff_walking_environment()

title_regex = re.compile('v-(.*)\.txt')

env_strs = ['4x4', '8x8', '15x15', '4x12']
#env_strs = ['4x12']

for env_str in env_strs:
    grid_files = glob.glob('{}/v-*{}*.txt'.format(base_dir, env_str))
    print(grid_files)

    env = envs[env_str]

    for path in grid_files:
        file = basename(path)
        search_result = title_regex.search(basename(file))
    logger.info("Creating MDPs")
    logger.info("----------")

    envs = [{
        'env': environments.get_large_rewarding_frozen_lake_environment(),
        'name': 'large_frozen_lake',
        'readable_name': 'Frozen Lake (18x20)',
    }, {
        'env':
        environments.get_large_rewarding_frozen_lake_slipper_environment(),
        'name':
        'large_frozen_lake',
        'readable_name':
        'Frozen Lake (18x20)',
    }, {
        'env': environments.get_windy_cliff_walking_environment(),
        'name': 'cliff_walking_windy',
        'readable_name': 'Cliff Walking (4x12)',
    }, {
        'env': environments.get_cliff_walking_environment(),
        'name': 'cliff_walking',
        'readable_name': 'Cliff Walking (4x12)',
    }]

    experiment_details = []
    for env in envs:
        env['env'].seed(seed)
        logger.info('{}: State space: {}, Action space: {}'.format(
            env['readable_name'], env['env'].unwrapped.nS,
            env['env'].unwrapped.nA))
        experiment_details.append(
Ejemplo n.º 3
0
        'readable_name':
        'Frozen Lake (8x8)',
    }, {
        'env':
        environments.get_large_rewarding_frozen_lake_environment(
            ENV_REWARDS['large_lake']['step_rew'],
            ENV_REWARDS['large_lake']['hole_rew'],
            ENV_REWARDS['large_lake']['goal_rew']),
        'name':
        'large_frozen_lake',
        'readable_name':
        'Frozen Lake (15x15)',
    }, {
        'env':
        environments.get_windy_cliff_walking_environment(
            ENV_REWARDS['cliff_walking']['step_rew'],
            ENV_REWARDS['cliff_walking']['fall_rew'],
            ENV_REWARDS['cliff_walking']['goal_rew']),
        'name':
        'cliff_walking',
        'readable_name':
        'Cliff Walking (4x12)',
    }]

    experiment_details = []
    for env in envs:
        env['env'].seed(seed)
        logger.info('{}: State space: {}, Action space: {}'.format(
            env['readable_name'], env['env'].unwrapped.nS,
            env['env'].unwrapped.nA))
        experiment_details.append(
            experiments.ExperimentDetails(env['env'],