mqt.ionshuttler.linear.result

Linear compilation outcomes and their JSON representation.

Module Contents

ActionDecoder
class CompilationStatus[source]

Bases: enum.StrEnum

Describe how compilation ended.

SUCCESS = 'SUCCESS'
TIMEOUT = 'TIMEOUT'
FAILED = 'FAILED'
INTERRUPTED = 'INTERRUPTED'
class CompilationResult[source]

Contain an executable schedule and compiler diagnostics.

The architecture and action schedule are parallel compilation artifacts. This result also owns search completion, cost, runtime, explored-node count, and the compiler state reached at termination.

status: CompilationStatus
schedule: ActionSchedule
architecture: Architecture
wall_clock_s: float = 0.0
score: int | None = None
final_state: State | None = None
explored_nodes: int | None = None
__post_init__() → None[source]

Validate compiler diagnostics and the schedule boundary.

Raises:
  • TypeError – If a result field has the wrong type.

  • ValueError – If a numeric diagnostic is outside its valid range.

property path: list[Action]

A mutable copy of the schedule’s ordered executable operations.

property num_timesteps: int

The schedule’s makespan.

property initial_state: MachineState

The schedule’s machine-only initial state.

to_dict() → dict[str, object][source]

Return the compilation result using JSON-compatible values.

classmethod from_dict(data: object, *, action_types: Sequence[type[Action]] | None = None, action_decoders: ActionDecoders | None = None) → CompilationResult[source]

Restore a result from its JSON-compatible representation.

Returns:

The restored compilation result.

Raises:

ValueError – If the document is malformed.

to_json() → str[source]

Serialize this compilation result as JSON text.

Returns:

The JSON document.

classmethod from_json(raw: str, *, action_types: Sequence[type[Action]] | None = None, action_decoders: ActionDecoders | None = None) → CompilationResult[source]

Restore a result from JSON text.

Returns:

The restored compilation result.

save(filename: str | Path, directory: str | Path = 'outputs/results/json') → Path[source]

Write this result to a UTF-8 JSON file.

Parameters:
  • filename – Output filename, with .json added when omitted.

  • directory – Directory in which to create the file.

Returns:

The path written.

classmethod load(filename: str | Path, *, action_types: Sequence[type[Action]] | None = None, action_decoders: ActionDecoders | None = None) → CompilationResult[source]

Load a result from a UTF-8 JSON file.

Returns:

The restored compilation result.