Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-020
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
O.V.B Sewmina
2022-020
Commits
9d12164d
Commit
9d12164d
authored
Oct 09, 2022
by
Binara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_fare fuction refactored
parent
9b730593
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
38 deletions
+28
-38
routeplanner/AL.py
routeplanner/AL.py
+21
-37
routeplanner/helpers.py
routeplanner/helpers.py
+7
-1
No files found.
routeplanner/AL.py
View file @
9d12164d
from
asyncio.windows_events
import
NULL
from
tokenize
import
ContStr
from
turtle
import
distance
from
helpers
import
load_map_test
,
load_map_bus
,
load_map_train
,
route_177
,
route_176
,
route_8717
...
...
@@ -14,6 +15,7 @@ class PathPlanner():
self
.
type
=
type
self
.
range
=
0
self
.
cost
=
0
self
.
allRoutes
=
[
177
,
176
,
8717
]
self
.
closedSet
=
self
.
create_closedSet
()
if
goal
!=
None
and
start
!=
None
else
None
self
.
openSet
=
self
.
create_openSet
()
if
goal
!=
None
and
start
!=
None
else
None
self
.
cameFrom
=
self
.
create_cameFrom
()
if
goal
!=
None
and
start
!=
None
else
None
...
...
@@ -78,7 +80,6 @@ class PathPlanner():
self
.
record_best_path_to
(
current
,
neighbor
)
#self.range += self.dis
print
(
"No Path Found"
)
self
.
path
=
None
return
False
...
...
@@ -218,32 +219,23 @@ class PathPlanner():
for
n
in
self
.
path
[
1
:]:
self
.
range
=
self
.
range
+
distance
(
lastNode
,
n
)
lastNode
=
n
return
self
.
range
def
get_fare
(
self
,
path
):
currentRouteNo
=
self
.
map
.
routeNo
[
self
.
start
]
temp
=
0
for
x
in
path
:
if
self
.
map
.
routeNo
[
x
]
==
currentRouteNo
:
#print('path is(x) =' + str(x)+ ' ,temp =' + str(temp))
temp
+=
1
currentRouteNo
=
self
.
map
.
routeNo
[
x
]
else
:
print
(
"eeeeeeeeeeeeeeeeeeee"
)
self
.
func
(
currentRouteNo
,
temp
)
currentRouteNo
=
self
.
map
.
routeNo
[
x
]
temp
=
0
routeNumbers
=
[]
for
each
in
path
:
routeNumbers
.
append
(
self
.
map
.
routeNo
[
each
])
#routeNumbers
for
n
in
self
.
allRoutes
:
val
=
routeNumbers
.
count
(
n
)
if
val
>=
0
:
self
.
funcc
(
n
,
val
)
print
(
'cost = '
,
self
.
cost
)
#cost = cost + route_177.get(temp)
return
self
.
cost
def
func
(
self
,
no
,
nodes
):
print
(
'fuction'
)
def
funcc
(
self
,
no
,
nodes
):
if
(
no
==
177
):
self
.
cost
=
self
.
cost
+
route_177
.
get
(
nodes
)
elif
(
no
==
176
):
...
...
@@ -254,35 +246,27 @@ class PathPlanner():
pass
# Get route
def
main
(
a
,
start
,
destination
):
if
a
==
3
:
def
main
(
val
,
start
,
destination
):
if
val
==
3
:
map
=
load_map_train
()
elif
a
==
2
:
elif
val
==
2
:
map
=
load_map_bus
()
else
:
map
=
load_map_test
()
planner
=
PathPlanner
(
map
,
start
,
destination
)
print
(
map
.
roads
)
#print(map.roads)
path
=
planner
.
path
print
(
"Genarated path"
)
if
path
==
False
:
print
(
"No path Found"
,
path
)
return
return
False
else
:
print
(
path
)
print
(
'distance ='
,
planner
.
get_traveled_distance
())
print
(
planner
.
get_fare
(
path
))
print
(
'distance = '
,
planner
.
get_traveled_distance
()
/
10
)
fare
=
planner
.
get_fare
(
path
)
print
(
'trip RS.'
,
fare
)
main
(
1
,
0
,
3
)
\ No newline at end of file
main
(
1
,
1
,
18
)
\ No newline at end of file
routeplanner/helpers.py
View file @
9d12164d
...
...
@@ -8,6 +8,8 @@ from plotly.graph_objs import *
route_177
=
{
0
:
0
,
1
:
34
,
2
:
42
,
3
:
54
,
...
...
@@ -26,12 +28,16 @@ route_177 = {
}
route_176
=
{
0
:
0
,
1
:
34
,
2
:
42
,
3
:
54
,
}
route_8717
=
{
0
:
0
,
1
:
20
,
2
:
20
,
3
:
20
,
...
...
@@ -40,7 +46,7 @@ route_8717 = {
}
map_test
=
{
0
:
{
'pos'
:
(
6.911034627182109
,
79.84918916006576
),
'connections'
:
[
1
],
'name'
:
'Kollupitiya'
,
'type'
:
0
,
'routeNo'
:
177
,
'hValue'
:
1
},
0
:
{
'pos'
:
(
6.911034627182109
,
79.84918916006576
),
'connections'
:
[
1
,
16
],
'name'
:
'Kollupitiya'
,
'type'
:
0
,
'routeNo'
:
177
,
'hValue'
:
1
},
1
:
{
'pos'
:
(
6.911751932322411
,
79.86194701315071
),
'connections'
:
[
0
,
2
],
'name'
:
'Viharamahadevi Park'
,
'type'
:
0
,
'routeNo'
:
177
,
'hValue'
:
1
},
2
:
{
'pos'
:
(
6.911385550864001
,
79.87682791026592
),
'connections'
:
[
1
,
3
],
'name'
:
'House Of Fashion'
,
'type'
:
0
,
'routeNo'
:
177
,
'hValue'
:
1
},
3
:
{
'pos'
:
(
6.911031363415147
,
79.88498429384545
),
'connections'
:
[
2
,
4
],
'name'
:
'Castle Street'
,
'type'
:
0
,
'routeNo'
:
177
,
'hValue'
:
1
},
...
...
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