state_construction.py 813 B

12345678910111213141516171819202122232425262728
  1. import pandas as pd
  2. STATE_COLUMNS = [
  3. "q_UF", "temp", "TMP", "R",
  4. "nuK", "slope", "power", "ceb_removal"
  5. ]
  6. def build_chem_cycle_state(df: pd.DataFrame) -> pd.DataFrame:
  7. """
  8. 从【物理周期层级】数据中构造
  9. 【化学周期层级】的 RL 状态。
  10. """
  11. grouped = df.groupby(["unit_id", "chem_cycle_id"])
  12. state_df = pd.DataFrame({
  13. "q_UF": grouped["flow_mean"].mean(),
  14. "temp": grouped["temp_mean"].mean(),
  15. "TMP": grouped["tmp_start"].first(),
  16. "R": grouped["R_scaled_start"].first(),
  17. "nuK": grouped["cycle_nuK"].first(),
  18. "slope": grouped["cycle_long_a"].first(),
  19. "power": grouped["cycle_long_b"].first(),
  20. "ceb_removal": grouped["cycle_R_removed"].first(),
  21. })
  22. return state_df.reset_index(drop=True)