GeneticConfiguration
public struct GeneticConfiguration
Configuration of a genetic algorithm to evolve a quantum circuit
-
Errors throwed by
See moreGeneticConfiguration.init(depth:generationCount:populationSize:tournamentSize:mutationProbability:threshold:errorProbability:)
Declaration
Swift
public enum InitError : Error
-
Number of gates in an evolved circuits will be between the boundaries specified by
depth
Declaration
Swift
public let depth: Range<Int>
-
Maximum number of times a reproduction operation will be applied to increase the number of evolved circuits in a population
Declaration
Swift
public let generationCount: Int
-
Number of evolved circuits produced by a genetic algorithm will be between the boundaries specified by
populationSize
. The minimum size is the size of the initial population of randomly generated circuitsDeclaration
Swift
public let populationSize: Range<Int>
-
A reproduction operation is applied over a sub-set of the entire population of evolved circuits.
tournamentSize
is the size of this sub-setDeclaration
Swift
public let tournamentSize: Int
-
There are 2 reproduction operations: cross-over and mutation.
mutationProbability
is the probability of applying the latter on each new generation. It is expected to take a value between 0.0 and 1.0Declaration
Swift
public let mutationProbability: Double
-
An evolved circuit is evaluated against multiple
GeneticUseCase
instances. Each evaluation returns a a score, the lowest the score, the better a circuit solves a givenGeneticUseCase
instance. If the score is below thisthreshold
, the circuit is considered in the right track to solve the use caseDeclaration
Swift
public let threshold: Double
-
If the total score of an evolved circuit (i.e. the score considering all
GeneticUseCase
instances) is belowerrorProbability
, the circuit is considered a solution for the entire problemDeclaration
Swift
public let errorProbability: Double
-
init(depth:
generationCount: populationSize: tournamentSize: mutationProbability: threshold: errorProbability: ) Initialize a
GeneticConfiguration
instanceDeclaration
Swift
public init(depth: Range<Int>, generationCount: Int, populationSize: Range<Int>, tournamentSize: Int, mutationProbability: Double, threshold: Double, errorProbability: Double) throws