Skip to content

Commit 8c0f2fb

Browse files
authored
Add files via upload
1 parent 0e5d795 commit 8c0f2fb

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

Genetic_Algorithm_Assignment.ipynb

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
"def rankSelection(chromosome,fitness,popSize):\n",
167167
" \n",
168168
" rankTotal = sum(x for x in range(0,popSize))\n",
169-
" totRandom = rankTotal*random.uniform(0,rankTotal)\n",
169+
" totRandom = rankTotal*random.uniform(0,1) #CREEPY Something is here\n",
170170
" tot=0\n",
171171
" fitness_sorted = fitness.sort_values(by=['fitness'])\n",
172172
" for i in fitness_sorted.index:\n",
@@ -194,26 +194,15 @@
194194
" parent2 = rankSelection(chromosome,fitness,popSize)\n",
195195
" \n",
196196
" #random crossover point\n",
197-
" crossPoint = random.randint(1,popSize)\n",
197+
" crossPoint = random.randint(1,10)\n",
198198
" \n",
199199
" c1p1 = parent1[1:crossPoint]\n",
200200
" c1p2 = parent1[crossPoint:11]\n",
201201
" \n",
202202
" child =c1p1.append(c1p2)\n",
203203
" \n",
204204
" child = bitflip(child)\n",
205-
" return child\n",
206-
" \n",
207-
" #return parent1, parent2\n",
208-
" #if(random.uniform(0,1)<0.75):\n",
209-
" #crossPoint = random.randint(1,popSize)\n",
210-
" #c1p1 = parent1.loc[,1:crossPoint]\n",
211-
" #c1p2 = parent2.loc[,crossPoint+1:11]\n",
212-
" \n",
213-
" #merge c1p1 and c1p2 as the new offspring\n",
214-
" \n",
215-
" \n",
216-
" "
205+
" return child"
217206
],
218207
"execution_count": 0,
219208
"outputs": []
@@ -287,11 +276,11 @@
287276
},
288277
"source": [
289278
"#initialize\n",
290-
"popSize = 16 #population size\n",
279+
"popSize = 50 #population size\n",
291280
"fifo_index = -1\n",
292281
"\n",
293282
"#iterate model\n",
294-
"values = trainModel(50)\n"
283+
"values = trainModel(500)\n"
295284
],
296285
"execution_count": 0,
297286
"outputs": []
@@ -305,12 +294,12 @@
305294
"base_uri": "https://localhost:8080/",
306295
"height": 204
307296
},
308-
"outputId": "fccba889-e8d2-4fdc-cc48-ecd4aa14a687"
297+
"outputId": "f09e0c6c-2e64-4ef7-d153-03240ac39d6c"
309298
},
310299
"source": [
311300
"values"
312301
],
313-
"execution_count": 139,
302+
"execution_count": 204,
314303
"outputs": [
315304
{
316305
"output_type": "execute_result",
@@ -319,20 +308,20 @@
319308
"file 1 1\n",
320309
"file 2 1\n",
321310
"file 3 1\n",
322-
"file 4 1\n",
323-
"file 5 1\n",
311+
"file 4 0\n",
312+
"file 5 0\n",
324313
"file 6 0\n",
325314
"file 7 1\n",
326315
"file 8 1\n",
327-
"file 9 1\n",
328-
"file 10 0\n",
329-
"Name: 5, dtype: int64"
316+
"file 9 0\n",
317+
"file 10 1\n",
318+
"Name: 0, dtype: int64"
330319
]
331320
},
332321
"metadata": {
333322
"tags": []
334323
},
335-
"execution_count": 139
324+
"execution_count": 204
336325
}
337326
]
338327
},

0 commit comments

Comments
 (0)