Files
EOS/docs/adr/0009-optimization-parameters-are-dataclasses.md
T
Bobby NoelteandClaude Opus 5.5 9adf7b8be2 docs(optimization): add optimizer architecture ADRs, skill and test (#1572)
Additional changes
- Add the optimizer terms to the glossary.
- Point to the skill from AGENTS.md, docs/develop/ai.md and the energy-domain skill.
- Match module names case-exactly, also on case-insensitive file systems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-27 13:55:41 +01:00

1.4 KiB

Optimization parameters are dataclasses, optimization requests are Pydantic models

The optimization parameters are read in the innermost loops of an optimization run, and they no longer cross the public API: clients send optimization requests, which parameter preparation completes into optimization parameters (0006). So the optimization parameters, including the device parameters of the simulation, are plain Python dataclasses (@dataclass(frozen=True, slots=True): a run never changes its inputs, and slots keep attribute access fast), never Pydantic models; they are valid by construction because parameter preparation always builds a valid set (see the energy-domain skill), not because a model validates them. Validation and the public schema live where external input arrives: optimization requests are Pydantic models, and the settings models of the configuration stay Pydantic models.

Considered Options

  • Pydantic models for the optimization parameters: rejected. Attribute access and copies of Pydantic models cost time in the run, and the validation they offer is redundant behind a parameter preparation that never produces an invalid set.

Consequences

  • An invalid optimization parameter set is a bug in parameter preparation, found by its tests, not a validation error at run time.
  • Replay files need an explicit (de)serialization of the dataclasses instead of Pydantic's.