Commitv6

parent 4bff5ec6
ID_City,City,Biaya ID_City,City,Biaya
0,Pantai BUL BUL,10000 0,Pantai BUL BUL,0
1,BUKIT travel Gibeon,10001 1,BUKIT travel Gibeon,10000
2,Pakkodian,10002 2,Pakkodian,0
3,Taman Eden 100 Tobasa,10003 3,Taman Eden 100 Tobasa,10000
4,Water Park Tambunan,10004 4,Water Park Tambunan,15000
5,Bukit Pahoda,10005 5,Bukit Pahoda,0
6,Bukit Senyum,10006 6,Bukit Senyum,10000
7,Air Terjun Pandumaan,10007 7,Air Terjun Pandumaan,0
8,Long Beach,10008 8,Long Beach,5000
9,PANTAI AGADON,10009 9,PANTAI AGADON,0
10,Situmurun Waterfall,10010 10,Situmurun Waterfall,0
11,Simanimbo Waterfall,10011 11,Simanimbo Waterfall,0
12,Air Terjun Sigura Gura,10012 12,Air Terjun Sigura Gura,10000
13,The Kaldera,10013 13,The Kaldera,0
14,Museum T. B. Silalahi Center,10014 14,Museum T. B. Silalahi Center,10000
15,Bukit Tarabunga,10015 15,Bukit Tarabunga,0
16,Pantai Meat,10016 16,Pantai Meat,0
17,Air Terjun Sialogo,10017 17,Air Terjun Sialogo,0
18,Air Terjun Siboruon,10018 18,Air Terjun Siboruon,0
19,Gunung Pangulubao,10019 19,Gunung Pangulubao,5000
20,Lumban Silintong,10020 20,Lumban Silintong,10000
21,Siregar Aek Nalas,10021 21,Siregar Aek Nalas,5000
22,Pantai Janji Maria,10022 22,Pantai Janji Maria,0
23,Balerong Onan Balige,10023 23,Balerong Onan Balige,0
24,Dolok Tolong,10024 24,Dolok Tolong,0
25,Pantai Pasir Putih Parparean,10025 25,Pantai Pasir Putih Parparean,0
26,Dolok Surungan,10026 26,Dolok Surungan,0
27,Air Terjun Sampuran,10027 27,Air Terjun Sampuran,0
28,Air Terjun Morena,10028 28,Air Terjun Morena,0
29,Tornagodang,10029 29,Tornagodang,0
30,Hatulian Beach,10030 30,Hatulian Beach,5000
31,Monumen Raja Sonakmalela,10031 31,Monumen Raja Sonakmalela,0
32,Lumban Binanga Beach,10032 32,Lumban Binanga Beach,0
33,Pantai Pasifik Porsea,10033 33,Pantai Pasifik Porsea,2000
34,Desa Adat Ragi Hotang,10034 34,Desa Adat Ragi Hotang,0
35,Makam Raja Sisingamangaraja XII,10035 35,Makam Raja Sisingamangaraja XII,0
This diff is collapsed. Click to expand it.
...@@ -412,18 +412,18 @@ ...@@ -412,18 +412,18 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Route: 5, 1, 6, 4, 0, 3, 2, Distance: 238.00000000000003\n", "Route: 2, 5, 4, 1, 0, 3, 6, Distance: 248.0\n",
"Route: 1, 3, 6, 4, 5, 2, 0, Distance: 162.29999999999998\n", "Route: 6, 3, 4, 2, 5, 0, 1, Distance: 153.1\n",
"Route: 0, 2, 4, 1, 5, 3, 6, Distance: 251.5\n", "Route: 2, 4, 3, 6, 5, 0, 1, Distance: 251.5\n",
"Route: 1, 3, 5, 2, 0, 6, 4, Distance: 242.2\n", "Route: 2, 4, 3, 6, 5, 0, 1, Distance: 251.5\n",
"Route: 5, 4, 6, 1, 2, 3, 0, Distance: 305.3\n", "Route: 6, 1, 2, 0, 3, 4, 5, Distance: 241.39999999999998\n",
"Changes for particle 1: 0\n", "Changes for particle 1: 0\n",
"Changes for particle 2: 0\n", "Changes for particle 2: 0\n",
"Changes for particle 3: 0\n", "Changes for particle 3: 0\n",
"Changes for particle 4: 0\n", "Changes for particle 4: 1\n",
"epoch number: 0\n", "epoch number: 0\n",
"Target reached.\n", "Target reached.\n",
"Best Route: 4, 3, 6, 1, 5, 0, 2, Distance: 156.6\n" "Best Route: 6, 3, 4, 2, 5, 0, 1, Distance: 153.1\n"
] ]
} }
], ],
...@@ -442,7 +442,7 @@ ...@@ -442,7 +442,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"[4, 3, 6, 1, 5, 0, 2]" "[6, 3, 4, 2, 5, 0, 1]"
] ]
}, },
"execution_count": 20, "execution_count": 20,
...@@ -487,13 +487,13 @@ ...@@ -487,13 +487,13 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Water Park Tambunan\n",
"Taman Eden 100 Tobasa\n",
"Bukit Senyum\n", "Bukit Senyum\n",
"BUKIT travel Gibeon\n", "Taman Eden 100 Tobasa\n",
"Water Park Tambunan\n",
"Pakkodian\n",
"Bukit Pahoda\n", "Bukit Pahoda\n",
"Pantai BUL BUL\n", "Pantai BUL BUL\n",
"Pakkodian\n" "BUKIT travel Gibeon\n"
] ]
} }
], ],
...@@ -686,24 +686,24 @@ ...@@ -686,24 +686,24 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Route : [2, 5, 35, 14, 29, 18, 21, 2]\n", "Route : [0, 14, 31, 23, 30, 27, 4, 0]\n",
"179.85 , 70124 , 26.897694\n", "117.53 , 30000 , 26.897694\n",
"\n", "\n",
"\n", "\n",
"Route : [0, 31, 23, 19, 3, 1, 13, 0]\n", "Route : [0, 18, 31, 23, 35, 20, 21, 0]\n",
"117.33 , 70090 , 26.897694\n", "94.23 , 15000 , 26.897694\n",
"\n", "\n",
"\n", "\n",
"Route : [5, 20, 14, 35, 31, 23, 4, 5]\n", "Route : [0, 23, 31, 33, 16, 27, 5, 0]\n",
"20.78 , 70132 , 26.897694\n", "134.83 , 2000 , 26.897694\n",
"\n", "\n",
"\n", "\n",
"Route : [4, 20, 23, 31, 14, 35, 24, 4]\n", "Route : [5, 12, 23, 31, 16, 34, 24, 5]\n",
"30.68 , 70151 , 26.897694\n", "132.22999999999996 , 10000 , 26.897694\n",
"\n", "\n",
"\n", "\n",
"Route : [0, 35, 14, 23, 31, 4, 32, 0]\n", "Route : [0, 16, 2, 31, 23, 34, 24, 0]\n",
"31.68 , 70139 , 26.897694\n", "50.43000000000001 , 0 , 26.897694\n",
"\n", "\n",
"\n" "\n"
] ]
...@@ -759,7 +759,7 @@ ...@@ -759,7 +759,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": 32,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -774,7 +774,7 @@ ...@@ -774,7 +774,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 33,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -782,12 +782,12 @@ ...@@ -782,12 +782,12 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Pantai BUL BUL\n", "Pantai BUL BUL\n",
"Makam Raja Sisingamangaraja XII\n", "Pantai Meat\n",
"Museum T. B. Silalahi Center\n", "Pakkodian\n",
"Balerong Onan Balige\n",
"Monumen Raja Sonakmalela\n", "Monumen Raja Sonakmalela\n",
"Water Park Tambunan\n", "Balerong Onan Balige\n",
"Lumban Binanga Beach\n", "Desa Adat Ragi Hotang\n",
"Dolok Tolong\n",
"Pantai BUL BUL\n" "Pantai BUL BUL\n"
] ]
} }
...@@ -802,6 +802,133 @@ ...@@ -802,6 +802,133 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ABC"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"path = list(Dataz[\"ID_City\"])\n",
"Maximum_distance = Fitness_value.getting_max_distance()\n",
"Maximum_cost = Fitness_value.getting_max_cost()\n",
"def get_total_cost(path):\n",
" cost_route = []\n",
" cost = 0\n",
" for i in range(len(path)):\n",
" cost_route.append(Dataz.iloc[i][2])\n",
" cost = sum(cost_route)\n",
" return cost "
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [],
"source": [
"#Datax"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [],
"source": [
"path = [5, 12, 23, 31, 16, 34, 24, 5]"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [],
"source": [
"def calculate_distance():\n",
" distance_route = []\n",
" last_distance = 0\n",
" distance = 0\n",
" for i in range(0,4):\n",
" source = path[i]\n",
" target = path[i+1]\n",
" distance_route.append(Datax.iloc[source][target])\n",
" for i in range(0,4):\n",
" source = path[len(path)-1]\n",
" target = path[len(path)-len(path)]\n",
" last_distance = Datax.iloc[source][target] \n",
" distance = sum(distance_route)+last_distance\n",
" return distance"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"116.62999999999998"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"calculate_distance()"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [],
"source": [
"def get_last_distance():\n",
" last_distance = 0\n",
" for i in range(0,4):\n",
" source = path[len(path)-1]\n",
" target = path[len(path)-len(path)]\n",
" last_distance = Datax.iloc[source][target]\n",
" return last_distance "
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_last_distance()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment