Skip to content
cccskills
FreePublished on GitHub

simulation-optimization-diagnostics

シミュレーションと数理最適化(モンテカルロ / Monte Carlo / 離散事象シミュレーション / DES / 待ち行列 / リスク分析 / シナリオ分析、線形計画 / LP / 整数計画 / MIP / スケジューリング / 配送計画 / VRP / 割当 / メタヒューリスティクス)を 実行したら必ずセットで出す図と値のルーター。

SeedSequence.spawn, scipy.stats の rvs, simpy, SALib, pulp, LpProblem, mip.Model, ortools, pywraplp, cp_model, pyomo, cvxpy, linprog, milp がコードに現れたとき、または ユーザーが「シミュレーションして」「モンテカルロで見積もって」「待ち時間をシミュレートして」「最適化して」 「最適な割当を求めて」「スケジュールを組んで」と言ったときに使う。

収束・標準誤差・ソルバー status・制約違反・ 感度分析に言及がなくても適用する。SKILL.md のルーティング表で手法を特定し、対応する references/<手法>.md を 読んでから実行する。

MCMC は statistical-inference-diagnostics、ML のハイパラ探索は predictive-modeling-diagnostics を使う。

The English summary is being prepared. Showing the original description.

See how to install

Files included (3)

  • SKILL.md6.9 KB
  • references/optimization.md7.3 KB
  • references/simulation.md6.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

シミュレーション・数理最適化の必須セット(ルーター)

分析の実行と診断は不可分である。モデルを当てはめて係数やスコアだけを返すのは分析の前半でしかなく、 本スキルの適用下では未完了とみなす。ユーザーが診断・図・残差に言及しなくても、該当する references の図と値は必ず出す。

使い方(この順で)

  1. 下のルーティング表で、ユーザーが指示した手法(指示がなければ分析の主目的になる手法 1 つ)の行を見つける。複数の行を読むのは、手法を組み合わせるとき(例: シミュレーションで評価しながら最適化 → 両方)と、ユーザーが比較を指示したときだけ
    • 反復試行の出力分布そのもの、または最適解そのものが分析の目的のときだけ該当に数える。他の手法の中で使う乱数(default_rng / np.random による順列・ブートストラップ・サブサンプル・CV の分割)や、推定の部品としての scipy.optimize.minimize(最尤法など)は、コードに現れても該当に数えない
  2. その行の references/<手法>.md を読んでから実装する(読まずに回さない)
  3. 図を保存し、報告に「出力と報告」の判定表を載せる

ルーティング表

手法トリガー語彙(コード / 日本語)読むファイル
モンテカルロ・離散事象シミュレーション・感度分析SeedSequence.spawn scipy.stats.*.rvs simpy SALib sobol / モンテカルロ、反復試行、待ち行列、リスクreferences/simulation.md
LP / MIP / CP・非線形最適化・メタヒューリスティクスpulp LpProblem mip.Model pywraplp cp_model pyomo cvxpy linprog milp / 最適化、割当、スケジュール、配送references/optimization.md

隣接する手法(このルーターでは扱わない)

手法使う skill
MCMC によるベイズ推定、ブートストラップ CI、回帰・検定statistical-inference-diagnostics
ML のハイパラ探索(optuna / GridSearchCV)、予測モデルpredictive-modeling-diagnostics
A/B テスト・因果効果の推定causal-inference-diagnostics
クラスタリング・次元削減・異常検知unsupervised-eda-diagnostics

出力と報告(全手法共通)

  • 図は outputs/diagnostics/<YYYYMMDD-HHMM>_<短縮名>/ に保存する(短縮名は各 references の冒頭)。報告にはパスと下の表だけを載せ、図は貼らない
  • 図は 1 手法 1 枚の複合図を基本とし、各パネルのタイトルに「何を見る図か — 何が見えれば合格か」を書く。判定基準線は破線で描く
  • 乱数を使う処理は seed を固定し報告に明記する。日本語フォント・配色・保存形式は visualization skill に従う
  • コードの役割は図の保存と診断値の計算まで。値は「項目名 → 数値」の表(polars の DataFrame。pandas を返すライブラリの結果はそのまま載せてよい)にまとめて表示し、必要なら CSV で保存する。判定・合格基準・次アクションの文字列はコードで組み立てない
  • 報告の「診断サマリー」に次の表を載せる。実測値はコードが出した値を転記し、判定(OK / 要対処 / 確認=人間の判断待ち)と次アクションは references の合格基準と図を見て報告側で書く。要対処 には必ず次アクションを書く。全項目 OK でも表を出す
