Evaluation

dsbx.Eval

Evaluation utilities for dynamic scheduling trajectories.

This package starts with a lightweight trajectory representation that can be produced by environments and simulators, and will be extended with constraints and metric computation utilities.

class dsbx.Eval.StepRecord(**data)

Bases: BaseModel

A single step in a scheduling trajectory.

Each step records the decision point time, the full snapshot and the action that led to it. The info field can hold arbitrary metadata (e.g. rewards, solver stats).

Parameters:
  • time (float)

  • snapshot (Snapshot)

  • action (Dict[str, Any] | None)

  • info (Dict[str, Any])

time: float
snapshot: Snapshot
action: Dict[str, Any] | None
info: Dict[str, Any]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class dsbx.Eval.Trajectory(**data)

Bases: BaseModel

A sequence of decision points for a single scenario/run.

In the disk-backed setting, this model acts primarily as a lightweight handle around a JSONL file that stores one header line with static context followed by per-step dynamic records. The legacy steps list is preserved for compatibility but is no longer required to hold the entire trajectory in memory.

Parameters:
  • steps (List[StepRecord])

  • scenario_id (str | None)

  • seed (int | None)

  • config (Dict[str, Any])

  • static_context (StaticContext | None)

steps: List[StepRecord]
scenario_id: str | None
seed: int | None
config: Dict[str, Any]
static_context: StaticContext | None
append_step(step)

Append an in-memory step (legacy behaviour).

Return type:

None

Parameters:

step (StepRecord)

property last_snapshot: Snapshot

Return the last snapshot, streaming from disk if necessary.

iter_steps()

Iterate over all steps in the trajectory.

If a backing JSONL file is configured, steps are streamed from disk and static context is injected on the fly. Otherwise, this falls back to iterating over the in-memory steps list.

Return type:

Iterator[StepRecord]

iter_summaries()
Return type:

Iterator[Dict[str, Any]]

classmethod load_from_disk(path)

Create a disk-backed Trajectory from a JSONL file.

The file is expected to contain:

  • a first header line with a static_context object; and

  • subsequent lines describing individual steps with at least time and snapshot fields.

Return type:

Trajectory

Parameters:

path (Path)

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None