get_reset_pool.py 882 B

12345678910111213141516171819202122232425262728293031323334
  1. import yaml
  2. from pathlib import Path
  3. from loader import load_all_units_cycles, resolve_path
  4. from state_construction import build_chem_cycle_state, STATE_COLUMNS
  5. def load_config(path: Path) -> dict:
  6. with open(path, "r", encoding="utf-8") as f:
  7. return yaml.safe_load(f)
  8. def generate_reset_state_pool(config_path: Path):
  9. cfg = load_config(config_path)
  10. project_root = Path(cfg["Paths"]["project_root"])
  11. output_dir = resolve_path(
  12. project_root,
  13. cfg["Paths"]["data_to_rl"]["output_dir"]
  14. )
  15. output_dir.mkdir(parents=True, exist_ok=True)
  16. df = load_all_units_cycles(cfg)
  17. df = df[df["chem_cycle_valid"] == True]
  18. state_df = build_chem_cycle_state(df)
  19. # 严格完整性过滤
  20. state_df = state_df.dropna(subset=STATE_COLUMNS)
  21. state_df.to_csv(
  22. output_dir / "reset_state_pool.csv",
  23. index=False
  24. )