evopy
Evolutionary Strategies made simple!
Use evopy to easily optimize a vector of floats in Python.
🏗 Installation
All you need to use evopy is Python 3! Run this command to fetch evopy from PyPI:
pip install evopy
Then you can import EvoPy like this:
from evopy import EvoPy
⏩ Usage
One-Dimensional Example
Let's say we wanted to find the optimum of a parabola, without using exact methods from calculus! With Evopy, this is as easy as writing the following two lines:
evopy = EvoPy(lambda x: pow(x, 2), 1)
best_coordinates = evopy.run()
The main ingredient here is the fitness function (the lambda). This can also be a normal function reference, just make sure that it accepts a float or an array of floats and outputs a single float. The other ingredient is the 1 at the end of the first line: This is the dimensionality of the inputs that you expect in your fitness function. best_coordinates will contain an array with a single element, which is the best x value the algorithm could find in the default number of generations.
Multi-Dimensional Example
If the previous example seemed too simple to you, we can also look at the optimum of a more complex, two-dimensional function, like the Rastrigin function. We don't have to modify much in our previous code snippet to get this to work:
evopy = EvoPy(
lambda X: 5 + sum([(x**2 - 5 * np.cos(2 * np.pi * x)) for x in X]),
2,
generations=1000,
population_size=100
)
best_coordinates = evopy.run()
Compared to the first example, we have interchanged the fitness function for a more complex one, set the dimensionality to 2, and given the algorithm more time to find an optimum by setting a higher generation and individual count than the default.
Docs
For more detailed information on evopy's functionality, have a look at the docs!
⛏ Development
Clone this repository and fetch all dependencies from within the cloned directory:
pip install -r requirements.dev.txt
Run all tests with:
nosetests
To check your code style, run:
pylint evopy
To measure your code coverage, run:
nosetests --with-coverage --cover-package=evopy --cover-html --cover-branches --cover-erase
Metadata
Release files for evopy 0.3
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 |
|---|---|---|---|---|
| evopy-0.3.tar.gz | 7.1 kB | Without provenance | Details for evopy-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| evopy-0.3-py3-none-any.whl | Python 3 | none | any | Details for evopy-0.3-py3-none-any.whl |
Total release size: 15.6 kB
Release files / evopy-0.3.tar.gz
| Download URL | evopy-0.3.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3b3c122383a98b3ee9647fb26b07d8cbf656a3ac929cfd2cd98268ea3262fdb
|
|
BLAKE2b-256 checksum How to use checksums |
481b9333e30a7930feba44a443be9d06f6e283ea8a1f5df915704a7aba85cfe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
|
Release files / evopy-0.3-py3-none-any.whl
| Download URL | evopy-0.3-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd1b909cc949f77564d6cf6eb43cf609660e73d6b6b584d16a5937849eac9a81
|
|
BLAKE2b-256 checksum How to use checksums |
25c1000d76d1df352ac1353681180d8b778799d4527683781b9447ebe68a15da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
|
Security for evopy 0.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.