titan23 が使用している、AHC のツールです。 ありえないバグがあるかもしれません。ご注意ください。
使い方
初期設定
作業ディレクトリで以下のコマンドを実行し、設定ファイル ahc_settings ファイルを生成します
python3 -m ahclib setup
並列実行
njobs 数のスレッドを立ち上げて実行します。結果を記録した csv ファイルと実行ソースファイルが ./ahclib_results/ ディレクトリに保存されます
コマンドは以下です
python3 -m ahclib test [-c] [-v] [-r]
オプション
-c : コンパイルします
-v : ログを表示します(推奨)
-r : 標準出力と標準エラー出力をすべて保存します
Optuna を用いたパラメータ探索
コマンドは以下です
python3 -m ahclib opt
設定ファイル
設定ファイル ahc_settings 中の AHCSettings クラスに以下の情報を書いてください
スレッド数 (njobs)
(パソコンの最大スレッド数-1)との min がとられる
ファイル名 (filename)
コンパイルコマンド (compile_command)
コンパイルする必要が無いときは、None とする
実行コマンド (execute_command)
入力ファイル (input_file_names)
list[str] の形式で書く
制限時間 (timeout)
ms 単位で指定する
指定しないときは None とする
各テストでメモリを多く使う場合など、正確さに欠けることがある点に注意
集計関数 (get_score)
例: 平均など
例:
njobs = 127
filename = "./main.cpp"
compile_command = "g++ ./main.cpp -O2 -std=c++20 -o a.out -I./../../../Library_cpp"
execute_command = "./a.out"
input_file_names = [f"./in/{str(i).zfill(4)}.txt" for i in range(100)]
timeout = None
def get_score(scores: list[float]) -> float:
return sum(scores) / len(scores)
Optuna を用いたパラメータ探索用の設定
study_name
study_name が既にある場合、そのデータベースが利用される
direction
minimize か maximize
optuna の試行回数 (n_trials)
optuna のスレッド数 (n_jobs_optuna)
推定するもの
def objective(trial: optuna.trial.Trial) -> tuple:返り値のタプルはコマンドライン引数として渡す順番にする
例: 初期温度を探索する
study_name = "test"
direction = "minimize"
n_trials = 50
n_jobs_optuna = 1
def objective(trial: optuna.trial.Trial) -> tuple:
start_temp = trial.suggest_float("start_temp", 1, 1e9, log=True)
return start_temp, # タプルで返す
double start_temp;
int main(int argc, char *argv[]) {
start_temp = std::stod(argv[1]); // argv[1], ... に objective で返した値が格納されている
solve();
return 0;
}
Metadata
Release files for ahclib 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ahclib-0.1.0.tar.gz | 11.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ahclib-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.9 kB
Release files / ahclib-0.1.0.tar.gz
| Download URL | ahclib-0.1.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b537288b1ed12555059feb270ab12e6bd7a3d1ac8c725b873a704f520e5445aa
|
|
BLAKE2b-256 checksum How to use checksums |
3cdcad050b14d5d191cbb22fd47f91d5fa128a4c6999b77b3209825dc32c86c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.12
|
Release files / ahclib-0.1.0-py3-none-any.whl
| Download URL | ahclib-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40f54ae07d9cb6028801a5527ed61de7481523f8a4da5082ef2642c6737c9e04
|
|
BLAKE2b-256 checksum How to use checksums |
cc67db375bb1c579e4d06c61530051ad5016910b2a91a6aeb1098c55bebbd7ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.12
|
Security for ahclib 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.