Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
thieu1995 committed Sep 26, 2023
1 parent 8623b1f commit 766680d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 53 deletions.
10 changes: 4 additions & 6 deletions README.md
Expand Up @@ -39,7 +39,7 @@ traditional functions with different dimensions are implemented.
### Install with pip

Install the [current PyPI release](https://pypi.python.org/pypi/opfunu):
```sh
```sh
$ pip install opfunu==1.0.1
```

Expand All @@ -61,7 +61,7 @@ $ python setup.py install

## Lib's structure

```code
```code
docs
examples
Expand Down Expand Up @@ -170,7 +170,7 @@ For more usage examples please look at [examples](/examples) folder.

If you are using opfunu in your project, we would appreciate citations:

```code
```code
@software{thieu_nguyen_2020_3711682,
author = {Nguyen Van Thieu},
title = {Opfunu: An Open-source Python Library for Optimization Benchmark Functions},
Expand All @@ -184,13 +184,11 @@ If you are using opfunu in your project, we would appreciate citations:

## References

```code
```code
1. http://benchmarkfcns.xyz/fcns
2. https://en.wikipedia.org/wiki/Test_functions_for_optimization
3. https://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/
4. http://www.sfu.ca/~ssurjano/optimization.html
5. A Literature Survey of Benchmark Functions For Global Optimization Problems (2013)
6. Problem Definitions and Evaluation Criteria for the CEC 2014 Special Session and Competition on Single Objective Real-Parameter Numerical Optimization
```
8 changes: 4 additions & 4 deletions examples/example_with_mealpy.py
Expand Up @@ -12,16 +12,16 @@

problem_dict1 = {
"fit_func": ackey.evaluate,
"lb": ackey.lb.tolist(),
"ub": ackey.ub.tolist(),
"lb": ackey.lb,
"ub": ackey.ub,
"minmax": "min",
"log_to": None,
"save_population": False,
}

## Run the algorithm
model = SMA.BaseSMA(problem_dict1, epoch=100, pop_size=50, pr=0.03)
best_position, best_fitness = model.solve()
model = SMA.BaseSMA(epoch=100, pop_size=50, pr=0.03)
best_position, best_fitness = model.solve(problem_dict1)
print(f"Best solution: {best_position}, Best fitness: {best_fitness}")

print(ackey.n_fe)
Expand Down
26 changes: 11 additions & 15 deletions examples/name_based/c_func.py
Expand Up @@ -202,18 +202,14 @@
print(problem.is_succeed(problem.x_global))



# problem_dict = {
# "fit_func": problem.evaluate,
# "lb": problem.lb.tolist(),
# "ub": problem.ub.tolist(),
# "minmax": "min",
# "log_to": "None",
# }
#
# model = WOA.BaseWOA(problem_dict, epoch=1000, pop_size=50)
# best_position, best_fitness_value = model.solve()
# print(best_position, best_fitness_value)
#


problem_dict = {
"fit_func": problem.evaluate,
"lb": problem.lb.tolist(),
"ub": problem.ub.tolist(),
"minmax": "min",
"log_to": "None",
}

model = WOA.OriginalWOA(epoch=1000, pop_size=50)
best_position, best_fitness_value = model.solve(problem_dict)
print(best_position, best_fitness_value)
23 changes: 11 additions & 12 deletions examples/name_based/d_func.py
Expand Up @@ -153,15 +153,14 @@
print(problem.is_succeed(problem.x_global))


# problem_dict = {
# "fit_func": problem.evaluate,
# "lb": problem.lb.tolist(),
# "ub": problem.ub.tolist(),
# "minmax": "min",
# "log_to": "None",
# }
#
# model = WOA.BaseWOA(problem_dict, epoch=1000, pop_size=50)
# best_position, best_fitness_value = model.solve()
# print(best_position, best_fitness_value)

problem_dict = {
"fit_func": problem.evaluate,
"lb": problem.lb,
"ub": problem.ub,
"minmax": "min",
"log_to": "None",
}

model = WOA.OriginalWOA(epoch=1000, pop_size=50)
best_position, best_fitness_value = model.solve(problem_dict)
print(best_position, best_fitness_value)
27 changes: 11 additions & 16 deletions examples/name_based/e_func.py
Expand Up @@ -93,19 +93,14 @@
print(problem.is_succeed(problem.x_global))


# problem_dict = {
# "fit_func": problem.evaluate,
# "lb": problem.lb.tolist(),
# "ub": problem.ub.tolist(),
# "minmax": "min",
# "log_to": "None",
# }
#
# model = WOA.BaseWOA(problem_dict, epoch=1000, pop_size=50)
# best_position, best_fitness_value = model.solve()
# print(best_position, best_fitness_value)





problem_dict = {
"fit_func": problem.evaluate,
"lb": problem.lb,
"ub": problem.ub,
"minmax": "min",
"log_to": "None",
}

model = WOA.OriginalWOA(epoch=1000, pop_size=50)
best_position, best_fitness_value = model.solve(problem_dict)
print(best_position, best_fitness_value)

0 comments on commit 766680d

Please sign in to comment.