mqt.qecc.cc_decoder.decoder

LightsOut MaxSAT-based decoder for the hexagonal color code.

Classes

LightsOut

Lights out problem representation.

Functions

simulate_error_rate(code, error_rate, nr_sims[, ...]) → dict[str, Any]

Simulate the logical error rate for a given distance and error rate.

run(lattice_type, distance, error_rate[, nr_sims, ...]) → None

Run the decoding simulation for a given distance and error rate.

Module Contents

class LightsOut[source]

Lights out problem representation.

preconstruct_parity_constraint(light: int, indices: list[int]) → None[source]

Preconstruct the parity constraints for a light.

Adds all constraint to the optimizer that are independent of the value of the light.

complete_parity_constraint(light: int, indices: list[int], val: bool) → None[source]

Completes the parity constraints for a light.

Adds the constraint that is dependent on the value of the light.

preconstruct_z3_instance(weights: numpy.typing.NDArray[numpy.float64] | None = None) → None[source]

Preconstruct the z3 instance for the lights-out problem.

Creates all necessary variables, adds the known parts of the parity constraints. Soft constraints are added to the optimizer with default weights.

validate_model(model: z3.ModelRef, lights: list[bool]) → bool[source]

Validate the model by checking if pressing the switches turns off all lights.

count_switches(model: z3.ModelRef) → int[source]

Count the number of switches that are set to true.

solve(lights: list[bool], solver_path: str = 'z3', timeout: int = 1800) → tuple[list[int], bool, float][source]

Solve the lights-out problem for a given pattern.

Assumes that the z3 instance has already been pre-constructed.

simulate_error_rate(code: ColorCode, error_rate: float, nr_sims: int, solver_path: str = 'z3') → dict[str, Any][source]

Simulate the logical error rate for a given distance and error rate.

run(lattice_type: str, distance: int, error_rate: float, nr_sims: int = 10000, results_dir: str = './results_maxsat', solver: str = 'z3') → None[source]

Run the decoding simulation for a given distance and error rate.