def mutate_bit_genome(bitstring, p, **kwargs): if random.random() <= p: pos = random.randint(0, len(bitstring) - 1) char_list = list(bitstring) char_list[pos] = bit_flip(char_list[pos]) bitstring = char_list_to_str(char_list) return bitstring
def mutate_bit_components(bitstring, p, **kwargs): return char_list_to_str(bit_flip(b) if random.random() <= p else b for b in bitstring)
def mutate_bit_components(bitstring, p, **kwargs): return char_list_to_str( bit_flip(b) if random.random() <= p else b for b in bitstring)