Skip to content

Commit e2248d9

Browse files
committed
Created using Colaboratory
1 parent e9daf6c commit e2248d9

1 file changed

Lines changed: 77 additions & 27 deletions

File tree

Genetic_Algorithm_Assignment.ipynb

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@
66
"name": "Genetic Algorithm Assignment.ipynb",
77
"version": "0.3.2",
88
"provenance": [],
9-
"collapsed_sections": [
10-
"BEFLTAgH9Jxo",
11-
"7JEmrYDp_IZo",
12-
"o45jFGcl_Rq_",
13-
"KDNuThva_Wj-",
14-
"NrydFJLYZ8TN",
15-
"rYDi-eCZ_hVG",
16-
"ZtPy1zlX_dY_",
17-
"ZZbApi5tApCR"
18-
],
9+
"collapsed_sections": [],
1910
"include_colab_link": true
2011
},
2112
"kernelspec": {
@@ -3153,14 +3144,18 @@
31533144
"def details(row):\n",
31543145
" duration = 0\n",
31553146
" size = 0\n",
3156-
" \n",
3147+
" fitness = 0\n",
31573148
" for i in range(len(row)):\n",
31583149
" if(row[i] == 1):\n",
31593150
" size += df.loc[9-i,'size']\n",
31603151
" duration += df.loc[9-i,'duration']\n",
3152+
" \n",
3153+
" if(size<=4500):\n",
3154+
" fitness += duration\n",
3155+
" else:\n",
3156+
" fitness += duration*0.5\n",
31613157
" \n",
3162-
" \n",
3163-
" return duration,size"
3158+
" return duration,size,fitness"
31643159
],
31653160
"execution_count": 0,
31663161
"outputs": []
@@ -3174,12 +3169,14 @@
31743169
},
31753170
"source": [
31763171
"final_duration = []\n",
3172+
"final_fitness = []\n",
31773173
"final_size = []\n",
31783174
"for i in range(1024):\n",
31793175
" \n",
3180-
" duration,size = details(values.iloc[i].values)\n",
3176+
" duration,size,fitness = details(values.iloc[i].values)\n",
31813177
" final_duration.append(duration)\n",
3182-
" final_size.append(size)"
3178+
" final_size.append(size)\n",
3179+
" final_fitness.append(fitness) "
31833180
],
31843181
"execution_count": 0,
31853182
"outputs": []
@@ -3211,12 +3208,12 @@
32113208
"base_uri": "https://localhost:8080/",
32123209
"height": 34
32133210
},
3214-
"outputId": "edc8afbb-155f-4510-b15b-1921378d1acc"
3211+
"outputId": "4e629572-7965-421b-f27c-e763968446c3"
32153212
},
32163213
"source": [
32173214
"final_size[index]"
32183215
],
3219-
"execution_count": 390,
3216+
"execution_count": 427,
32203217
"outputs": [
32213218
{
32223219
"output_type": "execute_result",
@@ -3228,7 +3225,7 @@
32283225
"metadata": {
32293226
"tags": []
32303227
},
3231-
"execution_count": 390
3228+
"execution_count": 427
32323229
}
32333230
]
32343231
},
@@ -3241,12 +3238,12 @@
32413238
"base_uri": "https://localhost:8080/",
32423239
"height": 34
32433240
},
3244-
"outputId": "38ff8ebd-af24-45fb-cbad-cae6e6ef2c8f"
3241+
"outputId": "f388cf7d-bbc6-4a59-954d-9d6156151b02"
32453242
},
32463243
"source": [
32473244
"final_duration[index]"
32483245
],
3249-
"execution_count": 391,
3246+
"execution_count": 428,
32503247
"outputs": [
32513248
{
32523249
"output_type": "execute_result",
@@ -3258,7 +3255,7 @@
32583255
"metadata": {
32593256
"tags": []
32603257
},
3261-
"execution_count": 391
3258+
"execution_count": 428
32623259
}
32633260
]
32643261
},
@@ -3271,12 +3268,12 @@
32713268
"base_uri": "https://localhost:8080/",
32723269
"height": 34
32733270
},
3274-
"outputId": "96ce9dcb-b5b7-4a62-d6f4-0d76e7319b9d"
3271+
"outputId": "2b0a5479-1031-4fb3-e07d-d00f79472236"
32753272
},
32763273
"source": [
32773274
"index"
32783275
],
3279-
"execution_count": 392,
3276+
"execution_count": 429,
32803277
"outputs": [
32813278
{
32823279
"output_type": "execute_result",
@@ -3288,7 +3285,37 @@
32883285
"metadata": {
32893286
"tags": []
32903287
},
3291-
"execution_count": 392
3288+
"execution_count": 429
3289+
}
3290+
]
3291+
},
3292+
{
3293+
"cell_type": "code",
3294+
"metadata": {
3295+
"id": "c9xYYN9h8mna",
3296+
"colab_type": "code",
3297+
"colab": {
3298+
"base_uri": "https://localhost:8080/",
3299+
"height": 34
3300+
},
3301+
"outputId": "358e148a-4cc9-4c47-cc16-9200a5f98eaf"
3302+
},
3303+
"source": [
3304+
"final_fitness[index]"
3305+
],
3306+
"execution_count": 430,
3307+
"outputs": [
3308+
{
3309+
"output_type": "execute_result",
3310+
"data": {
3311+
"text/plain": [
3312+
"2795"
3313+
]
3314+
},
3315+
"metadata": {
3316+
"tags": []
3317+
},
3318+
"execution_count": 430
32923319
}
32933320
]
32943321
},
@@ -3301,12 +3328,12 @@
33013328
"base_uri": "https://localhost:8080/",
33023329
"height": 204
33033330
},
3304-
"outputId": "89cecf54-75b4-4a41-f259-1a350266ba99"
3331+
"outputId": "6abffb73-e545-46b3-ff34-ffeba5a525cb"
33053332
},
33063333
"source": [
33073334
"values.iloc[index]"
33083335
],
3309-
"execution_count": 386,
3336+
"execution_count": 431,
33103337
"outputs": [
33113338
{
33123339
"output_type": "execute_result",
@@ -3328,7 +3355,7 @@
33283355
"metadata": {
33293356
"tags": []
33303357
},
3331-
"execution_count": 386
3358+
"execution_count": 431
33323359
}
33333360
]
33343361
},
@@ -3344,6 +3371,29 @@
33443371
],
33453372
"execution_count": 0,
33463373
"outputs": []
3374+
},
3375+
{
3376+
"cell_type": "markdown",
3377+
"metadata": {
3378+
"id": "XbQ4-DPC_Eds",
3379+
"colab_type": "text"
3380+
},
3381+
"source": [
3382+
"### **Differential Evolution**"
3383+
]
3384+
},
3385+
{
3386+
"cell_type": "code",
3387+
"metadata": {
3388+
"id": "4v5sDfKd_HWr",
3389+
"colab_type": "code",
3390+
"colab": {}
3391+
},
3392+
"source": [
3393+
""
3394+
],
3395+
"execution_count": 0,
3396+
"outputs": []
33473397
}
33483398
]
33493399
}

0 commit comments

Comments
 (0)