Skip to main content

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

xevo-0.5.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file xevo-0.5.tar.gz.

File metadata

  • Download URL: xevo-0.5.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

Hashes for xevo-0.5.tar.gz
Algorithm Hash digest
SHA256 ff4176e1f81082996cbe6ab4e40274c851c2768980b60e5154b9c3c7a16962f6
MD5 7e35f3a9288ba99ff814c3b8cc9c265d
BLAKE2b-256 b7157f0308545ac52ffb911489bd8956eb2ae8781df8aac8b4191da54fc6ee90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page