Commit 817009a2 authored by Bryson Howell's avatar Bryson Howell

working on getting distinct trajectories

parent 997026ba
...@@ -10,4 +10,4 @@ datachop_hiker.mat ...@@ -10,4 +10,4 @@ datachop_hiker.mat
BW_LFandInac_Zelev.mat BW_LFandInac_Zelev.mat
e_x_y_data.pkl e_x_y_data.pkl
.pytest_cache .pytest_cache
z__test__ z__test__*.pyc
\ No newline at end of file
...@@ -103,6 +103,7 @@ class RobotGP(torch.nn.Module): ...@@ -103,6 +103,7 @@ class RobotGP(torch.nn.Module):
y = torch.as_tensor(self.mc_handle.terrain.y, dtype=torch.float64).view(-1, 1) y = torch.as_tensor(self.mc_handle.terrain.y, dtype=torch.float64).view(-1, 1)
z = 1 + torch.as_tensor(self.mc_handle.terrain.h, dtype=torch.float64).reshape(-1,1) z = 1 + torch.as_tensor(self.mc_handle.terrain.h, dtype=torch.float64).reshape(-1,1)
self.Xstar = torch.cat([x, y, z], 1).cuda() # [nTest, 3] self.Xstar = torch.cat([x, y, z], 1).cuda() # [nTest, 3]
self.min_Xstar = self.Xstar
self.num_test = self.Xstar.shape[0] self.num_test = self.Xstar.shape[0]
# print('Initializing Xstar took {} secs.'.format(time.time() - stime)) # print('Initializing Xstar took {} secs.'.format(time.time() - stime))
......
...@@ -228,10 +228,19 @@ class MonteCarlo(params.Default): ...@@ -228,10 +228,19 @@ class MonteCarlo(params.Default):
self.p[dist_mat <= self.params['ring_mobi'][3]] += 0.20 # containment ring self.p[dist_mat <= self.params['ring_mobi'][3]] += 0.20 # containment ring
# print(self.p) # print(self.p)
self.p = ndimage.gaussian_filter(self.p, sigma=8) # to make betta heatmap self.p = ndimage.gaussian_filter(self.p, sigma=8) # to make betta heatmap
elif self.params['lp_model'] == 'trust': #test for trust
self.p = np.zeros((self._x_shape, self._y_shape), dtype=float)
for r in range(0, self._x_shape):
for c in range(0, self._y_shape):
self.p[r,c] = np.float(r+c) / np.float(self._x_shape+self._y_shape)
else: else:
self.p = np.zeros((self._x_shape, self._y_shape), dtype=float) self.p = np.zeros((self._x_shape, self._y_shape), dtype=float)
#Show LP Heatmap
plt.imshow(self.p)
plt.title('Selected heatmap')
plt.show()
# generate lp from real model for comparison # generate lp from real model for comparison
fn = self.params['lp_filename'] fn = self.params['lp_filename']
self.comp_map, trash = load_heatmap(filename=fn, map_size=[self._x_shape, self._y_shape], self.comp_map, trash = load_heatmap(filename=fn, map_size=[self._x_shape, self._y_shape],
......
...@@ -336,6 +336,7 @@ class Searcher(params.Default): ...@@ -336,6 +336,7 @@ class Searcher(params.Default):
@staticmethod @staticmethod
def go_forth( params={} ): def go_forth( params={} ):
print("Searchers going forth")
if(params): if(params):
Searcher.params = params Searcher.params = params
...@@ -354,7 +355,10 @@ class Searcher(params.Default): ...@@ -354,7 +355,10 @@ class Searcher(params.Default):
dt = params.get('dt', 1) dt = params.get('dt', 1)
Searcher.x_sweep_width = ( (_xrange) / (2*num_searchers) ) * 1.2 # whats the deal with these constants? if(num_searchers == 0):
Searcher.x_sweep_width = ( (_xrange) / (2) ) * 1.2
else:
Searcher.x_sweep_width = ( (_xrange) / (2*num_searchers) ) * 1.2 # whats the deal with these constants?
Searcher.y_sweep_lambda = float(dt) * (_yrange) * 6.7e-2 Searcher.y_sweep_lambda = float(dt) * (_yrange) * 6.7e-2
''' '''
...@@ -365,7 +369,10 @@ class Searcher(params.Default): ...@@ -365,7 +369,10 @@ class Searcher(params.Default):
- grouped search method - grouped search method
''' '''
sweep_num = params['sweep_num'] # number of lengths of area to perform (for 'grouped' case) sweep_num = params['sweep_num'] # number of lengths of area to perform (for 'grouped' case)
s_x = _xrange/(sweep_num*2*num_searchers) # adjusted sweep length (2*s per searcher) if(num_searchers == 0):
s_x = _xrange/(sweep_num*2)
else:
s_x = _xrange/(sweep_num*2*num_searchers) # adjusted sweep length (2*s per searcher)
sw = 2*num_searchers*s_x sw = 2*num_searchers*s_x
s_y = np.int(_yrange/20) # y axis bound need not be calculated s_y = np.int(_yrange/20) # y axis bound need not be calculated
......
...@@ -125,6 +125,10 @@ def main(iteration = 0, parameters = -1): ...@@ -125,6 +125,10 @@ def main(iteration = 0, parameters = -1):
mc = MC.MonteCarlo(params=params) # calls terrain builder mc = MC.MonteCarlo(params=params) # calls terrain builder
mc.run_experiment() mc.run_experiment()
#Show terrain for fun (want to see heatmap too)
#mc.terrain.plot()
#plt.show()
planner = planning.Planning(params, on_terrain=mc.terrain, mode='TOTALDIST') # also calls terrain builder... planner = planning.Planning(params, on_terrain=mc.terrain, mode='TOTALDIST') # also calls terrain builder...
rgp = robotgp.RobotGP(mc, planner, _stime = stime, parameters = params) rgp = robotgp.RobotGP(mc, planner, _stime = stime, parameters = params)
rgp.collect_trainData() # sets out paths for each robot rgp.collect_trainData() # sets out paths for each robot
...@@ -179,22 +183,24 @@ if __name__ == "__main__": ...@@ -179,22 +183,24 @@ if __name__ == "__main__":
# KENTLAND case # KENTLAND case
if True: if True:
n_max = 4 #Number of robots n_max = 3 #Number of robots
s_max = 0 #Number of human searchers s_max = 1 #Number of searchers (humans)???
h_max = 0 #Number of humans
#global_fail_max = 1000 #global_fail_max = 1000
global_fail_max = 5 global_fail_max = 5
global_fails = 0 global_fails = 0
avg_runs = 5 avg_runs = 1
start_time = time.time() start_time = time.time()
params = ({ params = ({
'lp_model': 'custom', 'lp_model': 'trust',
'opt_iterations': 2, 'opt_iterations': 2,
'path_style': 'basic', 'path_style': 'basic',
'stats_name': 'kentland', 'stats_name': 'kentland',
'anchor_point': [37.197730, -80.585233], # kentland 'anchor_point': [37.197730, -80.585233], # kentland
'num_searchers': s_max, 'num_searchers': s_max,
'num_robots': n_max, 'num_robots': n_max,
'num_humans' : h_max,
'lp_filename': kentland_heatmap, 'lp_filename': kentland_heatmap,
'lin_feat_filename': kentland_linfeat 'lin_feat_filename': kentland_linfeat
}) })
......
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