Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ags_grabber
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Bryson Howell
ags_grabber
Commits
25b4fb66
Commit
25b4fb66
authored
Aug 18, 2024
by
Bryson Howell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Getting LPM heatmaps to work
parent
c323afcb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
8 deletions
+62
-8
Figure_1.png
Figure_1.png
+0
-0
lpm_hikersim.py
lpm_hikersim.py
+62
-8
test_8_feats.png
test_8_feats.png
+0
-0
No files found.
Figure_1.png
0 → 100644
View file @
25b4fb66
117 KB
lpm_hikersim.py
View file @
25b4fb66
...
@@ -25,7 +25,14 @@ def main(exp_name='test', start_idx=0, n_envs=1, n_iter=10):
...
@@ -25,7 +25,14 @@ def main(exp_name='test', start_idx=0, n_envs=1, n_iter=10):
#Size in meters of GIS datasets
#Size in meters of GIS datasets
test_extent
=
20000
test_extent
=
20000
download_extent
=
40000
download_extent
=
40000
LL
=
[
20000
,
20000
,
1
]
#LPM Parameters
ts
=
850
#walking speed
simT
=
10
#hours
T
=
ts
*
simT
alpha
=
0.55
p_behavior
=
[
0.055
,
0.377
,
0.559
,
0.003
,
0.006
,
0.0
]
#from nature paper
#Pull incident locations
#Pull incident locations
listname
=
'./lp_data/indexed_incidents.csv'
listname
=
'./lp_data/indexed_incidents.csv'
...
@@ -62,6 +69,7 @@ def main(exp_name='test', start_idx=0, n_envs=1, n_iter=10):
...
@@ -62,6 +69,7 @@ def main(exp_name='test', start_idx=0, n_envs=1, n_iter=10):
#Iterate through search incidents
#Iterate through search incidents
for
incident
in
range
(
0
,
len
(
i_area
)):
for
incident
in
range
(
0
,
len
(
i_area
)):
#Get current IPP/Find pair
cur_ipp
=
ipp_latlons
[
i_area
[
incident
]]
cur_ipp
=
ipp_latlons
[
i_area
[
incident
]]
ipp_xy
=
lat_lon2meters
(
cur_ipp
[
0
],
cur_ipp
[
1
])
ipp_xy
=
lat_lon2meters
(
cur_ipp
[
0
],
cur_ipp
[
1
])
find_ll
=
find_latlons
[
i_area
[
incident
]]
find_ll
=
find_latlons
[
i_area
[
incident
]]
...
@@ -86,13 +94,23 @@ def main(exp_name='test', start_idx=0, n_envs=1, n_iter=10):
...
@@ -86,13 +94,23 @@ def main(exp_name='test', start_idx=0, n_envs=1, n_iter=10):
sub_inac
=
inac
[
x_index
-
half_test
:
x_index
+
half_test
,
y_index
-
half_test
:
y_index
+
half_test
,:]
sub_inac
=
inac
[
x_index
-
half_test
:
x_index
+
half_test
,
y_index
-
half_test
:
y_index
+
half_test
,:]
sub_elev
=
elev
[
x_index
-
half_test
:
x_index
+
half_test
,
y_index
-
half_test
:
y_index
+
half_test
]
sub_elev
=
elev
[
x_index
-
half_test
:
x_index
+
half_test
,
y_index
-
half_test
:
y_index
+
half_test
]
map_data
=
lf_format
(
sub_inac
,
sub_lf
,
sub_elev
)
map_data
=
lf_format
(
sub_inac
,
sub_lf
,
sub_elev
)
plot_env
(
map_data
,
ipp_xy
,
find_xy
,
exp_name
,
env
,
incident
)
#run LPM
#run_replicate(ipp, find, map, T, p_behavior, alpha, LL)
else
:
else
:
map_data
=
lf_format
(
inac
,
lf
,
elev
)
map_data
=
lf_format
(
inac
,
lf
,
elev
)
plot_env
(
map_data
,
ipp_xy
,
find_xy
,
exp_name
,
env
,
incident
)
#Run LPM
#run_replicate(ipp, find, map, T, p_behavior, alpha, LL)
#plot_env(map_data,ipp_xy,find_xy,exp_name,env,incident)
start_t
=
time
.
time
()
[
x
,
y
,
behavior
]
=
run_replicate
(
ipp_xy
,
find_xy
,
map_data
,
T
,
p_behavior
,
alpha
,
LL
)
end_t
=
time
.
time
()
end_t
=
end_t
-
start_t
print
(
'Lost Person Simulation finished, it took
%.2
f seconds'
%
end_t
)
behavior
=
behavior
[
0
]
x
=
x
[
0
]
y
=
y
[
0
]
print
(
'IPP = {}'
.
format
(
ipp_xy
))
print
(
'X values = {}'
.
format
(
x
[
0
:
20
]))
print
(
'Y values = {}'
.
format
(
y
[
0
:
20
]))
print
(
'Behaviors = {}'
.
format
(
behavior
[
0
:
20
]))
#Locate find position from IPP
#Locate find position from IPP
#Convert both to meters
#Convert both to meters
...
@@ -184,7 +202,7 @@ def plot_env(map_data, ipp, find, exp_name='test', env=0, incident=0):
...
@@ -184,7 +202,7 @@ def plot_env(map_data, ipp, find, exp_name='test', env=0, incident=0):
#For visualizing all terrain features
#For visualizing all terrain features
t
=
'Area '
+
str
(
env
)
+
' Incident '
+
str
(
incident
)
+
' - Linear Features'
t
=
'Area '
+
str
(
env
)
+
' Incident '
+
str
(
incident
)
+
' - Linear Features'
plt
.
title
(
t
)
plt
.
title
(
t
)
plt
.
imshow
(
lf
)
plt
.
imshow
(
lf
,
cmap
=
'gray'
)
#Show initial position and find point
#Show initial position and find point
plt
.
plot
(
1500
,
1500
,
'g*'
,
label
=
'IPP'
,
ms
=
10
)
plt
.
plot
(
1500
,
1500
,
'g*'
,
label
=
'IPP'
,
ms
=
10
)
plt
.
plot
(
x_index
,
y_index
,
'yX'
,
label
=
'Find Position'
,
ms
=
10
)
plt
.
plot
(
x_index
,
y_index
,
'yX'
,
label
=
'Find Position'
,
ms
=
10
)
...
@@ -205,6 +223,42 @@ def plot_env(map_data, ipp, find, exp_name='test', env=0, incident=0):
...
@@ -205,6 +223,42 @@ def plot_env(map_data, ipp, find, exp_name='test', env=0, incident=0):
return
return
#Fill in later, skeleton for comparing two models
def
comparison_plot
():
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
1
,
2
)
# Scatter plot of path and track in the first subplot
ax1
.
scatter
(
x
=
np
.
array
(
path
)[:,
0
],
y
=
np
.
array
(
path
)[:,
1
],
label
=
'Path'
)
ax1
.
imshow
(
heatmap
)
ax1
.
set_xlim
([
0
,
48
])
ax1
.
set_ylim
([
0
,
48
])
ax1
.
set_xlabel
(
'X'
)
ax1
.
set_ylabel
(
'Y'
)
ax1
.
set_title
(
'Lost Person Model'
)
ax1
.
legend
()
# Scatter plot of path and track in the first subplot
ax2
.
scatter
(
x
=
np
.
array
(
path
)[:,
0
],
y
=
np
.
array
(
path
)[:,
1
],
label
=
'Path'
)
ax2
.
imshow
(
ringmap
)
ax2
.
set_xlim
([
0
,
48
])
ax2
.
set_ylim
([
0
,
48
])
ax2
.
set_xlabel
(
'X'
)
ax2
.
set_ylabel
(
'Y'
)
ax2
.
set_title
(
'Ring Model'
)
ax2
.
legend
()
# Plot of rewards in the second subplot
#ax2.plot(rews)
#ax2.set_xlabel('Step')
#ax2.set_ylabel('Reward')
#x2.set_title('Rewards')
plt
.
tight_layout
()
plt
.
suptitle
(
"LPM Reward Function with Ring Model Constraint (Trust =
%.2
f)"
%
trustval
)
plt
.
show
()
return
#TODO: Delete this, not needed any more
#TODO: Delete this, not needed any more
#Combines Linear and Inacessible features for all map layers
#Combines Linear and Inacessible features for all map layers
def
test_lf_format
(
exp_name
=
'test'
,
force_save
=
'False'
):
def
test_lf_format
(
exp_name
=
'test'
,
force_save
=
'False'
):
...
@@ -258,7 +312,7 @@ def test_lf_format(exp_name='test',force_save='False'):
...
@@ -258,7 +312,7 @@ def test_lf_format(exp_name='test',force_save='False'):
#For visualizing all terrain features
#For visualizing all terrain features
t
=
exp_name
+
' Area '
+
str
(
env
)
+
' - Linear Features'
t
=
exp_name
+
' Area '
+
str
(
env
)
+
' - Linear Features'
plt
.
title
(
t
)
plt
.
title
(
t
)
plt
.
imshow
(
bw_lf
)
plt
.
imshow
(
bw_lf
,
cmap
=
'greys'
)
#Show initial position and find point
#Show initial position and find point
plt
.
plot
(
1500
,
1500
,
'g*'
,
label
=
'IPP'
,
ms
=
10
)
plt
.
plot
(
1500
,
1500
,
'g*'
,
label
=
'IPP'
,
ms
=
10
)
plt
.
plot
(
400
,
600
,
'yX'
,
label
=
'Find Position'
,
ms
=
10
)
plt
.
plot
(
400
,
600
,
'yX'
,
label
=
'Find Position'
,
ms
=
10
)
...
@@ -304,7 +358,7 @@ def test_lf_format(exp_name='test',force_save='False'):
...
@@ -304,7 +358,7 @@ def test_lf_format(exp_name='test',force_save='False'):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
start
=
7
#Environment to start at (0 is first, 8 is first large map)
start
=
7
#Environment to start at (0 is first, 8 is first large map)
n
=
2
#Number of environments to test
n
=
1
#Number of environments to test
mc
=
10
#Monte Carlo iterations
mc
=
10
#Monte Carlo iterations
...
...
test_8_feats.png
0 → 100644
View file @
25b4fb66
115 KB
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