Esempio n. 1
0
def main():

    pa = parameters.Parameters() # 初始化参数

    type_exp = 'pg_re'  # 'pg_su' 'pg_su_compact' 'v_su', 'pg_v_re', 'pg_re', q_re', 'test'

    pg_resume = None
    v_resume = None
    q_resume = None
    log = None

    render = False

    try:
        opts, args = getopt.getopt(
            sys.argv[1:],
            "hi:o:", ["exp_type=",
                      "num_res=",
                      "num_nw=",
                      "simu_len=",
                      "num_ex=",
                      "num_seq_per_batch=",
                      "eps_max_len=",
                      "num_epochs=",
                      "time_horizon=",
                      "res_slot=",
                      "max_job_len=",
                      "max_job_size=",
                      "new_job_rate=",
                      "dist=",
                      "lr_rate=",
                      "ba_size=",
                      "pg_re=",
                      "v_re=",
                      "q_re=",
                      "out_freq=",
                      "ofile=",
                      "log=",
                      "render=",
                      "unseen="])

    except getopt.GetoptError:
        script_usage()
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            script_usage()
            sys.exit()
        elif opt in ("-e", "--exp_type"):
            type_exp = arg
        elif opt in ("-n", "--num_res"):
            pa.num_res = int(arg)
        elif opt in ("-w", "--num_nw"):
            pa.num_nw = int(arg)
        elif opt in ("-s", "--simu_len"):
            pa.simu_len = int(arg)
        elif opt in ("-n", "--num_ex"):
            pa.num_ex = int(arg)
        elif opt in ("-sp", "--num_seq_per_batch"):
            pa.num_seq_per_batch = int(arg)
        elif opt in ("-el", "--eps_max_len"):
            pa.episode_max_length = int(arg)
        elif opt in ("-ne", "--num_epochs"):
            pa.num_epochs = int(arg)
        elif opt in ("-t", "--time_horizon"):
            pa.time_horizon = int(arg)
        elif opt in ("-rs", "--res_slot"):
            pa.res_slot = int(arg)
        elif opt in ("-ml", "--max_job_len"):
            pa.max_job_len = int(arg)
        elif opt in ("-ms", "--max_job_size"):
            pa.max_job_size = int(arg)
        elif opt in ("-nr", "--new_job_rate"):
            pa.new_job_rate = float(arg)
        elif opt in ("-d", "--dist"):
            pa.discount = float(arg)
        elif opt in ("-l", "--lr_rate"):
            pa.lr_rate = float(arg)
        elif opt in ("-b", "--ba_size"):
            pa.batch_size = int(arg)
        elif opt in ("-p", "--pg_re"):
            pg_resume = arg
        elif opt in ("-v", "--v_re"):
            v_resume = arg
        elif opt in ("-q", "--q_re"):
            q_resume = arg
        elif opt in ("-f", "--out_freq"):
            pa.output_freq = int(arg)
        elif opt in ("-o", "--ofile"):
            pa.output_filename = arg
        elif opt in ("-lg", "--log"):
            log = arg
        elif opt in ("-r", "--render"):
            render = (arg == 'True')
        elif opt in ("-u", "--unseen"):
            pa.generate_unseen = (arg == 'True')
        else:
            script_usage()
            sys.exit()

    pa.compute_dependent_parameters()

    if type_exp == 'pg_su':
        pg_su.launch(pa, pg_resume, render, repre='image', end='all_done')
    elif type_exp == 'v_su':
        v_su.launch(pa, v_resume, render)
    elif type_exp == 'pg_re':
        pg_re.launch(pa, pg_resume, render, repre='image', end='all_done')
    elif type_exp == 'pg_v_re':
        pg_v_re.launch(pa, pg_resume, v_resume, render)
    elif type_exp == 'test':
        # quick_test.launch(pa, pg_resume, render)
        slow_down_cdf.launch(pa, pg_resume, render, True)
    # elif type_exp == 'q_re':
    #     q_re.launch(pa, q_resume, render)
    else:
        print("Error: unkown experiment type " + str(type_exp))
        exit(1)
