def __init__(self, factors, *args, **kwargs):
        """
        Construct a new ``BiggestMultipleGA`` instance.

        Only allows chromosomes with 1 gene each.

        factors:  sequence of integer factors >= 1 that solutions must have.
        """
        kwargs['translator'] = BinaryIntTranslator()
        super().__init__(*args, **kwargs)

        # only 1-gene chromosomes allowed
        for c in self.chromosomes:
            assert len(c.genes) == 1

        assert factors and all(isinstance(i, int) and i >= 1 for i in factors)
        self.factors = factors

        self.max_encoded_val = int('1' * self.chromosomes[0].length, base=2)
        self.best_possible_fit = len(self.factors)
        self.found_best = False
def __init__ ( self , factors , * args , ** kwargs ) : kwargs [ 'translator' ] = BinaryIntTranslator ( ) super ( ) . __init__ ( * args , ** kwargs ) for c in self . chromosomes : assert len ( c . genes ) == 1 assert factors and all ( isinstance ( i , int ) and i >= 1 for i in factors ) self . factors = factors self . max_encoded_val = int ( '1' * self . chromosomes [ 0 ] . length , base = 2 ) self . best_possible_fit = len ( self . factors ) self . found_best = False
Construct a new ``BiggestMultipleGA`` instance.

        Only allows chromosomes with 1 gene each.

        factors:  sequence of integer factors >= 1 that solutions must have.