Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
Code_Sidang_Ulang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ari Whuandaniel Manurung
Code_Sidang_Ulang
Commits
ed6e027b
Commit
ed6e027b
authored
Jul 24, 2020
by
Yolanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating_pso
parent
5c56bae1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
+35
-35
Algo_PSO.ipynb
Algo_PSO.ipynb
+35
-35
No files found.
Algo_PSO.ipynb
View file @
ed6e027b
...
@@ -374,7 +374,7 @@
...
@@ -374,7 +374,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
7
,
"execution_count":
6
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -398,7 +398,7 @@
...
@@ -398,7 +398,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
8
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -412,12 +412,12 @@
...
@@ -412,12 +412,12 @@
"map = [];\n",
"map = [];\n",
"particles = []\n",
"particles = []\n",
"Maximum_distance= Fitness_value.getting_max_distance()\n",
"Maximum_distance= Fitness_value.getting_max_distance()\n",
"CITY_COUNT =
len(Data4)
"
"CITY_COUNT =
7
"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
9
,
"execution_count":
8
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -443,7 +443,7 @@
...
@@ -443,7 +443,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
10
,
"execution_count":
9
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -474,7 +474,7 @@
...
@@ -474,7 +474,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
1
,
"execution_count": 1
0
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -488,7 +488,7 @@
...
@@ -488,7 +488,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
2
,
"execution_count": 1
1
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -509,7 +509,7 @@
...
@@ -509,7 +509,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
3
,
"execution_count": 1
2
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -527,7 +527,7 @@
...
@@ -527,7 +527,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
4
,
"execution_count": 1
3
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -542,7 +542,7 @@
...
@@ -542,7 +542,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
5
,
"execution_count": 1
4
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -574,7 +574,7 @@
...
@@ -574,7 +574,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
6
,
"execution_count": 1
5
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -596,20 +596,20 @@
...
@@ -596,20 +596,20 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
17
,
"execution_count":
31
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"def copy_from_particle(source, destination):\n",
"def copy_from_particle(source, destination):\n",
" # push destination's data points closer to source's data points.\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",
" targetB = 0\n",
" indexA = 0\n",
" indexA = 0\n",
" indexB = 0\n",
" indexB = 0\n",
" tempIndex = 0\n",
" tempIndex = 0\n",
" \n",
" \n",
" # targetB will be source's neighbor immediately succeeding targetA (circular).\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 particles[source].get_data(i) == targetA:\n",
" if i == CITY_COUNT - 1:\n",
" if i == CITY_COUNT - 1:\n",
" targetB = particles[source].get_data(0) # if end of array, take from beginning.\n",
" targetB = particles[source].get_data(0) # if end of array, take from beginning.\n",
...
@@ -640,7 +640,7 @@
...
@@ -640,7 +640,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
18
,
"execution_count":
32
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -666,7 +666,7 @@
...
@@ -666,7 +666,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
19
,
"execution_count":
33
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -700,7 +700,7 @@
...
@@ -700,7 +700,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
20
,
"execution_count":
34
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -718,25 +718,25 @@
...
@@ -718,25 +718,25 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
21
,
"execution_count":
35
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Route:
6, 2, 1, 0, 3, 5, 4, Distance: 336.3
\n",
"Route:
3, 5, 2, 0, 4, 1, 6, Distance: 152.20000000000002
\n",
"Route: 6, 2,
5, 1, 0, 4, 3, Distance: 248.10000000000002
\n",
"Route: 6, 2,
4, 3, 5, 0, 1, Distance: 241.40000000000003
\n",
"Route:
3, 0, 1, 4, 5, 6, 2, Distance: 336.4
\n",
"Route:
2, 1, 6, 3, 0, 4, 5, Distance: 157.20000000000002
\n",
"Route:
4, 3, 0, 6, 5, 1, 2, Distance: 336.4
\n",
"Route:
0, 4, 5, 2, 3, 1, 6, Distance: 157.20000000000002
\n",
"Route:
6, 0, 4, 3, 2, 1, 5, Distance: 336.5
\n",
"Route:
5, 4, 0, 2, 3, 1, 6, Distance: 161.4
\n",
"Changes for particle 1:
0
\n",
"Changes for particle 1:
1
\n",
"Changes for particle 2:
0
\n",
"Changes for particle 2:
1
\n",
"Changes for particle 3:
0
\n",
"Changes for particle 3:
1
\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:
5, 2, 0, 4, 1, 6, 3, Distance: 152.
2\n"
"Best Route:
3, 5, 2, 0, 4, 1, 6, Distance: 152.2000000000000
2\n"
]
]
}
}
],
],
...
@@ -749,16 +749,16 @@
...
@@ -749,16 +749,16 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
22
,
"execution_count":
36
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"[
5, 2, 0, 4, 1, 6, 3
]"
"[
3, 5, 2, 0, 4, 1, 6
]"
]
]
},
},
"execution_count":
22
,
"execution_count":
36
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -777,7 +777,7 @@
...
@@ -777,7 +777,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
23
,
"execution_count":
37
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -793,20 +793,20 @@
...
@@ -793,20 +793,20 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
24
,
"execution_count":
38
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Taman Eden 100 Tobasa\n",
"Bukit Pahoda\n",
"Bukit Pahoda\n",
"Pakkodian\n",
"Pakkodian\n",
"Pantai BUL BUL\n",
"Pantai BUL BUL\n",
"Water Park Tambunan\n",
"Water Park Tambunan\n",
"BUKIT travel Gibeon\n",
"BUKIT travel Gibeon\n",
"Bukit Senyum\n",
"Bukit Senyum\n"
"Taman Eden 100 Tobasa\n"
]
]
}
}
],
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment