Skip to main content

Neat ACO is an Ant Colony Optimization algorithm written in pure Python.

Project description

neataco is an Ant Colony Optimization algorithm written in pure python. The intention is to use this package with PyPy. The hot loops in the algorithm are perfect for PyPy's just-in-time compilation and results in very fast performance.

To run create an instance of AntColonyOptimization and call run(). The output is a list with the optimized sequence of input items.

The input items can be a list of anything, because the distance function also has to be provided. The distance function must be able to calculate the distance between any items in the input list.

An example:

from neataco import AntColonyOptimization
items = [10, 20, 15, 5, 100, 2, 30, 50]
distance_fn = lambda a, b: abs(b - a)

aco = AntColonyOptimization(
    items,
    distance_fn,
    ant_count=1024,
    alpha=1,
    beta=20,
    evaporation=0.2,
)
optimal_path = aco.run()
print(optimal_path)

This will print the shortest path between all of the numbers; in this case ordering them.

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

neataco-1.0.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

neataco-1.0.0-py3-none-any.whl (16.5 kB view hashes)

Uploaded Python 3

Supported by

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