Metadata-Version: 2.4
Name: EvoCore
Version: 0.1.0
Summary: Libreria de algoritmos geneticos flexible y extensible
Author-email: Sergio Alcántara Avilés <sergioalc89@gmail.com>
License: MIT License
        
        Copyright (c) [2026] [Sergio Alcántara Avilés]
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: sphinx>=7.0; extra == "dev"
Requires-Dist: furo>=2024.1.0; extra == "dev"
Requires-Dist: numpydoc>=1.8.0; extra == "dev"
Requires-Dist: myst-parser>=3.0.0; extra == "dev"
Requires-Dist: build>=1.2.0; extra == "dev"
Dynamic: license-file

# EvoCore

Librería Python para construir y experimentar con algoritmos genéticos mediante un núcleo fijo y operadores intercambiables.

## ¿Qué es EvoCore?

EvoCore permite ejecutar algoritmos genéticos sin tocar el núcleo evolutivo. Los operadores de selección, cruce, mutación e inicialización se inyectan como dependencias, lo que hace que la librería sea fácil de extender y adaptar a cualquier problema.

## ¿Por que EvoCore?

Aqui Sergio explicara en el futuro que diferencia esta libreria del resto.

## Instalación

Puede ser instalada desde pip.

En caso de querer instalar desde el repositorio:

- Python 3.10 or higher
- NumPy >= 1.26

Optional development dependencies (tests, documentation):

- pytest >= 8.0
- sphinx >= 7.0
- furo >= 2024.1.0
- numpydoc >= 1.8.0
- myst-parser >= 3.0.0
- build >= 1.2.0

```bash
   git clone https://github.com/tu-usuario/evocore.git
   cd evocore
   python3 -m venv .venv
   source .venv/bin/activate        # Linux / macOS
   .venv\Scripts\activate           # Windows
   pip install -e .[dev]
```

## Uso rápido

El siguiente ejemplo resuelve el problema OneMax: maximizar el número de unos en un cromosoma binario.

```python
import random
from evocore import GeneticAlgorithm, GeneticAlgorithmConfig, Individual
from evocore import TournamentSelection
from evocore import OnePointCrossover
from evocore import BitFlipMutation
from evocore import RandomBinaryInitializer

# Función de fitness: cuenta el número de unos
def onemax(solution, data=None):
    return float(sum(solution))

# Configuración del algoritmo
config = GeneticAlgorithmConfig(
    population_size=50,
    generations=100,
    crossover_rate=0.8,
    mutation_rate=0.01,
    elitism=2,
    seed=42,
)

# Construcción del algoritmo con operadores intercambiables
ga = GeneticAlgorithm(
    config=config,
    initializer=RandomBinaryInitializer(chromosome_length=20),
    selection=TournamentSelection(tournament_size=3),
    crossover=OnePointCrossover(),
    mutation=BitFlipMutation(mute_probability=0.1),
    fitness_function=onemax,
)

# Ejecución
best, history = ga.run()

print(f"Mejor solución: {best.solution}")
print(f"Fitness:        {best.fitness}")
print(f"Generaciones:   {len(history.records)}")
```

## Operadores disponibles

| Familia | Operador | Codificación |
|---|---|---|
| Selección | `TournamentSelection` | Cualquiera |
| Selección | `RouletteWheelSelection` | Cualquiera |
| Cruce | `OnePointCrossover` | Binaria |
| Cruce | `UniformCrossover` | Binaria |
| Mutación | `BitFlipMutation` | Binaria |
| Inicialización | `RandomBinaryInitializer` | Binaria |

## Estructura del proyecto

```
   src/evocore/
   ├── __init__.py              ← public API
   ├── core/
   │   ├── algorithm.py         ← GeneticAlgorithm (evolutionary loop)
   │   ├── config.py            ← GeneticAlgorithmConfig
   │   ├── individual.py        ← Individual
   │   ├── history.py           ← History, GenerationRecord
   │   └── population.py        ← population utilities
   ├── operators/
   │   ├── base.py              ← GeneticOperator (abstract)
   │   ├── selection/           ← 5 selection operators
   │   ├── crossover/           ← 7 crossover operators
   │   ├── mutation/            ← 5 mutation operators
   │   └── initialization/      ← 3 initializers
   ├── encodings/
   │   ├── base.py              ← Encoding (abstract)
   │   ├── binary.py
   │   ├── real.py
   │   └── permutation.py
   ├── metrics/
   │   ├── base.py              ← Metric (abstract)
   │   ├── fitness_variance.py
   │   ├── diversity.py
   │   ├── stagnation.py
   │   ├── mean_fitness.py
   │   └── selection_pressure.py
   ├── gp/                      ← Genetic Programming module
   │   ├── node.py
   │   ├── primitives.py
   │   ├── adf.py
   │   ├── individual.py
   │   ├── evaluation.py
   │   └── operators/
   └── utils/
       ├── validation.py        ← shared validation functions
       └── random.py            ← random chromosome generators
```

## Tests

```bash
pytest -v
```

## Documentación

file:///home/sergio/Escritorio/Uni/TFG/GA/docs/build/html/index.html

## Estado del proyecto

Finalización de la etapa 1.0, en futuras versiones se planea apliar el modulo de programación genetica. 

## Licencia

MIT
