LightsOut Decoder

QECC provides means to decode quantum codes based on an analogy to the well-known LightsOut puzzle.

The main class for the decoder is the LightsOut class.

class LightsOut(lights_to_switches, switches_to_lights, switch_vars=None, helper_vars=<factory>, optimizer=<factory>)[source]

Lights out problem representation.

complete_parity_constraint(light, indices, val)[source]

Completes the parity constraints for a light.

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

Return type:

None

count_switches(model)[source]

Count the number of switches that are set to true.

Return type:

int

preconstruct_parity_constraint(light, indices)[source]

Preconstruct the parity constraints for a light.

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

Return type:

None

preconstruct_z3_instance()[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.

Return type:

None

solve(lights, solver_path='z3')[source]

Solve the lights-out problem for a given pattern.

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

Return type:

tuple[list[int], timedelta, timedelta]

validate_model(model, lights)[source]

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

Return type:

bool

The main function for the decoder is the run() function.

run(lattice_type, distance, error_rate, nr_sims=10000, results_dir='./results_maxsat', solver='z3')[source]

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

Return type:

None