-
Notifications
You must be signed in to change notification settings - Fork 1
/
target-runner-umm.py
executable file
·53 lines (47 loc) · 2.12 KB
/
target-runner-umm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
###############################################################################
# This script is the command that is executed every run.
# Check the examples in examples/
#
# This script is run in the execution directory (execDir, --exec-dir).
#
# PARAMETERS:
# argv[1] is the candidate configuration number
# argv[2] is the instance ID
# argv[3] is the seed
# argv[4] is the instance name
# The rest (argv[5:]) are parameters to the run
#
# RETURN VALUE:
# This script should print one numerical value: the cost that must be minimized.
# Exit with 0 if no error, with 1 in case of error
###############################################################################
import sys
import os
import pandas as pd
import runner
from argparse import ArgumentParser,RawDescriptionHelpFormatter,_StoreTrueAction,ArgumentDefaultsHelpFormatter,Action
parser = ArgumentParser(description = "UMM")
parser.add_argument('configuration_id', type=str, help='configuration_id')
parser.add_argument('instance_id', type=str, help='instance_id')
parser.add_argument('seed', type=int, help='random seed')
parser.add_argument('instance_name', type=str, help='instance name')
parser.add_argument("--output", type=str, default=None, help="output file")
# Parameters for the target algorithm
parser.add_argument('--m_ini', type=int, default=10, help='m_ini')
parser.add_argument('--budget', type=int, default=400, help='budget')
parser.add_argument('--eval_ranks', type=int, default=0, help='eval_ranks')
parser.add_argument('--init', choices = ['random', 'maxmindist', 'greedy_euclidean'], default = 'random', help='init')
args = parser.parse_args()
budget = args.budget
assert budget > 2 * args.m_ini
stdout = sys.stdout
outfilename = f'c{args.configuration_id}-{args.instance_id}-{args.seed}.stdout'
with open(outfilename, 'w') as sys.stdout:
df = runner.run_once("UMM", args.instance_name, args.seed, budget = budget, m_ini = args.m_ini,
eval_ranks = args.eval_ranks, init = args.init,
out_filename = args.output)
sys.stdout = stdout
print(df["Fitness"].min())
# remove tmp file.
os.remove(outfilename)