# 关键代码快照与调用索引

本包复制了 59 个关键源码/许可文件，保留原相对目录与原始字节。每项提供逐行网页、原文件和 SHA-256。复制范围覆盖本文解释的核心计算链与实验入口；运行依赖、模型和完整数据沿用原工程。

代码阅读顺序为 `train → runner → policy → actor/critic → trainer/buffer`，环境通过离散封装进入 runner。v3.4 actor 的主要依赖为 HATTV33AA 中的关系算子与 HATTV20 中的编码/解码接口。AA 权重同时读取编码后的 query/key 与边特征，其信息依赖按方法章公式解释。

[完整哈希清单](code_manifest.json) · [环境和 actor 检查](evidence/implementation_checks.json)

网页中的行号固定到本次快照。队列等文件包含工作区已有修改，哈希标识的是实际打包内容；git HEAD 记录于清单，便于定位对应基础版本。


## 方法与 PPO 调用链

| 原路径 / 逐行阅读 | 对应作用 | 原文件 |
|---|---|---|
| [algorithms/algorithm/HATTV34Network.py](code_view/algorithms/algorithm/HATTV34Network.py.html) | v3.4 服务任务上下文、AA/AT 与候选路由；方法章主要实现 | [下载](code/algorithms/algorithm/HATTV34Network.py) |
| [algorithms/algorithm/HATTV33AANetwork.py](code_view/algorithms/algorithm/HATTV33AANetwork.py.html) | TypedRelationEdge 与 v3.3AA 基础；learned/uniform/zero 语义 | [下载](code/algorithms/algorithm/HATTV33AANetwork.py) |
| [algorithms/algorithm/HATTV20Network.py](code_view/algorithms/algorithm/HATTV20Network.py.html) | 实体编码器、CandidateEdgeDecoder、基础 actor 与 schema 投影 | [下载](code/algorithms/algorithm/HATTV20Network.py) |
| [algorithms/algorithm/gaRMAPPOPolicy.py](code_view/algorithms/algorithm/gaRMAPPOPolicy.py.html) | 图模型路由、actor/critic 构造与动作接口 | [下载](code/algorithms/algorithm/gaRMAPPOPolicy.py) |
| [algorithms/algorithm/ga_rmappo.py](code_view/algorithms/algorithm/ga_rmappo.py.html) | PPO 更新、active masks、损失与优化停止条件 | [下载](code/algorithms/algorithm/ga_rmappo.py) |
| [algorithms/algorithm/r_actor_critic.py](code_view/algorithms/algorithm/r_actor_critic.py.html) | MLP/recurrent actor 与集中式 critic | [下载](code/algorithms/algorithm/r_actor_critic.py) |
| [algorithms/algorithm/rMAPPOPolicy.py](code_view/algorithms/algorithm/rMAPPOPolicy.py.html) | 标准 MAPPO 策略对照 | [下载](code/algorithms/algorithm/rMAPPOPolicy.py) |
| [algorithms/algorithm/r_mappo.py](code_view/algorithms/algorithm/r_mappo.py.html) | 标准 PPO trainer | [下载](code/algorithms/algorithm/r_mappo.py) |
| [algorithms/utils/act.py](code_view/algorithms/utils/act.py.html) | 离散策略动作层 | [下载](code/algorithms/utils/act.py) |
| [algorithms/utils/mlp.py](code_view/algorithms/utils/mlp.py.html) | MLP 编码基础 | [下载](code/algorithms/utils/mlp.py) |
| [algorithms/utils/rnn.py](code_view/algorithms/utils/rnn.py.html) | 可选 recurrent 层 | [下载](code/algorithms/utils/rnn.py) |
| [algorithms/utils/distributions.py](code_view/algorithms/utils/distributions.py.html) | 动作分布与 log probability | [下载](code/algorithms/utils/distributions.py) |
| [runner/shared/macf_runner.py](code_view/runner/shared/macf_runner.py.html) | collect/insert、focal state、决策掩码、训练与评价 | [下载](code/runner/shared/macf_runner.py) |
| [runner/shared/base_runner.py](code_view/runner/shared/base_runner.py.html) | 训练器/buffer 初始化及公共流程 | [下载](code/runner/shared/base_runner.py) |
| [utils/shared_gat_buffer.py](code_view/utils/shared_gat_buffer.py.html) | Dict on-policy 数据与 GAE | [下载](code/utils/shared_gat_buffer.py) |
| [utils/shared_buffer.py](code_view/utils/shared_buffer.py.html) | MAPPO 对照 buffer | [下载](code/utils/shared_buffer.py) |
| [utils/obs_utils.py](code_view/utils/obs_utils.py.html) | 观测/state 展平及字段规则 | [下载](code/utils/obs_utils.py) |
| [utils/valuenorm.py](code_view/utils/valuenorm.py.html) | 价值归一化 | [下载](code/utils/valuenorm.py) |


## 环境与执行

