Git Product home page Git Product logo

jkpir / coa Goto Github PK

View Code? Open in Web Editor NEW
27.0 0.0 9.0 67 KB

A new metaheuristic for global optimization problems proposed in the IEEE Congress on Evolutionary Computation (CEC), 2018

Home Page: https://www.mathworks.com/matlabcentral/fileexchange/68373-coa

License: BSD 3-Clause "New" or "Revised" License

MATLAB 39.44% Python 33.09% R 27.47%
optimization metaheuristics global-optimization multimodal-optimization nature-inspired-algorithms

coa's People

Contributors

jkpir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coa's Issues

Possible error in Python version's random initialization

Hello! Thanks very much for the interesting paper and especially for providing the reference implementation in Python! It's made it possible for a hobbyist like myself to try the algorithm out.

I'm trying to reproduce the results in another paper (or rather, apply the methods to my own problem) which used COA to optimize the placement of $n$ wireless routers in 2D space1. While testing the algorithm, I noticed that it seemed a bit too difficult to get the minimum cost to converge to satisfactory values - it was taking me around $10^5$ iterations ("function evaluations") to start reaching even the ballpark of the results in the paper, plateauing around 0.2 (I'm using 0..1 for my cost) They got their results with $10^3$ iterations!

So I started stepping through the implementation, and noticed that the initial random values generated for the coyotes were actually out of the VarMin, VarMax range. I was initially using negative values in VarMin, which made this pop out.

The possible error

I believe that there are parentheses missing in this statement, which generates the initial random values for each coyote:

COA/COA.py

Lines 34 to 35 in e880367

coyotes = np.tile(VarMin, [pop_total, 1]) + np.random.rand(pop_total, D) * np.tile(VarMax, [pop_total, 1]) - \
np.tile(VarMin, [pop_total, 1])

Due to the missing parentheses, this gets evaluated essentially as min + (random() * max) - min, instead of the intended min + random() * (max - min). This causes the initial random values to be biased towards the maximum, depending on min and max.

The latter (min + random() * (max - min)) is also used when generating the puppies:

COA/COA.py

Lines 117 to 119 in e880367

pup = p1*coyotes_aux[parents[0], :] + \
p2*coyotes_aux[parents[1], :] + \
n*(VarMin + np.random.rand(1, D) * (VarMax - VarMin))

After changing that line like the following, I started instantly receiving much better results (first sub-0.1 min cost with 20k function evaluations!)

-coyotes = np.tile(VarMin, [pop_total, 1]) + np.random.rand(pop_total, D) * np.tile(VarMax, [pop_total, 1]) - np.tile(VarMin, [pop_total, 1]) 
+coyotes = np.tile(VarMin, [pop_total, 1]) + np.random.rand(pop_total, D) * (np.tile(VarMax, [pop_total, 1]) - np.tile(VarMin, [pop_total, 1])) 

Footnotes

  1. S. Mekhmoukh Taleb et al. "Solving the Mesh Router Nodes Placement in Wireless Mesh Networks Using Coyote Optimization Algorithm," in IEEE Access, vol. 10, pp. 52744-52759, 2022, doi: 10.1109/ACCESS.2022.3166866. โ†ฉ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.