Skip to content

Commit a0fa93d

Browse files
committed
Update README.md
1 parent bd190de commit a0fa93d

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,51 @@ $ yay -Syyu python-fireflyalgorithm
4141
## Usage:
4242

4343
```python
44-
import numpy as np
4544
from fireflyalgorithm import FireflyAlgorithm
46-
47-
def sphere(x):
48-
return np.sum(x ** 2)
45+
from fireflyalgorithm.problems import sphere
4946

5047
FA = FireflyAlgorithm()
5148
best = FA.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000)
5249

5350
print(best)
5451
```
5552

53+
### Command line interface
54+
55+
The package also comes with a simple command line interface which allows you to evaluate the algorithm on several
56+
popular test functions
57+
58+
```shell
59+
firefly-algorithm -h
60+
```
61+
62+
```text
63+
usage: firefly-algorithm [-h] --problem PROBLEM -d DIMENSION -l LOWER -u UPPER -nfes MAX_EVALS [-r RUNS] [--pop-size POP_SIZE] [--alpha ALPHA] [--beta-min BETA_MIN] [--gamma GAMMA] [--seed SEED]
64+
65+
Evaluate the Firefly Algorithm on one or more test functions
66+
67+
options:
68+
-h, --help show this help message and exit
69+
--problem PROBLEM Test problem to evaluate
70+
-d DIMENSION, --dimension DIMENSION
71+
Dimension of the problem
72+
-l LOWER, --lower LOWER
73+
Lower bounds of the problem
74+
-u UPPER, --upper UPPER
75+
Upper bounds of the problem
76+
-nfes MAX_EVALS, --max-evals MAX_EVALS
77+
Max number of fitness function evaluations
78+
-r RUNS, --runs RUNS Number of runs of the algorithm
79+
--pop-size POP_SIZE Population size
80+
--alpha ALPHA Randomness strength
81+
--beta-min BETA_MIN Attractiveness constant
82+
--gamma GAMMA Absorption coefficient
83+
--seed SEED Seed for the random number generator
84+
```
85+
86+
**Note:** The CLI script can also run as a python module (python -m niaarm ...)
87+
88+
5689
## Reference Papers:
5790

5891
I. Fister Jr., X.-S. Yang, I. Fister, J. Brest. [Memetic firefly algorithm for combinatorial optimization](http://www.iztok-jr-fister.eu/static/publications/44.pdf) in Bioinspired Optimization Methods and their Applications (BIOMA 2012), B. Filipic and J.Silc, Eds.

0 commit comments

Comments
 (0)