| 原路径 / 逐行阅读 | 对应作用 | 原文件 |
|---|---|---|
| [envs/delivcoal/env_core.py](code_view/envs/delivcoal/env_core.py.html) | 当前主实验物理过程、观测、event、覆盖与奖励 | [下载](code/envs/delivcoal/env_core.py) |
| [envs/delivcoal/env_discrete.py](code_view/envs/delivcoal/env_discrete.py.html) | Gym Dict/Discrete 空间与环境封装 | [下载](code/envs/delivcoal/env_discrete.py) |
| [envs/delivcoal/env_wrappers.py](code_view/envs/delivcoal/env_wrappers.py.html) | 向量环境与自动 reset 接口 | [下载](code/envs/delivcoal/env_wrappers.py) |
| [envs/capcoal/env_core.py](code_view/envs/capcoal/env_core.py.html) | CapCoal 任务生成与执行语义 | [下载](code/envs/capcoal/env_core.py) |
| [envs/capcoal/env_discrete.py](code_view/envs/capcoal/env_discrete.py.html) | CapCoal 空间封装 | [下载](code/envs/capcoal/env_discrete.py) |
| [envs/macf/env_core.py](code_view/envs/macf/env_core.py.html) | MACF 基础环境及历史调用参照 | [下载](code/envs/macf/env_core.py) |
| [envs/gymrt2a/env_discrete.py](code_view/envs/gymrt2a/env_discrete.py.html) | 局部网格观测到 HATT 输入的适配 | [下载](code/envs/gymrt2a/env_discrete.py) |


## 训练和评价入口

| 原路径 / 逐行阅读 | 对应作用 | 原文件 |
|---|---|---|
| [config.py](code_view/config.py.html) | 参数定义与默认值；冻结有效配置字段见 evidence | [下载](code/config.py) |
| [train/train.py](code_view/train/train.py.html) | 训练入口、环境与 runner 选择 | [下载](code/train/train.py) |
| [train/eval.py](code_view/train/eval.py.html) | checkpoint 加载与独立评价 | [下载](code/train/eval.py) |
| [train/sweep.py](code_view/train/sweep.py.html) | 批量训练、checkpoint 与状态调度 | [下载](code/train/sweep.py) |
| [scripts/experiments/run_staged_validation_queue.py](code_view/scripts/experiments/run_staged_validation_queue.py.html) | 分阶段冻结 checkpoint 评估队列 | [下载](code/scripts/experiments/run_staged_validation_queue.py) |
| [scripts/experiments/run_final_window_queue.py](code_view/scripts/experiments/run_final_window_queue.py.html) | 末期逐 episode actor 评估 | [下载](code/scripts/experiments/run_final_window_queue.py) |


## 机制实验和实现核对

| 原路径 / 逐行阅读 | 对应作用 | 原文件 |
|---|---|---|
| [scripts/analysis/evaluate_priority_reconfiguration.py](code_view/scripts/analysis/evaluate_priority_reconfiguration.py.html) | 配对优先级事件、首次动作和闭环执行 | [下载](code/scripts/analysis/evaluate_priority_reconfiguration.py) |
| [scripts/analysis/summarize_priority_reconfiguration.py](code_view/scripts/analysis/summarize_priority_reconfiguration.py.html) | 按训练 seed 汇总配对效应 | [下载](code/scripts/analysis/summarize_priority_reconfiguration.py) |
| [scripts/analysis/evaluate_source_commitment.py](code_view/scripts/analysis/evaluate_source_commitment.py.html) | 共享状态库与源条件配对评价入口 | [下载](code/scripts/analysis/evaluate_source_commitment.py) |
| [scripts/analysis/eval_task_slot_permutation.py](code_view/scripts/analysis/eval_task_slot_permutation.py.html) | 任务槽重排、动作映射与配对统计 | [下载](code/scripts/analysis/eval_task_slot_permutation.py) |
| [tests/test_hatt_network.py](code_view/tests/test_hatt_network.py.html) | 排列、梯度、任务上下文、schema 初始化检查 | [下载](code/tests/test_hatt_network.py) |


## 本地基线与跨环境 actor

