OptimizationRunConfigurationToml

TOML codec for OptimizationRunConfiguration.

Uses tomlkt, which integrates directly with kotlinx-serialization. The same @Serializable types serve both JSON and TOML.

TOML is the preferred format for hand-authored optimization configurations because it supports comments, table-header syntax, and array-of-tables syntax that read more cleanly than JSON for nested structures.

Sealed-class polymorphism is encoded via the standard kotlinx-serialization discriminator pattern; tomlkt emits the discriminator as a type = "..." key on the table representing the sealed value. This applies to SolverSpec, TemperatureSpec, CoolingScheduleSpec, CESamplerSpec, and PenaltyFunctionSpec.

Output shape

Encoded output begins with the multi-line DOCUMENT_HEADER banner (a sequence of #-prefixed lines describing the file's layout and editing rules); per-field @TomlComment annotations on the spec data classes appear inline above each key. Both layers of comments are ignored by the decoder.

The configured Toml instance sets explicitNulls = false so that optional fields with null values are omitted from the encoded output rather than rendered as field = null lines. Decoding is symmetric — a missing key takes the property's declared default.

Functions

Link copied to clipboard

Deserialises an OptimizationRunConfiguration from a TOML string produced by encode.

Link copied to clipboard

Serialises config to a TOML string, prefixed with DOCUMENT_HEADER.