Skip to main content

Indago

Indago is a Python 3 module for numerical optimization.

Installation

For easiest install for using the optimization framework use

pip3 install indago

In order to obtain Indago code, clone Gitlab repository by executing following command in the directory where you want to loacte Indago root directory:

git clone https://gitlab.com/sivic/indago.git

For building and installing Indago package into your Python environment

python setup.py build
python setup.py install

Or for continous testing/developing:

python setup.py clean build install

Dependencies

A following packages should be installed using aptitude:

  • python3
  • python3-pip
  • python3-tk
    sudo apt install python3 python3-pip python3-tk

After packages installation using above command, additional python packages should be installed using pip from requirements.txt

    pip install -r requirements.txt

Algorithms

Indago is a Python module for numerical optimization of real fitness function over a real parameter domain. It was developed at the Department for Fluid Mechanics and Computational Engineering of the University of Rijeka, Faculty of Engineering, by Stefan Ivić, Siniša Družeta, and others.

Indago is developed for in-house research and teaching purposes and is not officially supported in any way, it is not properly documented and probably needs more testing. But hey, we use it, it works for us, and it's free! Anyway, proceed with caution, as you would with any other beta-level software.

As of now, Indago consists of three stochastic swarm-based optimizers, namely Particle Swarm Optimization (PSO), Fireworks Algorithm (FWA) and Squirrel Search Algorithm (SSA). They are all available through the same API, which was designed to be as accessible as possible. Indago relies heavily on NumPy, so the inputs and outputs of the optimizers are mostly NumPy arrays. Besides NumPy and a couple of other stuff here and there (such as a few SciPy functions), Indago is pure Python. Indago optimizers also include some of our original research improvements, so feel free to try those as well. And don't forget to cite. :)

Particle swarm optimization

Using Indago is easy. Let us use PSO as an example. First, we need to import NumPy and Indago PSO, and then initialize an optimizer object:

import numpy as np
from indago.pso import PSO
pso = PSO()

Then, we must provide a goal function which needs to be minimized, say:

def goalfun(x):	# must take 1D np.array
    return np.sum(x**2) # must return scalar number
pso.evaluation_function = goalfun

Now we can define optimizer inputs:

pso.method = 'Vanilla' # we will use standard PSO, the other available option is 'TVAC' [1]
pso.dimensions = 20 # number of variables in the design vector (x)
pso.swarm_size = 15 # number of PSO particles
pso.iterations = int(1000 * pso.dimensions / pso.swarm_size) # any integer will do, but 10³D function calls is possibly a good choice
pso.lb = np.ones(pso.dimensions) * -1 # 1D np.array of lower bound values
pso.ub = np.ones(pso.dimensions) * 1 # 1D np.array of lower bound values

Also, we must provide optimization method parameters:

pso.params['cognitive_rate'] = 1.0 # PSO parameter also known as c1 (ranges from 0.0 to 2.0)
pso.params['social_rate'] = 1.0 # PSO parameter also known as c2 (ranges from 0.0 to 2.0)
pso.params['inertia'] = 0.72 # PSO parameter known as inertia weight (w, ranges from 0.5 to 1.0), the other available options are 'LDIW' (w linearly decreasing from 1.0 to 0.4) and 'anakatabatic'

If we want to use our (still unpublished) adaptive inertia weight technique:

pso.params['inertia'] = 'anakatabatic'

then we need to also specify the anakatabatic model:

pso.params['akb_model'] = 'languid' # [2,3], the other options are 'fish' and 'nosedive'

Finally, we can start the optimization and get the results:

result = pso.run()
min_f = result.f # fitness at minimum, scalar number
x_min = result.x # design vector at minimum, 1D np.array

And that's it!

Fireworks algorithm

If we wanted to use FWA [4], we just have to import it instead of PSO:

from indago.pso import FWA
fwa = FWA()

Now we can proceed in the same manner as with PSO. For FWA, the only method available is basic FWA:

fwa.method = 'Vanilla'

In FWA, we do not need swarm_size parameter and we have to set the following method parameters:

fwa.params['n'] = 20 # DA LI JE OVO U BITI SWARM_SIZE?
fwa.params['m1'] = 10
fwa.params['m2'] = 10

Lastly, if we want to try our luck with SSA [5], we initialize it like this:

from indago.pso import SSA
ssa = SSA()

In SSA, the only available method is 'Vanilla', and we need to provide the swarm_size parameter. Also, there is only one mandatory method parameter:

ssa.params['acorn_tree_attraction'] = 0.5 # ranges from 0.0 to 1.0

Optionally, we can define a few other parameters:

ssa.params['predator_presence_probability'] = 0.1
ssa.params['gliding_constant'] = 1.9 
ssa.params['gliding_distance_limits'] = [0.5, 1.11] 

Among other stuff, Indago also includes the CEC2014 test suite [6], comprising 30 test functions for real optimization methods. You can use it by importing it like this:

from indago.benchmarks import CEC2014

Then, you have to initialize it for a specific dimensionality of the test functions:

test = CEC2014(10) # you can also use 20, 50 and 100

Now you can use specific test functions (test.F1(), test.F2(), ...up to test.F30()), they all take 1D np.array of size 10/20/50/100 and return a scalar number. Alternatively, you can iterate through the built-in list of them all:

test_results = []
for f in test.functions:
    optimizer.evaluation_function = f
    test_results.append(optimizer.run().f)

Have fun!

References:

  1. Ratnaweera, A., Halgamuge, S. K., & Watson, H. C. (2004). Self-organizing hierarchical particle swarm optimizer with time-varying acceleration coefficients. IEEE Transactions on evolutionary computation, 8(3), 240-255.

  2. Družeta, S., & Ivić, S. (2017). Examination of benefits of personal fitness improvement dependent inertia for Particle Swarm Optimization. Soft Computing, 21(12), 3387-3400.

  3. Družeta, S., Ivić, S., Grbčić, L., & Lučin, I. (2019). Introducing languid particle dynamics to a selection of PSO variants. Egyptian Informatics Journal.

  4. Jain, M., Singh, V., & Rani, A. (2019). A novel nature-inspired algorithm for optimization: Squirrel search algorithm. Swarm and evolutionary computation, 44, 148-175.

  5. Liang, J. J., Qu, B. Y., & Suganthan, P. N. (2013). Problem definitions and evaluation criteria for the CEC 2014 special session and competition on single objective real-parameter numerical optimization. Computational Intelligence Laboratory, Zhengzhou University, Zhengzhou China and Technical Report, Nanyang Technological University, Singapore, 635.

Metadata

Release files for indago 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for indago 0.0.6
File Size Uploaded Provenance Actions
Indago-0.0.6.tar.gz 21.1 kB Without provenance Details for Indago-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for indago 0.0.6
File Interpreter ABI Platform Actions
Indago-0.0.6-py3-none-any.whl Python 3 none any Details for Indago-0.0.6-py3-none-any.whl

Total release size: 46.7 kB

Release files / Indago-0.0.6.tar.gz

Download URL Indago-0.0.6.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6c16646c41e868ea76f67e9d08367a4d75cad8d4c01057c9edd7bc68ae86a499
BLAKE2b-256 checksum
How to use checksums
e0872662f7377d1616dd25fadab4c7a211f828742497eba0dfa8232966b3d4df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

Release files / Indago-0.0.6-py3-none-any.whl

Download URL Indago-0.0.6-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f908c6949054e9a5ba3573e3b56ee3af254bbb4772cf02d288490735108ef603
BLAKE2b-256 checksum
How to use checksums
97ba80be6f23a2d08b5269937e4aa7ade1f4f3ed70192af3ca9da20c785812ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

Security for indago 0.0.6

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.

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page