YPEA for Python
Yarpiz Evolutionary Algorithms (YPEA) is a toolbox for defining an optimization problem once and solving it with any of its metaheuristics. This is the Python version of YPEA for MATLAB, redesigned and with the known defects fixed.
Status: early development (0.2.0). All 15 algorithms of YPEA for MATLAB and four modern baselines work. Benchmark suites, test problems and the experiment runner are being added.
Install
pip install ypea # core, needs only NumPy
pip install "ypea[plot]" # with matplotlib for plots
Python 3.12 or newer. To work on YPEA itself, clone the repository and run pip install -e ".[dev]".
Example
Find 20 real numbers in [-10, 10] that minimize the sphere function:
import ypea
problem = ypea.Problem(
vars=ypea.Real("x", shape=20, lb=-10, ub=10),
objective=lambda sol: ypea.benchmarks.sphere(sol.x),
)
pso = ypea.PSO(max_iter=100, pop_size=100, w=0.5, wdamp=1, c1=1, c2=2)
result = pso.solve(problem, seed=42)
print(result.best.solution.x)
print(result.best.obj_value)
Any other algorithm solves the same problem:
de = ypea.DE(strategy="DE/best/2/bin", max_iter=1000, pop_size=20,
beta_min=0.1, beta_max=0.9, crossover_prob=0.1)
result = de.solve(problem, seed=42)
Algorithms
The 15 algorithms of YPEA for MATLAB, with their known defects fixed:
| Class | Algorithm |
|---|---|
ABC |
Artificial Bee Colony |
ACOR |
Ant Colony Optimization for Continuous Domains |
BA |
Bees Algorithm (standard and probabilistic) |
BBO |
Biogeography-based Optimization |
CA |
Cultural Algorithm |
CMAES |
Covariance Matrix Adaptation Evolution Strategy |
DE |
Differential Evolution (rand, best, current-to-best, rand-to-best, bin and exp) |
FA |
Firefly Algorithm |
GA |
Genetic Algorithm |
HS |
Harmony Search |
ICA |
Imperialist Competitive Algorithm |
IWO |
Invasive Weed Optimization |
PSO |
Particle Swarm Optimization |
SA |
Simulated Annealing |
TLBO |
Teaching-Learning-based Optimization |
Four modern baselines for benchmark comparisons:
| Class | Algorithm |
|---|---|
JADE |
Adaptive Differential Evolution with external archive |
SHADE |
Success-History based Adaptive Differential Evolution |
LSHADE |
SHADE with Linear Population Size Reduction |
IPOPCMAES |
CMA-ES with restarts and increasing population size |
See docs/differences-from-matlab.md and docs/new-algorithms.md for details.
Decision variables
All variable types are encoded as numbers in [0, 1], so every algorithm can solve every problem. Decoded indices are 0 based.
| Type | Decodes to | Typical use |
|---|---|---|
Real(name, shape, lb, ub) |
real array in [lb, ub] | continuous optimization |
Integer(name, shape, lb, ub) |
integer array in [lb, ub] | generalized knapsack |
Binary(name, shape) |
0/1 array | knapsack |
Permutation(name, n, count=None) |
permutation of 0..n-1 (one per row) | TSP, QAP, n-Queens |
Selection(name, n, k, count=None) |
k distinct items out of n | feature selection |
BinarySelection(name, n, k, count=None) |
0/1 mask with k ones | feature selection |
Partition(name, n, k, count=None) |
list of k groups of items | vehicle routing, allocation |
BinaryPartition(name, n, k, count=None) |
(k, n) 0/1 assignment matrix | hub location allocation |
FixedSum(name, shape, target, axis=None) |
non negative reals with a fixed total, row sums or column sums | transportation |
A problem can mix several variables. The decoded solution has one attribute per variable (sol.x, sol.tour).
Constraints
The objective may return (f, g), where each value in g is satisfied when g <= 0. By default, solutions are compared with Deb's feasibility rules. Use constraints="penalty" for a penalty method.
def evaluate(sol):
x, y = sol.x
return (x - 1) ** 2 + (y - 2) ** 2, [x + y - 2]
problem = ypea.Problem(ypea.Real("x", shape=2, lb=-5, ub=5), evaluate)
Citing
For this Python version (see CITATION.cff):
Mostapha Kalami Heris, YPEA: Yarpiz Evolutionary Algorithms for Python, version 0.2.0, 2026. https://github.com/smkalami/ypea-python
For the original MATLAB toolbox:
Mostapha Kalami Heris, Yarpiz Evolutionary Algorithms Toolbox for MATLAB (YPEA), Yarpiz, 2020.
License
MIT
Metadata
Release files for ypea 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ypea-0.2.0.tar.gz | 52.5 kB | With provenance | Details for ypea-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ypea-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ypea-0.2.0-py3-none-any.whl |
Total release size: 110.9 kB
Release files / ypea-0.2.0.tar.gz
| Download URL | ypea-0.2.0.tar.gz |
|---|---|
| Size | 52.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22275c3028344cfd37030047e66f75f898d535ec85af3330c176fc148e3ed31b
|
|
BLAKE2b-256 checksum How to use checksums |
c4fe04fb1064c33241342adb8eb8b5a7c9f72727925f4f4d72599708c44bb92e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / ypea-0.2.0-py3-none-any.whl
| Download URL | ypea-0.2.0-py3-none-any.whl |
|---|---|
| Size | 58.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07cbff6f50c1056b0c116fcf819e746094c251f1eabd189bebb755c63b2031ba
|
|
BLAKE2b-256 checksum How to use checksums |
93f77cdd6dc6b790a3854fb4d38c725d931f85d5a2939d3b76004eaa5406057c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for ypea 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ypea-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.