Closed theshyyi closed 9 months ago
Hi @theshyyi,
I think you are setting the seed value in model.solve
function. So that is why the results are always the same.
You should use different seed value for each trial, may be use trial index as seed value. Then each trial will generate a different result.
for trial in range(0, 50):
model = BaseGA(...)
model.solve(seed=trial)
In old version of numpy and mealpy. We don't have seed value, but we can still make the code is reproducible by setting a global seed value at the top of the script file like this:
import numpy as np
np.random.seed(10)
for trial in range(0, 50):
model =....
Then it will generate different results for each trial. When others run your script on their machines, it will still produce the same values, that is the concept of 'reproducibility. You can still try to set the global seed like that, but I am not sure it will work or not.
import numpy as np
np.random.seed(10)
for trial in range(0, 50):
model = BaseGA(...)
model.solve(seed=None)
Thank you for answering this query for me, I think I have understood why.
Thanks again, your response has helped me a great deal!
That is good to hear. I will close this issue now. Feel free to re-open if need be.
Description
Hello,Very useful library,While working on my algorithms using CotiaA, PSO etc. noticed an issue.
Every run of mine using the same algorithm gets the same results for the same CEC test function.
But what I've learned is that different runs will come up with different results because of the random function, so this has been confusing me. I hope you can answer my doubts. Thank you.
Additional Information
No response