Exemple #1
0
def mp_run(cfg):
    print('mp_run of {}'.format(cfg))
    bailing = None
    # Try to read configuration
    file = None
    try:
        file = open(cfg, 'r')
    except Exception as e:
        bailing = "mp_run {}:\n{}\n".format(cfg, traceback.format_exc())

    # Run the experiment
    if file:
        with file:
            args = yaml.load(file)
        try:
            cfg_run(**args)
        except Exception as e:
            bailing = "mp_run {}:\n{}\n".format(cfg, traceback.format_exc())

    # take care of fails
    if bailing:
        f = open("bailing.out", "a")
        try:
            f.write(bailing + "\n")
        finally:
            f.close()
Exemple #2
0
def mp_run(cfg):
    # Multiple copies can be run on one computer at the same time, which results in the same seed for a random generator.
    # Thus we need to wait for a second or so between runs
    global counter
    global cores
    with counter_lock:
        wait = counter.value
        counter.value += 2
    sleep(wait)
    print('wait finished {0}'.format(wait))
    # Run the experiment
    with open(cfg, 'r') as file:
        args = yaml.load(file)
    cfg_run(**args)
def mp_run(cfg):
    print('mp_run of {}'.format(cfg))
    # Read configuration
    try:
        file = open(cfg, 'r')
    except IOError:
        print("Could not read file: {}".format(cfg))
        sys.exit()
    with file:
        args = yaml.load(file)

    # Run the experiment
    try:
        cfg_run(**args)
    except Exception:
        print('mp_run {} failid to exit correctly'.format(cfg))
        sys.exit()
def mujoco_export(env,
                  mp,
                  task='Walking',
                  policies='',
                  trajectories='',
                  misc=''):
    args = parse_args()

    if task == 'Balancing':
        task_balancing = task
    else:
        task_balancing = ''

    args['cfg'] = "Roboschool{}-v1".format(env + task_balancing + 'GRL')
    args['steps'] = 0
    args['trials'] = 1
    args['test_interval'] = 0
    args['normalize_observations'] = False
    args['normalize_returns'] = False
    args['batch_norm'] = True
    args['render'] = True

    args['output'] = misc + '{}_{}_play-mp{}'.format(env.lower(), task.lower(),
                                                     mp)
    t = task[0].lower()
    if t == 'b':
        stage = stage_names[1]
    elif t == 'w':
        stage = stage_names[2]
    else:
        raise ValueError('incorrect task ' + task)
    args[
        'load_file'] = policies + 'ddpg-exp1_two_stage_{env}_ga_{task}-g0001-mp{mp}-{stage}'.format(
            env=env.lower(), task=t, mp=mp, stage=stage)
    args[
        'compare_with'] = policies + 'ddpg-exp1_two_stage_{env}_ga_b-g0001-mp{mp}-01_balancing-last'.format(
            env=env.lower(), mp=mp)
    args['trajectory'] = trajectories + '{}_{}-mp{}'.format(
        env.lower(), task.lower(), mp)

    args['env_timestep'] = 0.0165

    # Run actual script.
    args['save'] = False
    cfg_run(**args)
def leo_export(mp, policies='', task='walking', trajectories='', misc=''):
    args = parse_args()

    env = 'leo'

    args['cfg'] = 'cfg/{}_{}_play.yaml'.format(env, task)
    args['steps'] = 0
    args['trials'] = 1
    args['test_interval'] = 0
    args['normalize_observations'] = False
    args['normalize_returns'] = False
    args['batch_norm'] = True

    args['output'] = misc + '{}_{}_play-mp{}'.format(env, task, mp)
    t = task[0].lower()
    if t == 'b':
        stage = stage_names[1]
    elif t == 'w':
        stage = stage_names[2]
    else:
        raise ValueError('incorrect task ' + task)
    args[
        'load_file'] = policies + 'ddpg-exp1_two_stage_leo_ga_{task}-g0001-mp{mp}-{stage}'.format(
            task=t, mp=mp, stage=stage)
    args[
        'compare_with'] = policies + 'ddpg-exp1_two_stage_leo_ga_b-g0001-mp{mp}-01_balancing-last'.format(
            mp=mp)
    args['trajectory'] = trajectories + '{}_{}-mp{}'.format(env, task, mp)

    args['env_timestep'] = 0.03

    # Run actual script.
    args['save'] = False
    cfg_run(**args)

    if task == 'walking':
        os.rename('aux_leo.csv', 'aux_leo-mp{}.csv'.format(mp))
    task_balancing = task
else:
    task_balancing = ''

if tf:
    tfstr = '_TF'
else:
    tfstr = ''

args['cfg'] = "Roboschool{}-v1".format(env + task_balancing + 'GRL' + tfstr)
#args['cfg'] = "Roboschool{}-v1".format(env+task_balancing)
#args['cfg'] = "Roboschool{}-v1".format(env+task)
args['steps'] = 10000
args['test_interval'] = 30
#args['seed'] = 1
args['rb_max_size'] = args['steps']
args['normalize_observations'] = False
args['normalize_returns'] = False
args['batch_norm'] = True
args['version'] = 0
args['output'] = 'cl/{}_{}{}'.format(env.lower(), task.lower(), tfstr.lower())

args['rb_save_filename'] = 'cl/{}_{}{}'.format(env.lower(), task.lower(),
                                               tfstr.lower())
#args['rb_load_filename'] = '{}_{}'.format(env, 'balancing')
#args['reassess_for'] = 'walking_1_0'

# Run actual script.
args['save'] = True
cfg_run(**args)