예제 #1
0
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
예제 #2
0
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
예제 #3
0
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)
예제 #4
0
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)