thieu1995 / mealpy

A Collection Of The State-of-the-art Metaheuristic Algorithms In Python (Metaheuristic/Optimizer/Nature-inspired/Biology)
https://mealpy.readthedocs.io
GNU General Public License v3.0
871 stars 177 forks source link

about random seed #126

Closed cumttc closed 9 months ago

cumttc commented 9 months ago

It is well known that heuristic algorithms, due to their internal randomness, often produce different solutions for the same problem under the same conditions in multiple attempts (although their loss function values will be close) when the search depth is not extremely large. But when I was looking at the 'pymoo' project, it had a 'SEED'. When the same 'seed' is used, the difference between the solutions from multiple attempts is not so great. I am wondering if there is a similar operation in 'mealpy' that can make the gap between the solutions of multiple attempts not so big. Looking forward to your reply.

thieu1995 commented 9 months ago

Hi @cumttc,

There is no way you can make the gap between the best solution of multiple trials small based on the SEED value. It has nothing to do with the seed value. The fluctuations among those values are from the inner workings of the algorithm (equations, exploration, or exploitation). The seed value is used to ensure that your algorithm produces the same result each time you run the program. If you use the same seed but still get different results, then that library is the problem. You should always get the same value when using the same seed. Otherwise, how can people reliably reproduce the results?

Based on the fluctuations of different trials, you can see whether the algorithm is good or bad (a smaller difference means a better algorithm). It indicates the algorithm's stability for a specific group of problems. Algorithms in pymoo can provide small difference values because they are state-of-the-art optimizers. In mealpy, several algorithms are not well-designed, and I've developed many improved versions. So, don't expect to get a small difference among trials of an algorithm. Try several algorithms and determine which one is good or bad based on your own conclusions.