Commit ed6e027b by Yolanda

updating_pso

parent 5c56bae1
......@@ -374,7 +374,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
......@@ -398,7 +398,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
......@@ -412,12 +412,12 @@
"map = [];\n",
"particles = []\n",
"Maximum_distance= Fitness_value.getting_max_distance()\n",
"CITY_COUNT = len(Data4)"
"CITY_COUNT = 7"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
......@@ -443,7 +443,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
......@@ -474,7 +474,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
......@@ -488,7 +488,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
......@@ -509,7 +509,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
......@@ -527,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
......@@ -542,7 +542,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
......@@ -574,7 +574,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
......@@ -596,20 +596,20 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"def copy_from_particle(source, destination):\n",
" # push destination's data points closer to source's data points.\n",
" targetA = random.randrange(0, len(Data4)) # source's city to target.\n",
" targetA = random.randrange(0, CITY_COUNT) # source's city to target.\n",
" targetB = 0\n",
" indexA = 0\n",
" indexB = 0\n",
" tempIndex = 0\n",
" \n",
" # targetB will be source's neighbor immediately succeeding targetA (circular).\n",
" for i in range(len(Data4)):\n",
" for i in range(CITY_COUNT):\n",
" if particles[source].get_data(i) == targetA:\n",
" if i == CITY_COUNT - 1:\n",
" targetB = particles[source].get_data(0) # if end of array, take from beginning.\n",
......@@ -640,7 +640,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
......@@ -666,7 +666,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
......@@ -700,7 +700,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
......@@ -718,25 +718,25 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 35,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Route: 6, 2, 1, 0, 3, 5, 4, Distance: 336.3\n",
"Route: 6, 2, 5, 1, 0, 4, 3, Distance: 248.10000000000002\n",
"Route: 3, 0, 1, 4, 5, 6, 2, Distance: 336.4\n",
"Route: 4, 3, 0, 6, 5, 1, 2, Distance: 336.4\n",
"Route: 6, 0, 4, 3, 2, 1, 5, Distance: 336.5\n",
"Changes for particle 1: 0\n",
"Changes for particle 2: 0\n",
"Changes for particle 3: 0\n",
"Changes for particle 4: 0\n",
"Route: 3, 5, 2, 0, 4, 1, 6, Distance: 152.20000000000002\n",
"Route: 6, 2, 4, 3, 5, 0, 1, Distance: 241.40000000000003\n",
"Route: 2, 1, 6, 3, 0, 4, 5, Distance: 157.20000000000002\n",
"Route: 0, 4, 5, 2, 3, 1, 6, Distance: 157.20000000000002\n",
"Route: 5, 4, 0, 2, 3, 1, 6, Distance: 161.4\n",
"Changes for particle 1: 1\n",
"Changes for particle 2: 1\n",
"Changes for particle 3: 1\n",
"Changes for particle 4: 1\n",
"epoch number: 0\n",
"Target reached.\n",
"Best Route: 5, 2, 0, 4, 1, 6, 3, Distance: 152.2\n"
"Best Route: 3, 5, 2, 0, 4, 1, 6, Distance: 152.20000000000002\n"
]
}
],
......@@ -749,16 +749,16 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[5, 2, 0, 4, 1, 6, 3]"
"[3, 5, 2, 0, 4, 1, 6]"
]
},
"execution_count": 22,
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
......@@ -777,7 +777,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
......@@ -793,20 +793,20 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Taman Eden 100 Tobasa\n",
"Bukit Pahoda\n",
"Pakkodian\n",
"Pantai BUL BUL\n",
"Water Park Tambunan\n",
"BUKIT travel Gibeon\n",
"Bukit Senyum\n",
"Taman Eden 100 Tobasa\n"
"Bukit Senyum\n"
]
}
],
......
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