Source code for titan_pylib.ahc.ahc_settings

 1import optuna
 2
 3"""example
 4python3 ./parallel_tester.py -c -v -njobs 127
 5
 6python3 ./oprimizer.py
 7g++ ./main.cpp -O2 -std=c++20 -o a.out -I./../../../Library_cpp
 8"""
 9
10
[docs] 11class AHCSettings: 12 """ 13 AHCテスターの設定ファイル 14 15 https://github.com/titan-23/Library_py/tree/main/titan_pylib/ahc/readme.md 16 """ 17 18 # parallel_tester -------------------- # 19 compile_command = "g++ ./main.cpp -O2 -std=c++20 -o a.out -I./../../../Library_cpp" 20 execute_command = "./a.out" 21 input_file_names = [f"./in/{str(i).zfill(4)}.txt" for i in range(100)] 22 timeout = None 23
[docs] 24 def get_score(scores: list[float]) -> float: 25 return sum(scores) / len(scores) * 100
26 27 # ------------------------------------ # 28 29 # optimizer -------------------------- # 30 # study_name 31 study_name = "test" 32 33 # direction: minimize / maximize 34 direction = "minimize" 35 36 # parallel_tester の cpu_count 37 n_jobs_parallel_tester = 127 38 39 # optuna の試行回数 40 n_trials = 50 41 42 # optuna の cpu_count 43 n_jobs_optuna = 1 44
[docs] 45 def objective(trial: optuna.trial.Trial) -> tuple: 46 # 返り値のタプルはコマンドライン引数として渡す順番にする 47 start_temp = trial.suggest_float("start_temp", 1, 100, log=True) 48 k = trial.suggest_float("k", 0.0001, 1, log=True) 49 end_temp = start_temp * k 50 return (start_temp, end_temp)
51 52 # ------------------------------------ #