GeneticFactory
public protocol GeneticFactory
A genetic algorithm to find a quantum circuit that includes a Gate.oracle(truthTable:target:controls:)
and solves a list of GeneticUseCase
instances.
-
Result type returned by
GeneticFactory.evolveCircuit(configuration:useCases:gates:)
.Values returned:
eval
: Score of the evolded circuit. The nearer to 0, the better solution the circuit is.gates
: Evolved circuit.oracleAt
: Position ofGate.oracle(truthTable:target:controls:)
ingates
.
Declaration
Swift
typealias EvolvedCircuit = (eval: Double, gates: [Gate], oracleAt: Int?)
-
Look for a quantum circuit that solves a list of
useCases
using onlygates
and the parameter informed in theconfiguration
.Declaration
Swift
func evolveCircuit(configuration config: GeneticConfiguration, useCases: [GeneticUseCase], gates: [ConfigurableGate]) -> Result<EvolvedCircuit, EvolveCircuitError>
Parameters
configuration
A
GeneticConfiguration
instance wih the parameters for a genetic algorithm.useCases
List of
GeneticUseCase
instances for which the algorithm looks for a circuit that solves all of them simultaneously.gates
List of allowed gates, i.e. the evolved circuit will only include gates specified in this list and, if necessary, an oracle gate.
Return Value
An
EvolvedCircuit
instance. OrEvolveCircuitError
error.