A simple polymorph evolutionary class system
Project description
xevo
This is a simple set of classes to use for evolutionary coding in a polymorphic way. The central classes are given by "eobj", which implements the basic structure for an object that will be optimized by the second one "evo", which handles the optimization.
#eobj Each eobj needs to at least implement: def add(a,b): how to combine objects a and b def randomize(s): return a new completely random version of this class def mutate(s): return a sligthly mutated version of this object def calcstrength(s)->float: how strong is this objects version def _copy(s): copy the specifics of this object
you can also override shallmaximize->bool to chance if the strength should be maximized
Finally init(s) should not contain any nonoptional parameters and call s.initial()
There are two simple examples of this object. pion.py tries to find a fixed value (aka np.pi) and bitflip.py tries to maximize the sum of a list of booleans. This is very simple and implements a simple counter, that counts how often any state is evaluated. You can also take a look at the deep learning example below.
#evo This object only needs to implement two functions def generation(s)->None: update the objects (stored in s.q) def _copy(s) -> "subclass of evo": copy the specifics of this object
Here there is a simple example implemented in crossevo (which is also given in the package), of a batch of object, in which 2 random objects figth against each other and the weaker one is replaced by either a combination of both objects, or by a mutation of the winning one.
#erun Runs an experiment given an evo object and an eobj object. You can also specify the size population in the initializer. To run the experiment call run(s,maxsteps=1000000,goalstrength=1000000.0), where maxsteps is the maximum number of generation calls that can be called. And by beating goalstrength the run is stopped before. After the run, you can call show_history(s,log=False) to show a strength history (with an optional logarithmic y axis (if log=True))
#machine learning If you take a look at the eobj deep (deep.py and deeptools.py), you find a simple optimizer object, which tries to find the perfect network setup for a keras dense network setup. So using it requires keras and tensorflow.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file xevo-0.52.tar.gz
.
File metadata
- Download URL: xevo-0.52.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 605cd89d2031698bc0e61c5c97523811ab7d7cb270baaba3df802b971bf0e4ba |
|
MD5 | 1d1f0f7488be6a9e120fa5eb1a8e0803 |
|
BLAKE2b-256 | 31f057cafb2ca647bd41ced03e8af20cae31e8b9b40118d65df724d7e60fb855 |
File details
Details for the file xevo-0.52-py3-none-any.whl
.
File metadata
- Download URL: xevo-0.52-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85ba5583e570e3a0ca47ac035efe6b4e1c6b7b8b0efba14d9a8c03bc045ef799 |
|
MD5 | b0a824ee689834c5f185559d7e3fec93 |
|
BLAKE2b-256 | fc6e201c8574a9fa431de216e931b3d5ae33654626b83339cab6ded71853db5c |