診断項目実測値合格基準判定次アクション
MC 標準誤差 / CI 半幅0.8 / 1.6(平均 120.4)報告桁より小さい要対処反復を 1,000 → 10,000 に増やす
status / sol_statusOptimal / Solution Found(時間切れ)Optimal Solution Found要対処gap 2.3%・60 秒と明記。時間延長か定式化強化

全手法共通の落とし穴

  • 「平均」「最適値」の 1 つの数字で終わらない。分布・裾・標準誤差、ソルバー status・制約の再検証・現行比の改善率が揃うまで未完了
  • 入力(分布・係数・制約)の根拠を書く。根拠のない入力で出した結果は「仮定の下の試算」と明記する
  • 小さな問題で解析解・厳密解・保存則と突き合わせてから本番規模に進む(実装バグの検出)
  • 次アクションに書いた別の手法(「メタヒューリスティクスでも解く」など)は報告上の提案であり、ユーザーの指示なしに実行しない。指示されていない手法の図を混ぜると、どの結果を採用したのかが読み手に伝わらない
  • 判定表をコードで生成しない。基準ごとの単純な閾値分岐だけでは、図や分析目的を踏まえた判断(件数は基準内でも図に形がある、など)を十分に扱えない。解釈・次アクションの文章をスクリプトに埋め込むと、分析コードも報告文で膨らむ(前提が崩れたら処理を止める assert は別)
    # NG: 判定と次アクションをコードの分岐で組み立てる
    verdict = "OK" if ci_half < 0.5 else "要対処"
    # OK: 値を表で出すだけ。判定と次アクションは報告に書く
    vals = {"mean": mean, "mcse": mcse, "ci_half": ci_half}
    print(pl.DataFrame({"項目": list(vals), "値": list(vals.values())}, strict=False))  # int・float・文字列が混ざっても落ちない
    

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Use this when summarizing analysis results, writing reports, documenting experiment outcomes, or presenting model evaluation — including structuring findings in Japanese with conclusions, facts, assumptions, interpretations, and caveats.

The English summary is being prepared. Showing the original description.

atsushi-green/ds-ai-coding-skills91Updated Oct 4, 2026

因果推論・効果検証(A/B テスト / ABテスト / オンライン実験 / リフト / SRM / CUPED、観察データの処置効果 / ATE / ATT / CATE / 傾向スコア / propensity score / IPW / 二重頑健 / DML / causal forest、準実験 / 差の差 / DiD / イベントスタディ / 操作変数 / IV / 2SLS / 回帰不連続 / RDD / 合成コントロール)を実行したら必ずセットで出す図と値のルーター。 proportions_ztest, chisquare, statsmodels.stats.power, dowhy, econml, causalml, doubleml, propensity, LinearDML, IV2SLS, rdrobust, rddensity, pysyncon, treat*post がコードに現れたとき、またはユーザーが「ABテストの結果を 見て」「施策の効果を推定して」「差の差で」「傾向スコアで揃えて」「閾値前後で比較して」と言ったときに使う。SRM・ バランス・並行トレンド・first-stage に言及がなくても適用する。SKILL.md のルーティング表で設計を特定し、対応する references/<設計>.md を読んでから実行する。実験でない群間比較の検定は statistical-inference-diagnostics、 予測モデルの解釈(SHAP 等)は predictive-modeling-diagnostics を使う。

The English summary is being prepared. Showing the original description.

atsushi-green/ds-ai-coding-skills91Updated Oct 4, 2026

Use this when performing DataFrame operations — including loading, filtering, joining, aggregating, transforming, or reshaping tabular data with polars or pandas.

The English summary is being prepared. Showing the original description.

atsushi-green/ds-ai-coding-skills91Updated Oct 4, 2026

Use this when creating, editing, executing, or reviewing Jupyter notebooks — including cell structure, kernel management, extracting reusable logic to src/, and ensuring notebooks are restartable.

The English summary is being prepared. Showing the original description.

atsushi-green/ds-ai-coding-skills91Updated Oct 4, 2026

Use this when reading from or writing to local files — including constructing file paths with pathlib, creating directories, choosing output locations, and using path utilities from src/analysis_project/paths.py.

The English summary is being prepared. Showing the original description.

atsushi-green/ds-ai-coding-skills91Updated Oct 4, 2026

分析を始める前に構造化された分析計画を作成する

The English summary is being prepared. Showing the original description.

atsushi-green/ds-ai-coding-skills91Updated Oct 4, 2026

See all skills by atsushi-green

Report a problem with this skill