Esempio n. 2
0
def main():

    pa = parameters.Parameters()

    type_exp = 'pg_re'  # 'pg_su' 'pg_su_compact' 'v_su', 'pg_v_re', 'pg_re', q_re', 'test'

    pg_resume = None
    v_resume = None
    q_resume = None
    log = None

    render = True

    # try:
    #     opts, args = getopt.getopt(
    #         sys.argv[1:],
    #         "hi:o:", ["exp_type=",
    #                   "num_res=",
    #                   "num_nw=",
    #                   "simu_len=",
    #                   "num_ex=",
    #                   "num_seq_per_batch=",
    #                   "eps_max_len=",
    #                   "num_epochs=",
    #                   "time_horizon=",
    #                   "res_slot=",
    #                   "max_job_len=",
    #                   "max_job_size=",
    #                   "new_job_rate=",
    #                   "dist=",
    #                   "lr_rate=",
    #                   "ba_size=",
    #                   "pg_re=",
    #                   "v_re=",
    #                   "q_re=",
    #                   "out_freq=",
    #                   "ofile=",
    #                   "log=",
    #                   "render=",
    #                   "unseen="])
    #
    # except getopt.GetoptError:
    #     script_usage()
    #     sys.exit(2)
    #
    # for opt, arg in opts:
    #     if opt == '-h':
    #         script_usage()
    #         sys.exit()
    #     elif opt in ("-e", "--exp_type"):
    #         type_exp = arg
    #     elif opt in ("-n", "--num_res"):
    #         pa.num_res = int(arg)
    #     elif opt in ("-w", "--num_nw"):
    #         pa.num_nw = int(arg)
    #     elif opt in ("-s", "--simu_len"):
    #         pa.simu_len = int(arg)
    #     elif opt in ("-n", "--num_ex"):
    #         pa.num_ex = int(arg)
    #     elif opt in ("-sp", "--num_seq_per_batch"):
    #         pa.num_seq_per_batch = int(arg)
    #     elif opt in ("-el", "--eps_max_len"):
    #         pa.episode_max_length = int(arg)
    #     elif opt in ("-ne", "--num_epochs"):
    #         pa.num_epochs = int(arg)
    #     elif opt in ("-t", "--time_horizon"):
    #         pa.time_horizon = int(arg)
    #     elif opt in ("-rs", "--res_slot"):
    #         pa.res_slot = int(arg)
    #     elif opt in ("-ml", "--max_job_len"):
    #         pa.max_job_len = int(arg)
    #     elif opt in ("-ms", "--max_job_size"):
    #         pa.max_job_size = int(arg)
    #     elif opt in ("-nr", "--new_job_rate"):
    #         pa.new_job_rate = float(arg)
    #     elif opt in ("-d", "--dist"):
    #         pa.discount = float(arg)
    #     elif opt in ("-l", "--lr_rate"):
    #         pa.lr_rate = float(arg)
    #     elif opt in ("-b", "--ba_size"):
    #         pa.batch_size = int(arg)
    #     elif opt in ("-p", "--pg_re"):
    #         pg_resume = arg
    #     elif opt in ("-v", "--v_re"):
    #         v_resume = arg
    #     elif opt in ("-q", "--q_re"):
    #         q_resume = arg
    #     elif opt in ("-f", "--out_freq"):
    #         pa.output_freq = int(arg)
    #     elif opt in ("-o", "--ofile"):
    #         pa.output_filename = arg
    #     elif opt in ("-lg", "--log"):
    #         log = arg
    #     elif opt in ("-r", "--render"):
    #         render = (arg == 'True')
    #     elif opt in ("-u", "--unseen"):
    #         pa.generate_unseen = (arg == 'True')
    #     else:
    #         script_usage()
    #         sys.exit()

    # # supervised learning
    # pa.type_exp = "pg_su"
    # pa.simu_len = 50      # length of the busy cycle that repeats itself
    # pa.num_ex = 10        # number of sequences
    # pa.output_filename = "data/pg_su"
    # pa.output_freq = 10
    # pa.compute_dependent_parameters()
    # pg_su.launch(pa, pg_resume, render, repre='image', end='all_done')

    # reinforcement learning
    # pa.type_exp = "pg_re_single_core"
    pa.pg_resume = None  #"data/pg_su_net_file_9990.pkl"
    pa.simu_len = 50
    pa.num_ex = 3
    pa.output_filename = "data/pg_re"
    pg_re.launch(pa)