genetic-algorithm

overlapping in matplotlib plot

overlapping in matplotlib plot Question: I am comparing the execution time of an exhaustive search and genetic algorithm along with sample solutions. In the graph below, I am trying to improve the readability of my graph. However, they overlap with each other. Sample Code: import matplotlib.pyplot as plt # define the data exhaustive_search = [72, …

Total answers: 1

Why does PyGad fitness_function not work when inside of a class?

Why does PyGad fitness_function not work when inside of a class? Question: I am trying to train a genetic algorithm but for some reason it does not work when it’s stored inside of a class. I have two equivalent pieces of code but the one stored inside of a class fails. It returns this.. raise …

Total answers: 1

Iterating a list: getting values as[set(), set(), set(), set(), set()]

Iterating a list: getting values as[set(), set(), set(), set(), set()] Question: I have a list (df_pop_initial_list), and it looks like this: [[‘000000000000000000000000000001011000000’], [‘000000001000000000000001000000000010000’], [‘000000000000000000000000000000010011000’], [‘000000000000001001000000000000010000000’], [‘000000000000000000010000001000000010000’], [‘1000000000100000000010000000000000000000’], [‘1000000010000000000001000000000000000000’], [‘1001000000000000000010000000000000000000’], [‘000000000000100000000000100000000000010’], [‘000000000110000000000000000000001000000’], [‘000000101000000010000000000000000000000’], [‘000000000000001000000010000100000000000’], [‘000000000000000010000101000000000000000’], [‘000000001000100000000000000000000100000’], [‘000000100000000000000000010000001000000’], [‘000000000000001100000000000010000000000’], [‘010000000000000000000000000001001000000’], [‘000000010100000001000000000000000000000’], [‘000000000000000000001000000001100000000’], [‘000100000000000100000000000000000000010′]] I am trying to count 1’s in this 39 bits string list and converting …

Total answers: 1

Genetic Algorithm using fixed length vector

Genetic Algorithm using fixed length vector Question: I am trying to implement a genetic algorithm using fixed-length vectors of real numbers. I found a simple implementation online using a binary encoded values. My confusion arises when I am trying to figure out a way to initialise the array and set the bounds for this algorithm. …

Total answers: 1

finding indexes of 1's in a bit string and storing these indexes in a list — Index should be started from 1 not 0

finding indexes of 1's in a bit string and storing these indexes in a list — Index should be started from 1 not 0 Question: I am finding indexes of 1’s in a bit string successfully. However, these indexes start from 0. Sample Data: initial_pop 000000000000000000000000000001011000000 000000001000000000000001000000000010000 000000000000000000000000000000010011000 000000000000001001000000000000010000000 000000000000000000010000001000000010000 1000000000100000000010000000000000000000 1000000010000000000001000000000000000000 1001000000000000000010000000000000000000 000000000000100000000000100000000000010 000000000110000000000000000000001000000 …

Total answers: 2

counting 1's in a bit string to keep positions in a variable and then accessing each value

counting 1's in a bit string to keep positions in a variable and then accessing each value Question: I am finding 1’s in a bit string and then storing them. Sample Data: Sample code: def indices(chromosome): return {i for i,c in enumerate(chromosome) if c==’1′} for ind in df_initial_pop[‘initial_pop’].index: locations = indices(df_initial_pop[‘initial_pop’] [ind]) print (locations) Output: …

Total answers: 1

Cross-over is failing binary encoded string

Cross-over is failing binary encoded string Question: I am implementing Genetic Algorithm (GA). There are 43 numbers [Ambulance Locations] to choose from (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, …

Total answers: 1

Mutation with String Encoded Chromosomes – Genetic Algorithm

Mutation with String Encoded Chromosomes – Genetic Algorithm Question: I am implementing Genetic Algorithm (GA). There are 43 numbers [Ambulance Locations] to choose from (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, …

Total answers: 1