genetic-algorithm

Swapping bits at a given point between two bytes

帅比萌擦擦* 提交于 2021-02-13 17:04:12
问题 Let's say I have these two numbers: x = 0xB7 y = 0xD9 Their binary representations are: x = 1011 0111 y = 1101 1001 Now I want to crossover (GA) at a given point, say from position 4 onwards. The expected result should be: x = 1011 1001 y = 1101 0111 Bitwise, how can I achieve this? 回答1: I would just use bitwise operators: t = (x & 0x0f) x = (x & 0xf0) | (y & 0x0f) y = (y & 0xf0) | t That would work for that specific case. In order to make it more adaptable, I'd put it in a function,

Swapping bits at a given point between two bytes

元气小坏坏 提交于 2021-02-13 17:03:45
问题 Let's say I have these two numbers: x = 0xB7 y = 0xD9 Their binary representations are: x = 1011 0111 y = 1101 1001 Now I want to crossover (GA) at a given point, say from position 4 onwards. The expected result should be: x = 1011 1001 y = 1101 0111 Bitwise, how can I achieve this? 回答1: I would just use bitwise operators: t = (x & 0x0f) x = (x & 0xf0) | (y & 0x0f) y = (y & 0xf0) | t That would work for that specific case. In order to make it more adaptable, I'd put it in a function,

Swapping bits at a given point between two bytes

非 Y 不嫁゛ 提交于 2021-02-13 17:03:16
问题 Let's say I have these two numbers: x = 0xB7 y = 0xD9 Their binary representations are: x = 1011 0111 y = 1101 1001 Now I want to crossover (GA) at a given point, say from position 4 onwards. The expected result should be: x = 1011 1001 y = 1101 0111 Bitwise, how can I achieve this? 回答1: I would just use bitwise operators: t = (x & 0x0f) x = (x & 0xf0) | (y & 0x0f) y = (y & 0xf0) | t That would work for that specific case. In order to make it more adaptable, I'd put it in a function,

There is a missing attribute in the chromosome in genetic algorithm

你离开我真会死。 提交于 2021-02-11 09:15:37
问题 I'm building a model about airline scheduling by using genetic algorithms that generate a flight schedule on a daily basis and assigning the right aircraft too. Each chromosome represents a total of 50 flight legs a day(including the return trip that means 100 trips a day) and I have 42 legs, so obviously there will be repeated flight legs. The initial members are created randomly, and there are some constraints that must be satisfied to have a valid schedule. The problem is one of the

Faster way to group data than pandas groupby

风格不统一 提交于 2021-01-29 08:02:09
问题 I am implementing a Genetic Algorithm. For this algorithm a number of iterations (between 100 to 500) have to be done where in each iteration all 100 individuals are evaluated for their 'fitness'. To this extent, I have written an evaluate function. However, even for one iteration evaluating the fitness of the 100 individuals already takes 13 seconds. I have to speed this up massively in order to implement an efficient algorithm. The evaluate function takes two arguments, and then performs

All objects made through constructor have the same vectors

房东的猫 提交于 2021-01-28 23:55:30
问题 I'm new to C++ and I am trying to create a basic genetic algorithm. I created a Chromosome class and want to create a Society class that generates a vector of these Chromosomes with randomly generated "genes". Genes being the vector in the Chromosome that holds values of 0 or 1. I was testing out the Chromosome constructor, and all of the objects have the same gene vectors. How can I make the constructor generate random values? I have included code below. Any other coding practice or

All objects made through constructor have the same vectors

↘锁芯ラ 提交于 2021-01-28 23:43:35
问题 I'm new to C++ and I am trying to create a basic genetic algorithm. I created a Chromosome class and want to create a Society class that generates a vector of these Chromosomes with randomly generated "genes". Genes being the vector in the Chromosome that holds values of 0 or 1. I was testing out the Chromosome constructor, and all of the objects have the same gene vectors. How can I make the constructor generate random values? I have included code below. Any other coding practice or

SpyderKernelApp WARNING No such comm

吃可爱长大的小学妹 提交于 2021-01-03 07:02:19
问题 Running a GA code on spyder through Anaconda, the script runs till the end and just before running the well plotter ( see below): # Well Plotter pdf = matplotlib.backends.backend_pdf.PdfPages("ROP Log.pdf") plt.figure(figsize=(5,21)) plt.plot(well_proposal['Pred_ROP'] , well_proposal['AHD'], c='r', label= 'Predicted ROP') plt.ylim( bottom =max(well_proposal['AHD']), top =min(well_proposal['AHD'])) plt.xlim(right = 100, left = 0) plt.title('ROP VS Along Hole Depth') plt.ylabel("Along Hole

SpyderKernelApp WARNING No such comm

扶醉桌前 提交于 2021-01-03 07:01:31
问题 Running a GA code on spyder through Anaconda, the script runs till the end and just before running the well plotter ( see below): # Well Plotter pdf = matplotlib.backends.backend_pdf.PdfPages("ROP Log.pdf") plt.figure(figsize=(5,21)) plt.plot(well_proposal['Pred_ROP'] , well_proposal['AHD'], c='r', label= 'Predicted ROP') plt.ylim( bottom =max(well_proposal['AHD']), top =min(well_proposal['AHD'])) plt.xlim(right = 100, left = 0) plt.title('ROP VS Along Hole Depth') plt.ylabel("Along Hole

Python multiprocessing.pool's interaction with a class objective function and neuro-evolution

限于喜欢 提交于 2020-06-23 02:47:11
问题 Warning, this is gonna be long since I want to be as specific as I can be. Exact problem: This is a multi-processing problem. I have ensured that my classes all behave as built/expected in previous experiments. edit: said threading beforehand. When I run toy example of my problem in a threaded environment, everything behaves; however, when I transition into my real problem, the code breaks. Specifically, I get a TypeError: can't pickle _thread.lock objects error. Full stack is at the bottom.