SevgiAkten / pycellga

Cellular Genetic Algorithms in Python.
https://sevgiakten.github.io/pycellga/
MIT License
2 stars 1 forks source link

overflow error in tests #57

Closed jbytecode closed 1 month ago

jbytecode commented 1 month ago

I got

tests/test_optimizer_alpha_cga.py::test_optimizer_alpha_cga_real
  /home/hako/code/python/pycellga/src/tests/test_optimizer_alpha_cga.py:33: RuntimeWarning: overflow encountered in power
    return sum(np.power(xi, 2) for xi in x)

tests/test_optimizer_cga.py::test_optimizer_cga_real
  /home/hako/code/python/pycellga/src/tests/test_optimizer_cga.py:33: RuntimeWarning: overflow encountered in power
    return sum(np.power(xi, 2) for xi in x)

tests/test_optimizer_sync_cga.py::test_optimizer_sync_cga_real
  /home/hako/code/python/pycellga/src/tests/test_optimizer_sync_cga.py:33: RuntimeWarning: overflow encountered in power
    return sum(np.power(xi, 2) for xi in x)

when I've been performing tests, it seems it's about the power function and this causes very big numbers. How about replacing pow(x, 2) with absoluate value, or logarithm or something else, or maybe using bigfloat? I've no idea right now, but we should get rid of this.

SevgiAkten commented 1 month ago

I fixed the error by using mpmath instead of numpy