Passing gene_type=int in the GA class constructor, will result in internal numpy arrays holding 64-bit integer values. This is well known to numpy users:
>>> type(numpy.array([1], dtype=int)[0])
<class 'numpy.int64'>
This, however, has two major problems:
- It contradicts the fact that Python
ints are arbitrary precision integers
- It prohibits users from using
pygad to explore bigger state-spaces (e.g. bit-vectors of 256-bits, or even larger in my case)
To solve this problem, a one-liner fix is to add object in GA.supported_int_types here. Then, users can pass gene_type=object in the GA constructor and handle Python integers in objective functions without worrying about numpy getting in their way.
Passing
gene_type=intin theGAclass constructor, will result in internalnumpyarrays holding 64-bit integer values. This is well known to numpy users:This, however, has two major problems:
ints are arbitrary precision integerspygadto explore bigger state-spaces (e.g. bit-vectors of 256-bits, or even larger in my case)To solve this problem, a one-liner fix is to add
objectinGA.supported_int_typeshere. Then, users can passgene_type=objectin theGAconstructor and handle Python integers in objective functions without worrying aboutnumpygetting in their way.