anyoptimization / pymoo

NSGA2, NSGA3, R-NSGA3, MOEAD, Genetic Algorithms (GA), Differential Evolution (DE), CMAES, PSO
https://pymoo.org
Apache License 2.0
2.23k stars 381 forks source link

Fix for issue #620 #635

Closed apanichella closed 1 month ago

apanichella commented 1 month ago

This PR fixes the error in issue #620

The previous implementation can lead to division by zero or extremely large exponential values that can lead to overflow problems for constrained problems.

This PR fixes these errors as follows:

muazhari commented 1 month ago

You are missing another error in this PR.

image

apanichella commented 1 month ago

For which problem do you get this error? That would help me debugging the code

muazhari commented 1 month ago

For which problem do you get this error? That would help me debugging the code

This: https://gist.github.com/muazhari/deed94f293489e95a75e95c057f5e98f

apanichella commented 1 month ago

On my machine, I don't get that error. I have also tried with different seeds

muazhari commented 1 month ago

Another error again in this: https://gist.github.com/muazhari/0825646b3767402b1899881836b36c42 image

I don't know if mixed variable modification to the GA algorithm is interoperable with agemoea2. I think it should because it uses the same abstraction in the superset class (GA), and is not specific to agemoea2.

muazhari commented 1 month ago

On my machine, I don't get that error. I have also tried with different seeds

damn, how? My machine is currently a bit random as in my last GitHub issues to Pymoo, wsl, and Ray. Is it because intel stability issue? haha.

muazhari commented 1 month ago

On my machine, I don't get that error. I have also tried with different seeds

I tried to run 3 times and still got the same error. Can you try to execute in different log levels? Or make sure the stdout/stderr not obstructed?

apanichella commented 1 month ago

Another error again in this: https://gist.github.com/muazhari/0825646b3767402b1899881836b36c42 image

I don't know if mixed variable modification to the GA algorithm is interoperable with agemoea2. I think it should because it uses the same abstraction in the superset class (GA), and is not specific to agemoea2.

I also don't get this error on my machine (M3 Mac). But the last commit should consider/handle division with NaN and Inf value. This should prevent the error you have.

Actually, I am looking at the stack trace you have. It seems you are not using the code after my commits as the line f += np.power(point[obj_index], x) in your stack trace is now f += np.power(point[obj_index] + epsilon, x), which is the latest code.

muazhari commented 1 month ago

Actually, I am looking at the stack trace you have. It seems you are not using the code after my commits as the line f += np.power(point[obj_index], x) in your stack trace is now f += np.power(point[obj_index] + epsilon, x), which is the latest code.

My bad. After ensuring to use your latest commit, both gists above did not display any errors.

muazhari commented 1 month ago

For which problem do you get this error? That would help me debugging the code

This: https://gist.github.com/muazhari/deed94f293489e95a75e95c057f5e98f

Sorry, this first gist still has an error (the second gist is fixed). I don't know why the stack trace can't be displayed to the stdout when using logger/try-catch. After I removed it, the stack trace displayed the error. Please rerun the modified gist.

apanichella commented 1 month ago

For which problem do you get this error? That would help me debugging the code

This: https://gist.github.com/muazhari/deed94f293489e95a75e95c057f5e98f

Sorry, this first gist still has an error (the second gist is fixed). I don't know why the stack trace can't be displayed to the stdout when using logger/try-catch. After I removed it, the stack trace displayed the error. Please rerun the modified gist.

It should be fixed with the last commit

muazhari commented 1 month ago

In the second gist (https://gist.github.com/muazhari/0825646b3767402b1899881836b36c42), comes another warning: image In the first gist (https://gist.github.com/muazhari/deed94f293489e95a75e95c057f5e98f), still has an earlier error. image

apanichella commented 1 month ago

The last two commits should fix the issues in both gits. Let me know if you encounter more issues

blankjul commented 1 month ago

I have merged the code for now. Please open a new PR if another fix is needed.

blankjul commented 1 month ago

Thanks @apanichella for taking care of it!