Commit 6133c359 by Febby Simanjuntak

Updated TA13

parent af4f8e35
...@@ -119,6 +119,41 @@ ...@@ -119,6 +119,41 @@
" <td>3.7704</td>\n", " <td>3.7704</td>\n",
" <td>98.6321</td>\n", " <td>98.6321</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Aek Kanopan</td>\n",
" <td>4.8</td>\n",
" <td>2.5633</td>\n",
" <td>99.5229</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Aek Malapari</td>\n",
" <td>5.0</td>\n",
" <td>2.2680</td>\n",
" <td>99.7627</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Aek Milas</td>\n",
" <td>3.9</td>\n",
" <td>1.5227</td>\n",
" <td>99.2204</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Aek Milas Paringgonan Sibuhuan</td>\n",
" <td>4.0</td>\n",
" <td>2.0399</td>\n",
" <td>99.8223</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Aek Sipaulak Hosa Loja</td>\n",
" <td>4.5</td>\n",
" <td>2.8446</td>\n",
" <td>98.5291</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -129,7 +164,12 @@ ...@@ -129,7 +164,12 @@
"1 A8 Village 4.0 2.0137 99.0037\n", "1 A8 Village 4.0 2.0137 99.0037\n",
"2 Air Terjun Sigarattung ( Sampuran Na Pitu) 4.5 2.4042 99.0474\n", "2 Air Terjun Sigarattung ( Sampuran Na Pitu) 4.5 2.4042 99.0474\n",
"3 Air Terjun Taman Eden 100, Tobasa 4.4 2.6951 98.6897\n", "3 Air Terjun Taman Eden 100, Tobasa 4.4 2.6951 98.6897\n",
"4 Abadas Jaya 4.3 3.7704 98.6321" "4 Abadas Jaya 4.3 3.7704 98.6321\n",
"5 Aek Kanopan 4.8 2.5633 99.5229\n",
"6 Aek Malapari 5.0 2.2680 99.7627\n",
"7 Aek Milas 3.9 1.5227 99.2204\n",
"8 Aek Milas Paringgonan Sibuhuan 4.0 2.0399 99.8223\n",
"9 Aek Sipaulak Hosa Loja 4.5 2.8446 98.5291"
] ]
}, },
"execution_count": 2, "execution_count": 2,
...@@ -140,7 +180,7 @@ ...@@ -140,7 +180,7 @@
"source": [ "source": [
"df = pd.read_csv('Pre_TA_13.csv', engine='python')\n", "df = pd.read_csv('Pre_TA_13.csv', engine='python')\n",
"print ('Banyak data =', len(df))\n", "print ('Banyak data =', len(df))\n",
"df.head()" "df.head(10)"
] ]
}, },
{ {
...@@ -189,8 +229,6 @@ ...@@ -189,8 +229,6 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"def generate(datatempat):\n", "def generate(datatempat):\n",
" tempatwisata =[]\n",
" tempatwisata.clear()\n",
" tempatwisata = generateTempatWisataDataFrame(datatempat)\n", " tempatwisata = generateTempatWisataDataFrame(datatempat)\n",
" return tempatwisata" " return tempatwisata"
] ]
...@@ -229,15 +267,8 @@ ...@@ -229,15 +267,8 @@
" arr2.append(x+1)\n", " arr2.append(x+1)\n",
" cek = True\n", " cek = True\n",
" break\n", " break\n",
" return arr2" " return arr2\n",
] "\n",
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"#def getItinerary(tempatwisata):\n", "#def getItinerary(tempatwisata):\n",
"# tempat.clear()\n", "# tempat.clear()\n",
"# Itine = generateItinerary(tempatwisata)\n", "# Itine = generateItinerary(tempatwisata)\n",
...@@ -248,7 +279,7 @@ ...@@ -248,7 +279,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -324,12 +355,12 @@ ...@@ -324,12 +355,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"inputt = []\n",
"def inputan(Itinerary):\n", "def inputan(Itinerary):\n",
" inputt = []\n",
" inputt.clear()\n", " inputt.clear()\n",
" p = preItinerary\n", " p = preItinerary\n",
" preproses_Itinerary = p.getLongLat(Itinerary)\n", " preproses_Itinerary = p.getLongLat(Itinerary)\n",
...@@ -359,163 +390,192 @@ ...@@ -359,163 +390,192 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def Randomtest1():\n",
" d = []\n",
" data = []\n",
" d.clear()\n",
" data.clear()\n",
" data = df[\"Tempat Wisata\"]\n",
" d = generate(data)\n",
" inn = inputan(d)\n",
" return inn"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"def Randomtest2():\n",
" c = []\n",
" data = []\n",
" data.clear()\n",
" data = df[\"Tempat Wisata\"]\n",
" c = generate(data)\n",
" innn = inputan(c)\n",
" return innn"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"def printt():\n",
" print(Randomtest2(), \"\\n\")\n",
" print(Randomtest1())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(2):\n",
" x1 = inputan(tempatwisata)\n",
" print(x1)\n",
" x1.clear()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x2 = inputan(tempatwisata)\n",
"x2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class simanneal:\n",
" def rumus(x1 , x2):\n",
" for i in range(len(x1)):\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def simulatedAnnealing(itinawal):\n",
" baru = 0\n",
" inp = getItinerary(tempatwisata)\n",
" \n",
" for i in range (10):\n",
" x2 = inputan(inp[0][0])\n",
" print(itinawal, \"\\t\", x2, \"\\t\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"x1 = inputan(Itinerary)\n", "class random:\n",
"\n", " def test(data):\n",
"def rumus(param1, param2):\n", " da = generate(data)\n",
" pa1 = param1[0][0]\n", " inn = inputan(da)\n",
" pa2 = param2[0][0]\n", " return (inn)\n",
" return pa2\n", " def test1(data):\n",
" tempatbaru = []\n",
" tempatbaru.clear()\n",
" da = generate(data)\n",
" inn = inputan(da)\n",
" tempatbaru.append((inn, da))\n",
" return tempatbaru\n",
" \n", " \n",
"def simulatedAnnealing(itinawal):\n", "temp_Case = []\n",
" baru = 0\n", "class simeal:\n",
" inp = getItinerary(tempatwisata)\n", " def calculate(x1, x2):\n",
" if (x1[0][0] < x2[0][0] and x1[0][3] < x2[0][3]) or (x1[0][0] < x2[0][0] and x1[0][3] == x2[0][3]):\n",
" return x1\n",
" else:\n",
" return x2\n",
" \n", " \n",
" for i in range (10):\n", " def solution():\n",
" x2 = inputan(inp[0][0])\n", " data = df[\"Tempat Wisata\"]\n",
" print(itinawal, \"\\t\", x2, \"\\t\")\n", " r = random \n",
" T_akhir = 50\n",
" T_awal = 0.001\n",
" CoolingRate = 0.9\n",
" while T_awal < T_akhir:\n",
" x1 = r.test(data)\n",
" x2 = r.test(data)\n",
" Newstate = simeal.calculate(x1, x2)\n",
" temp_Case.append(Newstate)\n",
" T_akhir = T_akhir * CoolingRate\n",
" \n",
" return temp_Case\n",
" " " "
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"x1 = inputan(Itinerary)\n", "SA = simeal\n",
"x2 = getItinerary(tempatwisata)\n", "solution = SA.solution()"
"inp = inputan(x2[0][0])\n",
"rumus(x1, inp)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 10,
"metadata": {}, "metadata": {
"outputs": [], "scrolled": true
"source": [] },
}, "outputs": [
{ {
"cell_type": "code", "name": "stdout",
"execution_count": null, "output_type": "stream",
"metadata": {}, "text": [
"outputs": [], "103 \n",
"\n"
]
},
{
"data": {
"text/plain": [
"[[(13863, 231, 1462217, 3.3)],\n",
" [(89868, 1498, 4271652, 3.8)],\n",
" [(144980, 2416, 6307217, 3.9)],\n",
" [(249405, 4157, 10167696, 3.9)],\n",
" [(261583, 4360, 10617826, 3.9)],\n",
" [(362630, 6044, 14351913, 3.9)],\n",
" [(429363, 7156, 16817652, 3.9)],\n",
" [(505222, 8420, 19620435, 3.9)],\n",
" [(529619, 8827, 20522913, 3.9)],\n",
" [(552620, 9210, 21372174, 3.9)],\n",
" [(622192, 10370, 23944348, 3.9)],\n",
" [(690243, 11504, 26458870, 3.9)],\n",
" [(773862, 12898, 29549913, 3.9)],\n",
" [(827498, 13792, 31532261, 3.9)],\n",
" [(935338, 15589, 35516913, 3.9)],\n",
" [(1031397, 17190, 39066957, 3.9)],\n",
" [(1102689, 18378, 41701217, 3.9)],\n",
" [(1110899, 18515, 42005000, 3.9)],\n",
" [(1161551, 19359, 43876478, 3.9)],\n",
" [(1209299, 20155, 45641522, 3.9)],\n",
" [(1286961, 21449, 48510826, 3.9)],\n",
" [(1351217, 22520, 50885652, 3.9)],\n",
" [(1402482, 23375, 52781522, 3.9)],\n",
" [(1460180, 24336, 54912435, 3.9)],\n",
" [(1483758, 24729, 55783870, 3.9)],\n",
" [(1551133, 25852, 58274000, 3.9)],\n",
" [(1610640, 26844, 60473652, 3.9)],\n",
" [(1635536, 27259, 61393870, 3.9)],\n",
" [(1684344, 28072, 63196609, 3.9)],\n",
" [(1755869, 29264, 65839739, 3.9)],\n",
" [(1813311, 30222, 67964000, 3.9)],\n",
" [(1886629, 31444, 70673652, 3.9)],\n",
" [(1911625, 31860, 71596087, 3.9)],\n",
" [(1955419, 32590, 73214783, 3.9)],\n",
" [(2014036, 33567, 75381174, 3.9)],\n",
" [(2113907, 35232, 79073130, 3.9)],\n",
" [(2164263, 36071, 80933522, 3.9)],\n",
" [(2207604, 36793, 82534478, 3.9)],\n",
" [(2234486, 37241, 83527870, 3.9)],\n",
" [(2265011, 37750, 84656522, 3.9)],\n",
" [(2300444, 38341, 85967000, 3.9)],\n",
" [(2312185, 38536, 86399391, 3.9)],\n",
" [(2325088, 38751, 86876130, 3.9)],\n",
" [(2332362, 38873, 87146652, 3.9)],\n",
" [(2380353, 39673, 88920565, 3.9)],\n",
" [(2391962, 39866, 89348522, 3.9)],\n",
" [(2408957, 40149, 89976043, 3.9)],\n",
" [(2431321, 40522, 90803130, 3.9)],\n",
" [(2432805, 40547, 90858565, 3.9)],\n",
" [(2432805, 40547, 90858565, 3.9)],\n",
" [(2458989, 40983, 91825348, 3.9)],\n",
" [(2497274, 41621, 93240043, 4.0)],\n",
" [(2513098, 41885, 93825435, 4.0)],\n",
" [(2523481, 42058, 94209043, 4.0)],\n",
" [(2528938, 42149, 94410826, 4.0)],\n",
" [(2582968, 43049, 96406478, 4.0)],\n",
" [(2601879, 43365, 97107174, 4.0)],\n",
" [(2654688, 44245, 99058478, 3.9)],\n",
" [(2660983, 44350, 99291304, 3.9)],\n",
" [(2731953, 45533, 101914478, 3.9)],\n",
" [(2737747, 45629, 102127348, 3.9)],\n",
" [(2767939, 46132, 103242696, 3.9)],\n",
" [(2771330, 46189, 103369087, 3.9)],\n",
" [(2799940, 46666, 104426783, 3.9)],\n",
" [(2815276, 46921, 104992217, 3.9)],\n",
" [(2827147, 47119, 105431261, 3.9)],\n",
" [(2827147, 47119, 105431261, 3.9)],\n",
" [(2834867, 47248, 105717304, 3.9)],\n",
" [(2852285, 47538, 106360348, 3.9)],\n",
" [(2862839, 47714, 106750609, 3.9)],\n",
" [(2908762, 48479, 108446913, 3.9)],\n",
" [(2960043, 49334, 110342783, 3.9)],\n",
" [(2987602, 49793, 111360565, 3.9)],\n",
" [(3004256, 50071, 111977000, 3.9)],\n",
" [(3015771, 50263, 112402739, 3.9)],\n",
" [(3062580, 51043, 114132304, 3.9)],\n",
" [(3093976, 51566, 115292000, 3.9)],\n",
" [(3122500, 52042, 116347478, 3.9)],\n",
" [(3127831, 52131, 116544826, 3.9)],\n",
" [(3140669, 52344, 117017130, 3.9)],\n",
" [(3170348, 52839, 118114739, 3.9)],\n",
" [(3188523, 53142, 118786609, 3.9)],\n",
" [(3224568, 53743, 120119261, 3.9)],\n",
" [(3224638, 53744, 120121478, 3.9)],\n",
" [(3224638, 53744, 120121478, 3.9)],\n",
" [(3229621, 53827, 120305522, 3.9)],\n",
" [(3253523, 54225, 121188043, 3.9)],\n",
" [(3268519, 54475, 121742391, 3.9)],\n",
" [(3272466, 54541, 121888739, 3.9)],\n",
" [(3303220, 55054, 123026261, 3.9)],\n",
" [(3374678, 56245, 125667174, 3.9)],\n",
" [(3377774, 56296, 125780261, 3.9)],\n",
" [(3377774, 56296, 125780261, 3.9)],\n",
" [(3388066, 56468, 126161652, 3.9)],\n",
" [(3401549, 56692, 126658348, 3.9)],\n",
" [(3423514, 57059, 127472130, 3.9)],\n",
" [(3449106, 57485, 128416739, 3.9)],\n",
" [(3449150, 57486, 128418957, 3.9)],\n",
" [(3453866, 57564, 128591913, 3.9)],\n",
" [(3471294, 57855, 129237174, 3.9)],\n",
" [(3485213, 58087, 129751609, 3.9)],\n",
" [(3491102, 58185, 129968913, 3.9)],\n",
" [(3491751, 58196, 129993304, 3.9)]]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"x2 = []\n", "print(len(solution), \"\\n\")\n",
"x2.clear()\n", "solution"
"inp.clear()\n",
"x2 = getItinerary(tempatwisata)\n",
"inp = inputan(x2[0][0])\n",
"#print(x2, \"\\n\\n\")\n",
"print(inp, \"\\n\\n\")"
] ]
}, },
{ {
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
...@@ -527,14 +587,10 @@ ...@@ -527,14 +587,10 @@
"execution_count": null, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
}, "#Initial Solution\n",
{ "class initial:"
"cell_type": "code", ]
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
......
...@@ -119,6 +119,41 @@ ...@@ -119,6 +119,41 @@
" <td>3.7704</td>\n", " <td>3.7704</td>\n",
" <td>98.6321</td>\n", " <td>98.6321</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Aek Kanopan</td>\n",
" <td>4.8</td>\n",
" <td>2.5633</td>\n",
" <td>99.5229</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Aek Malapari</td>\n",
" <td>5.0</td>\n",
" <td>2.2680</td>\n",
" <td>99.7627</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Aek Milas</td>\n",
" <td>3.9</td>\n",
" <td>1.5227</td>\n",
" <td>99.2204</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Aek Milas Paringgonan Sibuhuan</td>\n",
" <td>4.0</td>\n",
" <td>2.0399</td>\n",
" <td>99.8223</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Aek Sipaulak Hosa Loja</td>\n",
" <td>4.5</td>\n",
" <td>2.8446</td>\n",
" <td>98.5291</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -129,7 +164,12 @@ ...@@ -129,7 +164,12 @@
"1 A8 Village 4.0 2.0137 99.0037\n", "1 A8 Village 4.0 2.0137 99.0037\n",
"2 Air Terjun Sigarattung ( Sampuran Na Pitu) 4.5 2.4042 99.0474\n", "2 Air Terjun Sigarattung ( Sampuran Na Pitu) 4.5 2.4042 99.0474\n",
"3 Air Terjun Taman Eden 100, Tobasa 4.4 2.6951 98.6897\n", "3 Air Terjun Taman Eden 100, Tobasa 4.4 2.6951 98.6897\n",
"4 Abadas Jaya 4.3 3.7704 98.6321" "4 Abadas Jaya 4.3 3.7704 98.6321\n",
"5 Aek Kanopan 4.8 2.5633 99.5229\n",
"6 Aek Malapari 5.0 2.2680 99.7627\n",
"7 Aek Milas 3.9 1.5227 99.2204\n",
"8 Aek Milas Paringgonan Sibuhuan 4.0 2.0399 99.8223\n",
"9 Aek Sipaulak Hosa Loja 4.5 2.8446 98.5291"
] ]
}, },
"execution_count": 2, "execution_count": 2,
...@@ -140,7 +180,7 @@ ...@@ -140,7 +180,7 @@
"source": [ "source": [
"df = pd.read_csv('Pre_TA_13.csv', engine='python')\n", "df = pd.read_csv('Pre_TA_13.csv', engine='python')\n",
"print ('Banyak data =', len(df))\n", "print ('Banyak data =', len(df))\n",
"df.head()" "df.head(10)"
] ]
}, },
{ {
...@@ -189,8 +229,6 @@ ...@@ -189,8 +229,6 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"def generate(datatempat):\n", "def generate(datatempat):\n",
" tempatwisata =[]\n",
" tempatwisata.clear()\n",
" tempatwisata = generateTempatWisataDataFrame(datatempat)\n", " tempatwisata = generateTempatWisataDataFrame(datatempat)\n",
" return tempatwisata" " return tempatwisata"
] ]
...@@ -229,15 +267,8 @@ ...@@ -229,15 +267,8 @@
" arr2.append(x+1)\n", " arr2.append(x+1)\n",
" cek = True\n", " cek = True\n",
" break\n", " break\n",
" return arr2" " return arr2\n",
] "\n",
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"#def getItinerary(tempatwisata):\n", "#def getItinerary(tempatwisata):\n",
"# tempat.clear()\n", "# tempat.clear()\n",
"# Itine = generateItinerary(tempatwisata)\n", "# Itine = generateItinerary(tempatwisata)\n",
...@@ -248,7 +279,7 @@ ...@@ -248,7 +279,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -324,12 +355,12 @@ ...@@ -324,12 +355,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"inputt = []\n",
"def inputan(Itinerary):\n", "def inputan(Itinerary):\n",
" inputt = []\n",
" inputt.clear()\n", " inputt.clear()\n",
" p = preItinerary\n", " p = preItinerary\n",
" preproses_Itinerary = p.getLongLat(Itinerary)\n", " preproses_Itinerary = p.getLongLat(Itinerary)\n",
...@@ -359,163 +390,192 @@ ...@@ -359,163 +390,192 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def Randomtest1():\n",
" d = []\n",
" data = []\n",
" d.clear()\n",
" data.clear()\n",
" data = df[\"Tempat Wisata\"]\n",
" d = generate(data)\n",
" inn = inputan(d)\n",
" return inn"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"def Randomtest2():\n",
" c = []\n",
" data = []\n",
" data.clear()\n",
" data = df[\"Tempat Wisata\"]\n",
" c = generate(data)\n",
" innn = inputan(c)\n",
" return innn"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"def printt():\n",
" print(Randomtest2(), \"\\n\")\n",
" print(Randomtest1())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(2):\n",
" x1 = inputan(tempatwisata)\n",
" print(x1)\n",
" x1.clear()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x2 = inputan(tempatwisata)\n",
"x2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class simanneal:\n",
" def rumus(x1 , x2):\n",
" for i in range(len(x1)):\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def simulatedAnnealing(itinawal):\n",
" baru = 0\n",
" inp = getItinerary(tempatwisata)\n",
" \n",
" for i in range (10):\n",
" x2 = inputan(inp[0][0])\n",
" print(itinawal, \"\\t\", x2, \"\\t\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"x1 = inputan(Itinerary)\n", "class random:\n",
"\n", " def test(data):\n",
"def rumus(param1, param2):\n", " da = generate(data)\n",
" pa1 = param1[0][0]\n", " inn = inputan(da)\n",
" pa2 = param2[0][0]\n", " return (inn)\n",
" return pa2\n", " def test1(data):\n",
" tempatbaru = []\n",
" tempatbaru.clear()\n",
" da = generate(data)\n",
" inn = inputan(da)\n",
" tempatbaru.append((inn, da))\n",
" return tempatbaru\n",
" \n", " \n",
"def simulatedAnnealing(itinawal):\n", "temp_Case = []\n",
" baru = 0\n", "class simeal:\n",
" inp = getItinerary(tempatwisata)\n", " def calculate(x1, x2):\n",
" if (x1[0][0] < x2[0][0] and x1[0][3] < x2[0][3]) or (x1[0][0] < x2[0][0] and x1[0][3] == x2[0][3]):\n",
" return x1\n",
" else:\n",
" return x2\n",
" \n", " \n",
" for i in range (10):\n", " def solution():\n",
" x2 = inputan(inp[0][0])\n", " data = df[\"Tempat Wisata\"]\n",
" print(itinawal, \"\\t\", x2, \"\\t\")\n", " r = random \n",
" T_akhir = 50\n",
" T_awal = 0.001\n",
" CoolingRate = 0.9\n",
" while T_awal < T_akhir:\n",
" x1 = r.test(data)\n",
" x2 = r.test(data)\n",
" Newstate = simeal.calculate(x1, x2)\n",
" temp_Case.append(Newstate)\n",
" T_akhir = T_akhir * CoolingRate\n",
" \n",
" return temp_Case\n",
" " " "
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"x1 = inputan(Itinerary)\n", "SA = simeal\n",
"x2 = getItinerary(tempatwisata)\n", "solution = SA.solution()"
"inp = inputan(x2[0][0])\n",
"rumus(x1, inp)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 10,
"metadata": {}, "metadata": {
"outputs": [], "scrolled": true
"source": [] },
}, "outputs": [
{ {
"cell_type": "code", "name": "stdout",
"execution_count": null, "output_type": "stream",
"metadata": {}, "text": [
"outputs": [], "103 \n",
"\n"
]
},
{
"data": {
"text/plain": [
"[[(13863, 231, 1462217, 3.3)],\n",
" [(89868, 1498, 4271652, 3.8)],\n",
" [(144980, 2416, 6307217, 3.9)],\n",
" [(249405, 4157, 10167696, 3.9)],\n",
" [(261583, 4360, 10617826, 3.9)],\n",
" [(362630, 6044, 14351913, 3.9)],\n",
" [(429363, 7156, 16817652, 3.9)],\n",
" [(505222, 8420, 19620435, 3.9)],\n",
" [(529619, 8827, 20522913, 3.9)],\n",
" [(552620, 9210, 21372174, 3.9)],\n",
" [(622192, 10370, 23944348, 3.9)],\n",
" [(690243, 11504, 26458870, 3.9)],\n",
" [(773862, 12898, 29549913, 3.9)],\n",
" [(827498, 13792, 31532261, 3.9)],\n",
" [(935338, 15589, 35516913, 3.9)],\n",
" [(1031397, 17190, 39066957, 3.9)],\n",
" [(1102689, 18378, 41701217, 3.9)],\n",
" [(1110899, 18515, 42005000, 3.9)],\n",
" [(1161551, 19359, 43876478, 3.9)],\n",
" [(1209299, 20155, 45641522, 3.9)],\n",
" [(1286961, 21449, 48510826, 3.9)],\n",
" [(1351217, 22520, 50885652, 3.9)],\n",
" [(1402482, 23375, 52781522, 3.9)],\n",
" [(1460180, 24336, 54912435, 3.9)],\n",
" [(1483758, 24729, 55783870, 3.9)],\n",
" [(1551133, 25852, 58274000, 3.9)],\n",
" [(1610640, 26844, 60473652, 3.9)],\n",
" [(1635536, 27259, 61393870, 3.9)],\n",
" [(1684344, 28072, 63196609, 3.9)],\n",
" [(1755869, 29264, 65839739, 3.9)],\n",
" [(1813311, 30222, 67964000, 3.9)],\n",
" [(1886629, 31444, 70673652, 3.9)],\n",
" [(1911625, 31860, 71596087, 3.9)],\n",
" [(1955419, 32590, 73214783, 3.9)],\n",
" [(2014036, 33567, 75381174, 3.9)],\n",
" [(2113907, 35232, 79073130, 3.9)],\n",
" [(2164263, 36071, 80933522, 3.9)],\n",
" [(2207604, 36793, 82534478, 3.9)],\n",
" [(2234486, 37241, 83527870, 3.9)],\n",
" [(2265011, 37750, 84656522, 3.9)],\n",
" [(2300444, 38341, 85967000, 3.9)],\n",
" [(2312185, 38536, 86399391, 3.9)],\n",
" [(2325088, 38751, 86876130, 3.9)],\n",
" [(2332362, 38873, 87146652, 3.9)],\n",
" [(2380353, 39673, 88920565, 3.9)],\n",
" [(2391962, 39866, 89348522, 3.9)],\n",
" [(2408957, 40149, 89976043, 3.9)],\n",
" [(2431321, 40522, 90803130, 3.9)],\n",
" [(2432805, 40547, 90858565, 3.9)],\n",
" [(2432805, 40547, 90858565, 3.9)],\n",
" [(2458989, 40983, 91825348, 3.9)],\n",
" [(2497274, 41621, 93240043, 4.0)],\n",
" [(2513098, 41885, 93825435, 4.0)],\n",
" [(2523481, 42058, 94209043, 4.0)],\n",
" [(2528938, 42149, 94410826, 4.0)],\n",
" [(2582968, 43049, 96406478, 4.0)],\n",
" [(2601879, 43365, 97107174, 4.0)],\n",
" [(2654688, 44245, 99058478, 3.9)],\n",
" [(2660983, 44350, 99291304, 3.9)],\n",
" [(2731953, 45533, 101914478, 3.9)],\n",
" [(2737747, 45629, 102127348, 3.9)],\n",
" [(2767939, 46132, 103242696, 3.9)],\n",
" [(2771330, 46189, 103369087, 3.9)],\n",
" [(2799940, 46666, 104426783, 3.9)],\n",
" [(2815276, 46921, 104992217, 3.9)],\n",
" [(2827147, 47119, 105431261, 3.9)],\n",
" [(2827147, 47119, 105431261, 3.9)],\n",
" [(2834867, 47248, 105717304, 3.9)],\n",
" [(2852285, 47538, 106360348, 3.9)],\n",
" [(2862839, 47714, 106750609, 3.9)],\n",
" [(2908762, 48479, 108446913, 3.9)],\n",
" [(2960043, 49334, 110342783, 3.9)],\n",
" [(2987602, 49793, 111360565, 3.9)],\n",
" [(3004256, 50071, 111977000, 3.9)],\n",
" [(3015771, 50263, 112402739, 3.9)],\n",
" [(3062580, 51043, 114132304, 3.9)],\n",
" [(3093976, 51566, 115292000, 3.9)],\n",
" [(3122500, 52042, 116347478, 3.9)],\n",
" [(3127831, 52131, 116544826, 3.9)],\n",
" [(3140669, 52344, 117017130, 3.9)],\n",
" [(3170348, 52839, 118114739, 3.9)],\n",
" [(3188523, 53142, 118786609, 3.9)],\n",
" [(3224568, 53743, 120119261, 3.9)],\n",
" [(3224638, 53744, 120121478, 3.9)],\n",
" [(3224638, 53744, 120121478, 3.9)],\n",
" [(3229621, 53827, 120305522, 3.9)],\n",
" [(3253523, 54225, 121188043, 3.9)],\n",
" [(3268519, 54475, 121742391, 3.9)],\n",
" [(3272466, 54541, 121888739, 3.9)],\n",
" [(3303220, 55054, 123026261, 3.9)],\n",
" [(3374678, 56245, 125667174, 3.9)],\n",
" [(3377774, 56296, 125780261, 3.9)],\n",
" [(3377774, 56296, 125780261, 3.9)],\n",
" [(3388066, 56468, 126161652, 3.9)],\n",
" [(3401549, 56692, 126658348, 3.9)],\n",
" [(3423514, 57059, 127472130, 3.9)],\n",
" [(3449106, 57485, 128416739, 3.9)],\n",
" [(3449150, 57486, 128418957, 3.9)],\n",
" [(3453866, 57564, 128591913, 3.9)],\n",
" [(3471294, 57855, 129237174, 3.9)],\n",
" [(3485213, 58087, 129751609, 3.9)],\n",
" [(3491102, 58185, 129968913, 3.9)],\n",
" [(3491751, 58196, 129993304, 3.9)]]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"x2 = []\n", "print(len(solution), \"\\n\")\n",
"x2.clear()\n", "solution"
"inp.clear()\n",
"x2 = getItinerary(tempatwisata)\n",
"inp = inputan(x2[0][0])\n",
"#print(x2, \"\\n\\n\")\n",
"print(inp, \"\\n\\n\")"
] ]
}, },
{ {
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
...@@ -527,14 +587,10 @@ ...@@ -527,14 +587,10 @@
"execution_count": null, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
}, "#Initial Solution\n",
{ "class initial:"
"cell_type": "code", ]
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
......
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