Skip to main content

An evolutionary computation algorithm named CPIE in Python.

Project description

cpie

Clustering-based Promising Individual Enclosre(CPIE) in Python.

CPIE is an evolutionary computation algorithm which aims to search best parameters minimizing black-box function, especially UV-function.
UV-function has U-valley, which occupies large search space but contains only local optima, and V-valley, which occupies small search space but contains global optima.
e.g. Double-sphere: f(x) = min((x-2)^2 + 0.1, 10*(x+2)^2)

Installation

$ pip install cpie

CPIE depends on numpy, so please install numpy if needed.

Example of usage

First, you can import CPIE module as below.

    from cpie import CPie

Then, you need to prepare objective function to be minimized.

    def sphere(x):
        return sum(xi*xi for xi in x)

    def objective_func(x):
        return min(sphere(x-2)+0.1, 10*sphere(x+2))

You can minimize objective function like below.

    dimension = 2
    bounds_min = [-10.0] * dimension
    bounds_max = [ 10.0] * dimension
    cpie = CPie(bounds_min, bounds_max, Ns=7*dimension)
    for i in range(2000):
        solution = cpie.sample()
        f_value = objective_func(solution)
        cpie.update(f_value)
        cpie.print()

"bounds_min" and "bounds_max" means search space.
CPIE starts optimization with Ns solutions sampled unimormally in the search space.

After optimization loop, you can get optimized solution.

    print("global best x", cpie.best.x)
    print("global best f", cpie.best.f)

CPIE is niching algorithm, so you can also get best solutions from each mode.

    bests = cpie.get_bests()
    for i, b in enumerate(bests):
        print("mode", i, " f", b.f)

example_main.py shows full example code.

Project details


Release history Release notifications

This version

1.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cpie, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size cpie-1.0.0-py3-none-any.whl (10.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cpie-1.0.0.tar.gz (8.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page