Cybersecurity challange on HackYeah2024
Find the best path covering all the cities/points without repeating any. This task aims to minimize the total distance or cost of travel, and is widely used in logistics, planning, and routing.
- We have population of solutions
-
Solutions change with each new generation, mixing and creating potentially better solutions
-
But they can get stuck in a local minimum, and no longer improve in new generations
- In such case, we need some random unexpected change - a mutation, that will modify solutions.
- Applying mutations allows us to "unstuck" from local optimal solution.
- uses quantum bits that represent probability between 0 and 1
- operates on circuits consisting of quantum gates
- generates noise, unexpected outcomes, as a side-effect
Noise is a side-effect, something unexpected, outcome that “shouldn’t be possible”. Even though we can make use of it! For example a gate below has only two possible outputs: [00, 11]. But on quantum computers it can generate some unexpected outputs.
# create a Quantum Circuit with 2 qubits and 2 classical bits
qc = QuantumCircuit(2, 2)
# apply a Hadamard gate on qubit 0
qc.h(0)
# apply a CNOT gate on qubit 0 and qubit 1
qc.cx(0, 1)
# measure the qubits
qc.measure([0, 1], [0, 1])
Outcome per 1024 shots on a real quantum computer (on non-quantum computer, 0010 or 0001 would never occur)
Similarly to mutation, it’s an unepxected change that happens randomly. It’s possible to be received with different frequency, depending on a quantum machine and conditions.
# if anomaly occurs, then apply mutation
def should_apply_mutation():
res = self.qiskit_runtime.run(shots=1)
return
res.get('01', 0) > 0
or
res.get('10', 0) > 0
We also created a platform where you can simulate how this algorithm would work on a quantum computer with a given noise level.
git clone git@github.com:HackYeahKabanosy/quantum_genetic_algorithm.git
pip install -r requirement.txt
python program.py