Package: pyMetaheuristic
pyMetaheuristicIntroductionpyMetaheuristicis a robust Python Library crafted to provide a wide range of metaheuristic algorithms, ideal for tackling complex optimization tasks. It encompasses a diverse mix of algorithms, from traditional to modern methods. For a detailed list of these metaheuristics and their demonstrations, refer toSection 3. The library is also equipped with a selection of test functions, useful for benchmarking and evaluating algorithm performance. Details on these functions can be found inSection 4. Getting started withpyMetaheuristic is straightforward. Install the package using pip and begin exploring the available algorithms and test functions, as outlined inSections 1 and 2. Whether you're addressing intricate optimization problems or experimenting with different algorithms,pyMetaheuristicis your essential toolkit.Each metaheuristic includes two parameters: 'start_init' and 'target_value'. By default, 'start_init' is set to None, but it can be assigned an initial guess in the form of a NumPy array. The default value of 'target_value' is also None. However, you can specify a continuous value for it. If during the iterations, the objective function reaches a value that is equal to or less than this specified 'target_value', the iterations will halt.UsageInstallpipinstallpyMetaheuristicImport# Import PSOfrompyMetaheuristic.algorithmimportparticle_swarm_optimization# Import a Test Function. Available Test Functions: https://bit.ly/3KyluPpfrompyMetaheuristic.test_functionimporteasom# OR Define your Custom Function. The function input should be a list of values,# each value representing a dimension (x1, x2, ...xn) of the problem.importnumpyasnpdefeasom(variables_values=[0,0]):x1,x2=variables_valuesfunc_value=-np.cos(x1)*np.cos(x2)*np.exp(-(x1-np.pi)**2-(x2-np.pi)**2)returnfunc_value# Run PSOparameters={'swarm_size':250,'min_values':(-5,-5),'max_values':(5,5),'iterations':500,'decay':0,'w':0.9,'c1':2,'c2':2,'verbose':True,'start_init':None,'target_value':None}pso=particle_swarm_optimization(target_function=easom,**parameters)# Print Solutionvariables=pso[:-1]minimum=pso[-1]print('Variables: ',np.around(variables,4),' Minimum Value Found: ',round(minimum,4))# Plot SolutionfrompyMetaheuristic.utilsimportgraphsplot_parameters={'min_values':(-5,-5),'max_values':(5,5),'step':(0.1,0.1),'solution':[variables],'proj_view':'3D','view':'browser'}graphs.plot_single_function(target_function=easom,**plot_parameters)Colab DemoTry it inColab:Adaptive Random Search (Colab Demo) (Original Paper)Ant Lion Optimizer (Colab Demo) (Original Paper)Arithmetic Optimization Algorithm (Colab Demo) (Original Paper)Artificial Bee Colony Optimization (Colab Demo) (Original Paper)Artificial Fish Swarm Algorithm (Colab Demo) (Original Paper)Bat Algorithm (Colab Demo) (Original Paper)Biogeography Based Optimization (Colab Demo) (Original Paper)Cat Swarm Optimization (Colab Demo) (Original Paper)Chicken Swarm Optimization (Colab Demo) (Original Paper)Clonal Selection Algorithm (Colab Demo) (Original Paper)Coati Optimization Algorithm (Colab Demo) (Original Paper)Cockroach Swarm Optimization (Colab Demo) (Original Paper)Cross-Entropy Method (Colab Demo) (Original Paper)Crow Search Algorithm (Colab Demo) (Original Paper)Cuckoo Search (Colab Demo) (Original Paper)Cultural Algorithm (Colab Demo) (Original Paper)Differential Evolution (Colab Demo) (Original Paper)Dispersive Flies Optimization (Colab Demo) (Original Paper)Dragonfly Algorithm (Colab Demo) (Original Paper)Dynamic Virtual Bats Algorithm (Colab Demo) (Original Paper)Elephant Herding Optimization Algorithm (Colab Demo) (Original Paper)Firefly Algorithm (Colab Demo) (Original Paper)Flow Direction Algorithm (Colab Demo) (Original Paper)Flower Pollination Algorithm (Colab Demo) (Original Paper)Genetic Algorithm (Colab Demo) (Original Paper)Geometric Mean Optimizer (Colab Demo) (Original Paper)Grey Wolf Optimizer (Colab Demo) (Original Paper)Grey Wolf Optimizer - Adaptive Chaotic GWO (Colab Demo) (Original Paper)Grey Wolf Optimizer - Improved GWO (Colab Demo) (Original Paper)Grasshopper Optimization Algorithm (Colab Demo) (Original Paper)Gravitational Search Algorithm (Colab Demo) (Original Paper)Harmony Search Algorithm (Colab Demo) (Original Paper)Harris Hawks Optimization (Colab Demo) (Original Paper)Hunting Search Algorithm (Colab Demo) (Original Paper)Jaya (Colab Demo) (Original Paper)Jellyfish Search Optimizer (Colab Demo) (Original Paper)Krill Herd Algorithm (Colab Demo) (Original Paper)Memetic Algorithm (Colab Demo) (Original Paper)Monarch Butterfly Optimization (Colab Demo) (Original Paper)Moth Flame Optimization (Colab Demo) (Original Paper)Multiverse Optimizer (Colab Demo) (Original Paper)Pathfinder Algorithm (Colab Demo) (Original Paper)Particle Swarm Optimization (Colab Demo) (Original Paper)Population-Based Incremental Learning (Colab Demo) (Original Paper)Random Search (Colab Demo) (Original Paper)Salp Swarm Algorithm (Colab Demo) (Original Paper)Simulated Annealing (Colab Demo) (Original Paper)Sine Cosine Algorithm (Colab Demo) (Original Paper)Student Psychology Based Optimization (Colab Demo) (Original Paper)Symbiotic Organisms Search (Colab Demo) (Original Paper)Teaching Learning Based Optimization (Colab Demo) (Original Paper)Whale Optimization Algorithm (Colab Demo) (Original Paper)Whale Optimization Algorithm - Improved WOA (Colab Demo)  (Original Paper)Test FunctionsAckley (Paper) (Plot)Axis Parallel Hyper-Ellipsoid (Paper) (Plot)Beale (Paper) (Plot)Bohachevsky F1 (Paper) (Plot)Bohachevsky F2 (Paper) (Plot)Bohachevsky F3 (Paper) (Plot)Booth (Paper) (Plot)Branin RCOS (Paper) (Plot)Bukin F6 (Paper) (Plot)Cross in Tray (Paper) (Plot)De Jong F1 (Paper) (Plot)Drop Wave (Paper) (Plot)Easom (Paper) (Plot)Eggholder (Paper) (Plot)Goldstein-Price (Paper) (Plot)Griewangk F8 (Paper) (Plot)Himmelblau (Paper) (Plot)Holder Table (Paper) (Plot)Matyas (Paper) (Plot)McCormick (Paper) (Plot)Levi F13 (Paper) (Plot)Rastrigin (Paper) (Plot)Rosenbrocks Valley (De Jong F2) (Paper) (Plot)Schaffer F2 (Paper) (Plot)Schaffer F4 (Paper) (Plot)Schaffer F6 (Paper) (Plot)Schwefel (Paper) (Plot)Six Hump Camel Back (Paper) (Plot)Styblinski-Tang (Paper) (Plot)Three Hump Camel Back (Paper) (Plot)Zakharov (Paper) (Plot)Multiobjective Optimization or Many Objectives OptimizationFor Multiobjective Optimization or Many Objectives Optimization trypyMultiobjectiveTSP (Travelling Salesman Problem)For Travelling Salesman Problems, trypyCombinatorialAcknowledgementThis section is dedicated to everyone who helped improve or correct the code. Thank you very much!Raiser (01.MARCH.2022) -https://github.com/mpraiser- University of Chinese Academy of Sciences (China)