| 原路径 / 逐行阅读 | 对应作用 | 原文件 |
|---|---|---|
| [algorithms/algorithm/pcfa.py](code_view/algorithms/algorithm/pcfa.py.html) | 本项目 PCFA 联盟分配与资源规则 | [下载](code/algorithms/algorithm/pcfa.py) |
| [algorithms/algorithm/pcfa_policy.py](code_view/algorithms/algorithm/pcfa_policy.py.html) | 规则策略接口 | [下载](code/algorithms/algorithm/pcfa_policy.py) |
| [runner/pcfa/macf_runner.py](code_view/runner/pcfa/macf_runner.py.html) | PCFA 运行及 RNG 流评估 | [下载](code/runner/pcfa/macf_runner.py) |
| [runner/pcfa/base_runner.py](code_view/runner/pcfa/base_runner.py.html) | PCFA runner 基础 | [下载](code/runner/pcfa/base_runner.py) |
| [algorithms/qmix/qmix.py](code_view/algorithms/qmix/qmix.py.html) | QMIX/VDN trainer | [下载](code/algorithms/qmix/qmix.py) |
| [algorithms/qmix/algorithm/QMixPolicy.py](code_view/algorithms/qmix/algorithm/QMixPolicy.py.html) | individual-Q 策略 | [下载](code/algorithms/qmix/algorithm/QMixPolicy.py) |
| [algorithms/qmix/algorithm/agent_q_function.py](code_view/algorithms/qmix/algorithm/agent_q_function.py.html) | 个体 Q 网络 | [下载](code/algorithms/qmix/algorithm/agent_q_function.py) |
| [algorithms/qmix/algorithm/q_mixer.py](code_view/algorithms/qmix/algorithm/q_mixer.py.html) | 单调 mixer | [下载](code/algorithms/qmix/algorithm/q_mixer.py) |
| [runner/qmix/macf_runner.py](code_view/runner/qmix/macf_runner.py.html) | 值分解 rollout 与评估 | [下载](code/runner/qmix/macf_runner.py) |
| [utils/rec_buffer.py](code_view/utils/rec_buffer.py.html) | off-policy replay | [下载](code/utils/rec_buffer.py) |
| [algorithms/algorithm/HATTGyMRT2ANetwork.py](code_view/algorithms/algorithm/HATTGyMRT2ANetwork.py.html) | GymRT2A 空间候选 HATT actor | [下载](code/algorithms/algorithm/HATTGyMRT2ANetwork.py) |


## 外部方法适配与上游核心

| 原路径 / 逐行阅读 | 对应作用 | 原文件 |
|---|---|---|
| [experiments/reproduction/delivcoal_adapter_common.py](code_view/experiments/reproduction/delivcoal_adapter_common.py.html) | 共享 DelivCoal 配置读取与适配函数 | [下载](code/experiments/reproduction/delivcoal_adapter_common.py) |
| [experiments/reproduction/train_cfm_delivcoal.py](code_view/experiments/reproduction/train_cfm_delivcoal.py.html) | CFM pointer/POMO 配送训练 | [下载](code/experiments/reproduction/train_cfm_delivcoal.py) |
| [experiments/reproduction/eval_cfm_delivcoal.py](code_view/experiments/reproduction/eval_cfm_delivcoal.py.html) | CFM 采样/greedy 留出评价 | [下载](code/experiments/reproduction/eval_cfm_delivcoal.py) |
| [experiments/reproduction/run_marl_mrt2a_delivcoal.py](code_view/experiments/reproduction/run_marl_mrt2a_delivcoal.py.html) | MRT2A 配送训练入口 | [下载](code/experiments/reproduction/run_marl_mrt2a_delivcoal.py) |
| [experiments/reproduction/eval_marl_mrt2a_delivcoal.py](code_view/experiments/reproduction/eval_marl_mrt2a_delivcoal.py.html) | MRT2A 配送留出评价 | [下载](code/experiments/reproduction/eval_marl_mrt2a_delivcoal.py) |
| [third_party/heteromrta/attention.py](code_view/third_party/heteromrta/attention.py.html) | CFM 上游 AttentionNet | [下载](code/third_party/heteromrta/attention.py) |
| [third_party/heteromrta/worker.py](code_view/third_party/heteromrta/worker.py.html) | CFM 上游 rollout 与 success_rate 定义 | [下载](code/third_party/heteromrta/worker.py) |
| [third_party/heteromrta/LICENSE](code_view/third_party/heteromrta/LICENSE.html) | CFM 上游许可 | [下载](code/third_party/heteromrta/LICENSE) |
| [third_party/marl_mrt2a/marl_mrt2a/marl/src/envs/delivcoal_env.py](code_view/third_party/marl_mrt2a/marl_mrt2a/marl/src/envs/delivcoal_env.py.html) | 空间网格、legacy20/full27、路径意图适配 | [下载](code/third_party/marl_mrt2a/marl_mrt2a/marl/src/envs/delivcoal_env.py) |
| [third_party/marl_mrt2a/marl_mrt2a/marl/src/modules/agents/custom_agent.py](code_view/third_party/marl_mrt2a/marl_mrt2a/marl/src/modules/agents/custom_agent.py.html) | MRT2A 上游空间策略网络 | [下载](code/third_party/marl_mrt2a/marl_mrt2a/marl/src/modules/agents/custom_agent.py) |
| [third_party/marl_mrt2a/marl_mrt2a/marl/src/learners/ppo_learner.py](code_view/third_party/marl_mrt2a/marl_mrt2a/marl/src/learners/ppo_learner.py.html) | MRT2A 上游 PPO learner | [下载](code/third_party/marl_mrt2a/marl_mrt2a/marl/src/learners/ppo_learner.py) |
| [third_party/marl_mrt2a/LICENSE](code_view/third_party/marl_mrt2a/LICENSE.html) | MRT2A 上游许可 | [下载](code/third_party/marl_mrt2a/LICENSE) |

