Python module dedicated to the evolution of logic circuits through genetic algorithms
Project description
VLCDA
Virtual Logic Circuits Design Automation
Python module dedicated to the evolution of logic circuits through genetic algorithms
- Evolving Combinational Logic Circuits through genetic algorithm
- A set of Odd Parity Generetors evolveds until the 100% Fitness
To exploit the true potential of emerging nanotechnologies, automation of the electronic design (EDA) of digital systems must be rethought. The digital projects for the nanoelectronic age it must be immune to defects and accept variability. curiosity- Mind you, these are characteristics of biological systems shaped by evolution. algorithms genetics can be used for the synthesis of digital systems when hard- fully integrated ware, such as those imposed by programmable devices. It has even been pointed out that as digital circuits evolve, fault handling strategies recognized by evolution reappear naturally.
Installation
VEDA module requires Python 3 and some basics modules to run.
- Random
- Datetime
- Bisect
If you don't have theses modules, run the following commands:
pip install random
pip install datetime
pip install bisect
To install the module VEDA run the following commands...
pip install VLCDA
Be sure to maintain pip updated ...
pip install --upgrade VLCDA
Class Genoma
The Genoma
class represents an individual genome in the genetic algorithm.
Method __init__(self, numberOfGenes, nInputs, nOutputs)
numberOfGenes
: The number of genes in the genome.nInputs
: The number of inputs.nOutputs
: The number of outputs.
Method generate_parent(self)
Generates a random parent genome.
Method mutate(self)
Applies mutation to the genome.
Method copyGene(self, childGenome)
Copies the genes from the current genome to another genome.
Method calculateFitness(self, logicFunction)
Calculates the fitness of the genome based on a specified logic function.
Method calculateNoiseFitness(self)
Calculates the noise fitness of the genome.
Method setFaultChance(self)
Sets the fault chance for the genome.
Method setFitness(self, fitness)
Sets the fitness of the genome.
Method setGenotipo(self, a)
Sets the genotype of the genome.
Method getGenotypeActiveZone(self)
Returns the genes in the active zone of the genotype.
Method getGenotypeDeadZone(self)
Returns the genes in the dead zone of the genotype.
Method identify_deadGenes(self)
Identifies the dead genes in the genome. It is used in others methods to optimize some of the evolution steps.
Class GeneticAlgorithm
The GeneticAlgorithm
class implements a genetic algorithm to evolve genomes towards a desired solution.
Method __init__(self, y=10, maxGeneration=4000000)
y
: The number of children generated per generation.maxGeneration
: The maximum number of generations allowed.
Method display(self, guess, fitness, noiseFitness, totalGeneration)
Displays information about the current generation, including genotype, fitness, noise fitness, and the total number of generations. It will be shown every 1000 generation.
Method addToFitnessList(self, childFitness)
Adds choosen fitness off the generation to the fitness list, ensuring sorting (Will be usefull to plots in future methods).
Method showBarPlot(self, genome_id, samplingLen)
Displays a bar plot representing the frequency distribution of fitnesses in the population.
Method getBestGenomeWithSize(self, listChild)
Returns the genome with the best fitness and shortest genome size in a list of children.
Method getBestGenome(self, listChild)
Returns the genome with the best fitness in a list of children.
Method evolution(self, genome, logicFunction)
It performs the process of evolution of the genetic algorithm. This includes generating the y
children, mutation, selecting the best genomes, and displaying progress information.
This class is used to evolve genomes toward an optimal solution by applying mutations and natural selection over several generations until a stop criterion is reached or the desired solution is found. The logical function needs to be provided, or one of the module's implementations can be used.
Usage
Lets see an example of how to evolving an Parity Generator with de VLCDA module.
- Install the required dependencies (e.g.,
from VLCDA import Logic_Circuits_Evolution as LCE
). - Set the parameters for the genetic algorithm:
nGenes
: Number of genes in each genome.nOutputs
: Number of output nodes.nInputs
: Number of input nodes.
- Create an initial genome:
nGenes = 60 nOutputs = 1 nInputs = 4 genome = LCE.Genoma(nGenes, nInputs, nOutputs)
- Initialize the genetic algorithm:
geneticAlgorithm = LCE.GeneticAlgorithm()
- Evolve the genome using the
gpinand
function:geneticAlgorithm.evolution(genome, genome.gpinand)
To see the evolveds odd parity generetor sample (PG1 to PG9), you can do the following:
-
Install the required dependencies (e.g.,
from VLCDA import PGs_Collection as PGs
). -
Initialize the genetic algorithm:
PGs.PG_collection["PG1"]
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file VLCDA-1.0.11.tar.gz
.
File metadata
- Download URL: VLCDA-1.0.11.tar.gz
- Upload date:
- Size: 103.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f137280dfedcc5462183058da03a843c1f37509c9fcd612f1a87a86e025d524e |
|
MD5 | ee35365f9b5344b31a80f791607adcb3 |
|
BLAKE2b-256 | 71b7a0824e37209c988feb2da63f09c4cc9947379ce3b608b1f04130a4ca7b88 |