diff --git a/README.md b/README.md index 548d0d6..6c36a30 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -61,7 +61,7 @@ $ python setup.py install ## Lib's structure -```code +```code docs examples @@ -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}, @@ -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 - ``` diff --git a/examples/example_with_mealpy.py b/examples/example_with_mealpy.py index 3f6b681..605eb71 100644 --- a/examples/example_with_mealpy.py +++ b/examples/example_with_mealpy.py @@ -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) diff --git a/examples/name_based/c_func.py b/examples/name_based/c_func.py index 0f2ba51..53d729b 100644 --- a/examples/name_based/c_func.py +++ b/examples/name_based/c_func.py @@ -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) diff --git a/examples/name_based/d_func.py b/examples/name_based/d_func.py index 2a2c7ce..3d17ba3 100644 --- a/examples/name_based/d_func.py +++ b/examples/name_based/d_func.py @@ -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) diff --git a/examples/name_based/e_func.py b/examples/name_based/e_func.py index 57ed250..55b5c6a 100644 --- a/examples/name_based/e_func.py +++ b/examples/name_based/e_func.py @@ -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)