Skip to content

Integer precision issues #174

Closed
Closed
@huku-

Description

@huku-

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:

  1. It contradicts the fact that Python ints are arbitrary precision integers
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions