From cf73b62fc8362d11cd61b29f352f294029d50158 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Mon, 5 Dec 2022 14:38:12 -0500 Subject: [PATCH 01/40] Update local_gym.py --- explorationlib/local_gym.py | 110 ++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 90f11a9..9b599f0 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -1500,3 +1500,113 @@ def gamma_values(targets, shape=1.0, scale=2.0, prng=None): def levy_values(targets, exponent=2.0, prng=None): prng = _init_prng(prng) return np.power(prng.uniform(size=len(targets)), (-1 / exponent)) + +# --- +class ScentGridMovingTargets(Grid): + """Am open-grid, with scent and moving targets""" + def __init__(self, mode="discrete"): + super().__init__(mode=mode) + self.scent = None + self.scent_fn = None + self.obs = 0.0 + + def add_scent(self, + target, + value, + coord, + scent, + detection_radius=1.0, + noise_sigma=0.0, + p_target=1.0): + # Offset coords by target location + # align them in other words + self.scent_x_coord = coord[0] + target[0] + self.scent_y_coord = coord[1] + target[1] + + # Set scent and its params + self.noise_sigma = noise_sigma + self.scent_pdf = scent + self.add_targets([target], [value], + detection_radius=detection_radius, + kd_kwargs=None, + p_target=p_target) + + def scent_fn(state): + x, y = state + i = find_nearest(self.scent_x_coord, x) + j = find_nearest(self.scent_y_coord, y) + + # Add noise? + noise = np.abs(self.np_random.normal(0, self.noise_sigma)) + return self.scent_pdf[i, j] + noise + + self.scent_fn = scent_fn + + def add_scents( + self, + targets, + values, + coord, # assume shared + scents, + detection_radius=1.0, + noise_sigma=0.0, + p_target=1.0): + """Add several scents, and targets""" + self.noise_sigma = noise_sigma + self.scent_pdfs = scents + self.add_targets(targets, + values, + detection_radius=detection_radius, + kd_kwargs=None, + p_target=p_target) + + # Offset coords by target location + # align them in other words + self.scent_x_coords = [] + self.scent_y_coords = [] + for target in self.targets: + self.scent_x_coords.append(coord[0] + target[0]) + self.scent_y_coords.append(coord[1] + target[1]) + + def scent_fn(state): + # Pos + x, y = state + + # Sum scents from all targets @ pos + summed = 0.0 + for ind in range(self.num_targets): + i = find_nearest(self.scent_x_coords[ind], x) + j = find_nearest(self.scent_y_coords[ind], y) + summed += self.scent_pdfs[ind][i, j] + + # Add noise? + noise = np.abs(self.np_random.normal(0, self.noise_sigma)) + return summed + noise + + self.scent_fn = scent_fn + + def step(self, action): + # Move + super().step(action) # sets self.ind, etc + + # Scent + if self.scent_fn is not None: + x, y = int(self.state[0]), int(self.state[1]) + self.obs = self.scent_fn((x, y)) + else: + self.obs = 0.0 + + if + + # ! + self.state_obs = (self.state, self.obs) + return self.last() + + def last(self): + return (self.state_obs, self.reward, self.done, self.info) + + def reset(self): + self.state = np.zeros(2, dtype=int) + self.obs = 0.0 + self.state_obs = (self.state, self.obs) + self.last() From 25c9da4c09667b98d047e96086c41dacb65b2ced Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 14:57:36 -0500 Subject: [PATCH 02/40] Update plot.py --- explorationlib/plot.py | 53 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 448957c..e6d851c 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -495,4 +495,55 @@ def plot_length_hist(exp_data, if label is not None: ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) - return ax \ No newline at end of file + return ax + + + + +def plot_targets2d(env, + figsize=(3, 3), + boundary=(1, 1), + color=color, + alpha=1.0, + label=None, + title=None, + ax=None): + + # No targets no plot + if env.targets is None: + return None + + # Fmt + try: + vec = np.vstack(env.initial_targets) + except AttributeError: + vec = np.vstack(env.targets) + + # Create a fig obj? + if ax is None: + fig = plt.figure(figsize=figsize) + ax = fig.add_subplot(111) + + dx = ["black", "red"] + for i in range(len(env.targets): + dy = env.targets[i - 1] + dz = dx[dy] + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color=dz, + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") + + # Labels, legends, titles? + if title is not None: + ax.set_title(title) + if label is not None: + ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) + + return ax From 7a521994e0fe2cbf492e44c08c5b2ef772e70ffe Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 14:58:41 -0500 Subject: [PATCH 03/40] Update plot.py --- explorationlib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index e6d851c..8ed273a 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -500,7 +500,7 @@ def plot_length_hist(exp_data, -def plot_targets2d(env, +def plot_targets2dX(env, figsize=(3, 3), boundary=(1, 1), color=color, From d61607795c671a9b0a946e27aac5f6f3c80f2f18 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Mon, 5 Dec 2022 15:00:05 -0500 Subject: [PATCH 04/40] Update local_gym.py --- explorationlib/local_gym.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 9b599f0..35c1c9b 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -1595,8 +1595,8 @@ def step(self, action): self.obs = self.scent_fn((x, y)) else: self.obs = 0.0 - - if + + # if statement here # ! self.state_obs = (self.state, self.obs) From fe7dbda98bed7861301f9bce26891231e824e132 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Mon, 5 Dec 2022 15:03:42 -0500 Subject: [PATCH 05/40] Update local_gym.py --- explorationlib/local_gym.py | 217 ++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 110 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 35c1c9b..00d8d81 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -587,6 +587,113 @@ def reset(self): self.state_obs = (self.state, self.obs) self.last() +# --- +class ScentGridMovingTargets(Grid): + """An open-grid, with scent and moving targets""" + def __init__(self, mode="discrete"): + super().__init__(mode=mode) + self.scent = None + self.scent_fn = None + self.obs = 0.0 + + def add_scent(self, + target, + value, + coord, + scent, + detection_radius=1.0, + noise_sigma=0.0, + p_target=1.0): + # Offset coords by target location + # align them in other words + self.scent_x_coord = coord[0] + target[0] + self.scent_y_coord = coord[1] + target[1] + + # Set scent and its params + self.noise_sigma = noise_sigma + self.scent_pdf = scent + self.add_targets([target], [value], + detection_radius=detection_radius, + kd_kwargs=None, + p_target=p_target) + + def scent_fn(state): + x, y = state + i = find_nearest(self.scent_x_coord, x) + j = find_nearest(self.scent_y_coord, y) + + # Add noise? + noise = np.abs(self.np_random.normal(0, self.noise_sigma)) + return self.scent_pdf[i, j] + noise + + self.scent_fn = scent_fn + + def add_scents( + self, + targets, + values, + coord, # assume shared + scents, + detection_radius=1.0, + noise_sigma=0.0, + p_target=1.0): + """Add several scents, and targets""" + self.noise_sigma = noise_sigma + self.scent_pdfs = scents + self.add_targets(targets, + values, + detection_radius=detection_radius, + kd_kwargs=None, + p_target=p_target) + + # Offset coords by target location + # align them in other words + self.scent_x_coords = [] + self.scent_y_coords = [] + for target in self.targets: + self.scent_x_coords.append(coord[0] + target[0]) + self.scent_y_coords.append(coord[1] + target[1]) + + def scent_fn(state): + # Pos + x, y = state + + # Sum scents from all targets @ pos + summed = 0.0 + for ind in range(self.num_targets): + i = find_nearest(self.scent_x_coords[ind], x) + j = find_nearest(self.scent_y_coords[ind], y) + summed += self.scent_pdfs[ind][i, j] + + # Add noise? + noise = np.abs(self.np_random.normal(0, self.noise_sigma)) + return summed + noise + + self.scent_fn = scent_fn + + def step(self, action): + # Move + super().step(action) # sets self.ind, etc + + # Scent + if self.scent_fn is not None: + x, y = int(self.state[0]), int(self.state[1]) + self.obs = self.scent_fn((x, y)) + else: + self.obs = 0.0 + + # ! + self.state_obs = (self.state, self.obs) + return self.last() + + def last(self): + return (self.state_obs, self.reward, self.done, self.info) + + def reset(self): + self.state = np.zeros(2, dtype=int) + self.obs = 0.0 + self.state_obs = (self.state, self.obs) + self.last() # --- # Multi @@ -1500,113 +1607,3 @@ def gamma_values(targets, shape=1.0, scale=2.0, prng=None): def levy_values(targets, exponent=2.0, prng=None): prng = _init_prng(prng) return np.power(prng.uniform(size=len(targets)), (-1 / exponent)) - -# --- -class ScentGridMovingTargets(Grid): - """Am open-grid, with scent and moving targets""" - def __init__(self, mode="discrete"): - super().__init__(mode=mode) - self.scent = None - self.scent_fn = None - self.obs = 0.0 - - def add_scent(self, - target, - value, - coord, - scent, - detection_radius=1.0, - noise_sigma=0.0, - p_target=1.0): - # Offset coords by target location - # align them in other words - self.scent_x_coord = coord[0] + target[0] - self.scent_y_coord = coord[1] + target[1] - - # Set scent and its params - self.noise_sigma = noise_sigma - self.scent_pdf = scent - self.add_targets([target], [value], - detection_radius=detection_radius, - kd_kwargs=None, - p_target=p_target) - - def scent_fn(state): - x, y = state - i = find_nearest(self.scent_x_coord, x) - j = find_nearest(self.scent_y_coord, y) - - # Add noise? - noise = np.abs(self.np_random.normal(0, self.noise_sigma)) - return self.scent_pdf[i, j] + noise - - self.scent_fn = scent_fn - - def add_scents( - self, - targets, - values, - coord, # assume shared - scents, - detection_radius=1.0, - noise_sigma=0.0, - p_target=1.0): - """Add several scents, and targets""" - self.noise_sigma = noise_sigma - self.scent_pdfs = scents - self.add_targets(targets, - values, - detection_radius=detection_radius, - kd_kwargs=None, - p_target=p_target) - - # Offset coords by target location - # align them in other words - self.scent_x_coords = [] - self.scent_y_coords = [] - for target in self.targets: - self.scent_x_coords.append(coord[0] + target[0]) - self.scent_y_coords.append(coord[1] + target[1]) - - def scent_fn(state): - # Pos - x, y = state - - # Sum scents from all targets @ pos - summed = 0.0 - for ind in range(self.num_targets): - i = find_nearest(self.scent_x_coords[ind], x) - j = find_nearest(self.scent_y_coords[ind], y) - summed += self.scent_pdfs[ind][i, j] - - # Add noise? - noise = np.abs(self.np_random.normal(0, self.noise_sigma)) - return summed + noise - - self.scent_fn = scent_fn - - def step(self, action): - # Move - super().step(action) # sets self.ind, etc - - # Scent - if self.scent_fn is not None: - x, y = int(self.state[0]), int(self.state[1]) - self.obs = self.scent_fn((x, y)) - else: - self.obs = 0.0 - - # if statement here - - # ! - self.state_obs = (self.state, self.obs) - return self.last() - - def last(self): - return (self.state_obs, self.reward, self.done, self.info) - - def reset(self): - self.state = np.zeros(2, dtype=int) - self.obs = 0.0 - self.state_obs = (self.state, self.obs) - self.last() From c7cf98973193b429d14927bf060a65f085b48d57 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:16:08 -0500 Subject: [PATCH 06/40] Update plot.py --- explorationlib/plot.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 8ed273a..2003daf 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -24,7 +24,7 @@ def show_gif(name): return display.HTML(f'') -# def render_2d(name, +# def render_(name, # env, # exp_data, # num_experiment=0, @@ -265,13 +265,14 @@ def plot_targets2d(env, alpha=1.0, label=None, title=None, + differ = None ax=None): # No targets no plot if env.targets is None: return None - # Fmt + # Fmt try: vec = np.vstack(env.initial_targets) except AttributeError: @@ -281,19 +282,22 @@ def plot_targets2d(env, if ax is None: fig = plt.figure(figsize=figsize) ax = fig.add_subplot(111) - - # ! - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color=color, - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") + + dx = ["black", "red"] + for i in range(len(env.targets): + dy = env.targets[i - 1] + dz = dx[dy] + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color=dz, + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") # Labels, legends, titles? if title is not None: From 56e5f99e24dcf0d87ac286da84bbdcb0f157bbad Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:20:22 -0500 Subject: [PATCH 07/40] Update plot.py --- explorationlib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 2003daf..a370391 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -265,7 +265,7 @@ def plot_targets2d(env, alpha=1.0, label=None, title=None, - differ = None + differ = None, ax=None): # No targets no plot From af1c5f1cc724cd65bfdafd4a9d01b4a9fdcca058 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:25:44 -0500 Subject: [PATCH 08/40] Update plot.py --- explorationlib/plot.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index a370391..95543b2 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -282,12 +282,29 @@ def plot_targets2d(env, if ax is None: fig = plt.figure(figsize=figsize) ax = fig.add_subplot(111) - - dx = ["black", "red"] - for i in range(len(env.targets): - dy = env.targets[i - 1] - dz = dx[dy] - ax.scatter( + + + if differ == None: + return + else: + dx = ["black", "red"] + for i in range(len(env.targets): + dy = env.targets[i - 1] + dz = dx[dy] + + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color=dz, + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") + + ax.scatter( vec[:, 0], vec[:, 1], env.values, # value is size, literal @@ -298,7 +315,7 @@ def plot_targets2d(env, ax.set_ylim(-boundary[1], boundary[1]) ax.set_xlabel("x") ax.set_ylabel("y") - + # Labels, legends, titles? if title is not None: ax.set_title(title) From 24288206bbdf45a66f87ac12fdf29c80e2811712 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:38:03 -0500 Subject: [PATCH 09/40] Update plot.py --- explorationlib/plot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 95543b2..26d212d 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -261,11 +261,11 @@ def plot_scent_grid(env, def plot_targets2d(env, figsize=(3, 3), boundary=(1, 1), - color="black", + color=None, alpha=1.0, label=None, title=None, - differ = None, + differ=None, ax=None): # No targets no plot @@ -288,7 +288,7 @@ def plot_targets2d(env, return else: dx = ["black", "red"] - for i in range(len(env.targets): + for i in range(len(env.targets)): dy = env.targets[i - 1] dz = dx[dy] From 65babff96987aa309706142a1c1aa772a5c20eb7 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:40:00 -0500 Subject: [PATCH 10/40] Update plot.py --- explorationlib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 26d212d..3a1858f 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -288,7 +288,7 @@ def plot_targets2d(env, return else: dx = ["black", "red"] - for i in range(len(env.targets)): + for i in range(len(env.targets)): ##Change the color hopefully dy = env.targets[i - 1] dz = dx[dy] From ad929bf2fa010776fe0d4ed2861c63fc2c402ab7 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:59:48 -0500 Subject: [PATCH 11/40] Update plot.py --- explorationlib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 3a1858f..2878354 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -31,7 +31,7 @@ def show_gif(name): # figsize=(4, 4), # boundary=(50, 50), # interval=200): -# """Replay an experiment, as a movie. +# """Replay an experiment, as a movie. FUCK # NOTE: can be very slow to run for experiments # with more than a couple thousand steps. From ca86921dac92898fd6264695034031ae7a0ed674 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 18:08:51 -0500 Subject: [PATCH 12/40] Update plot.py --- explorationlib/plot.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 2878354..beb0432 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -285,7 +285,18 @@ def plot_targets2d(env, if differ == None: - return + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color=dz, + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") + else: dx = ["black", "red"] for i in range(len(env.targets)): ##Change the color hopefully @@ -304,17 +315,6 @@ def plot_targets2d(env, ax.set_xlabel("x") ax.set_ylabel("y") - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color=dz, - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") # Labels, legends, titles? if title is not None: From 4ffcc392eee8a7f59d70f49d03c5fadb77ac7d0b Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:42:09 -0500 Subject: [PATCH 13/40] Update plot.py --- explorationlib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index beb0432..4e5af01 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -289,7 +289,7 @@ def plot_targets2d(env, vec[:, 0], vec[:, 1], env.values, # value is size, literal - color=dz, + color="black", label=label, alpha=alpha) ax.set_xlim(-boundary[0], boundary[0]) From a8d6196b8e757983f5a0e41cc7f1dfd24062c828 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:47:44 -0500 Subject: [PATCH 14/40] Update plot.py --- explorationlib/plot.py | 48 ------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index 4e5af01..e763e46 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -520,51 +520,3 @@ def plot_length_hist(exp_data, - -def plot_targets2dX(env, - figsize=(3, 3), - boundary=(1, 1), - color=color, - alpha=1.0, - label=None, - title=None, - ax=None): - - # No targets no plot - if env.targets is None: - return None - - # Fmt - try: - vec = np.vstack(env.initial_targets) - except AttributeError: - vec = np.vstack(env.targets) - - # Create a fig obj? - if ax is None: - fig = plt.figure(figsize=figsize) - ax = fig.add_subplot(111) - - dx = ["black", "red"] - for i in range(len(env.targets): - dy = env.targets[i - 1] - dz = dx[dy] - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color=dz, - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") - - # Labels, legends, titles? - if title is not None: - ax.set_title(title) - if label is not None: - ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) - - return ax From 7764187b36b43ce766e70a1262152fd35e604699 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:21:15 -0500 Subject: [PATCH 15/40] Update local_gym.py --- explorationlib/local_gym.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 00d8d81..c29a082 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -681,6 +681,10 @@ def step(self, action): self.obs = self.scent_fn((x, y)) else: self.obs = 0.0 + + # New FP Code + print(target) + print("hi") # ! self.state_obs = (self.state, self.obs) From bc400d49b9e262e6d4046c30815f3272ea41a714 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:41:27 -0500 Subject: [PATCH 16/40] Update local_gym.py --- explorationlib/local_gym.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index c29a082..1543d7d 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -683,9 +683,18 @@ def step(self, action): self.obs = 0.0 # New FP Code - print(target) - print("hi") - + for target in self.targets: + target[0] += random.randint(-3, 3) + if target[0] > 10: + target[0] = 10 + elif target[0] < -10: + target[0] = -10 + target[1] += random.randint(-3, 3) + if target[1] > 10: + target[1] = 10 + elif target[1] < -10: + target[1] = -10 + # ! self.state_obs = (self.state, self.obs) return self.last() From 020bbab872d82f27574dfbdd7479152038af9836 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:45:10 -0500 Subject: [PATCH 17/40] Update local_gym.py --- explorationlib/local_gym.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 1543d7d..f581ce2 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -686,13 +686,17 @@ def step(self, action): for target in self.targets: target[0] += random.randint(-3, 3) if target[0] > 10: + print("target[0] > 10") target[0] = 10 elif target[0] < -10: + print("target[0] < -10") target[0] = -10 target[1] += random.randint(-3, 3) if target[1] > 10: + print("target[1] > 10") target[1] = 10 elif target[1] < -10: + print("target[1] < -10") target[1] = -10 # ! From 1370c2de96a088d5df3e72b10471b35c56a43c6d Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 00:00:35 -0500 Subject: [PATCH 18/40] Update local_gym.py --- explorationlib/local_gym.py | 1 + 1 file changed, 1 insertion(+) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index f581ce2..51bd46c 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -1,5 +1,6 @@ #! /usr/bin/env python import numpy as np +import random from copy import deepcopy from itertools import cycle From 5932d9cc67f12b7c1ef81353fa81045996112ffc Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 11:58:59 -0500 Subject: [PATCH 19/40] Update local_gym.py --- explorationlib/local_gym.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 51bd46c..7fd6656 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -591,6 +591,7 @@ def reset(self): # --- class ScentGridMovingTargets(Grid): """An open-grid, with scent and moving targets""" + countSteps = 0 def __init__(self, mode="discrete"): super().__init__(mode=mode) self.scent = None @@ -675,6 +676,7 @@ def scent_fn(state): def step(self, action): # Move super().step(action) # sets self.ind, etc + countSteps += 1 # Scent if self.scent_fn is not None: @@ -685,20 +687,18 @@ def step(self, action): # New FP Code for target in self.targets: - target[0] += random.randint(-3, 3) - if target[0] > 10: - print("target[0] > 10") - target[0] = 10 - elif target[0] < -10: - print("target[0] < -10") - target[0] = -10 - target[1] += random.randint(-3, 3) - if target[1] > 10: - print("target[1] > 10") - target[1] = 10 - elif target[1] < -10: - print("target[1] < -10") - target[1] = -10 + if countSteps%50 == 0: + print("countSteps = ", countSteps) + target[0] += random.randint(-3, 3) + if target[0] > 10: + target[0] = 10 + elif target[0] < -10: + target[0] = -10 + target[1] += random.randint(-3, 3) + if target[1] > 10: + target[1] = 10 + elif target[1] < -10: + target[1] = -10 # ! self.state_obs = (self.state, self.obs) From 61d9072f0d62349d591c78aa400f21ba610a9350 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:05:56 -0500 Subject: [PATCH 20/40] Update local_gym.py --- explorationlib/local_gym.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 7fd6656..d58389b 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -18,6 +18,8 @@ import warnings warnings.filterwarnings("ignore") +countSteps = 0 + # ------------------------------------------------------------------------- # Enviroments @@ -591,7 +593,6 @@ def reset(self): # --- class ScentGridMovingTargets(Grid): """An open-grid, with scent and moving targets""" - countSteps = 0 def __init__(self, mode="discrete"): super().__init__(mode=mode) self.scent = None From a6c954f79e6245447eae1672cc153e0cdbb7494f Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:10:37 -0500 Subject: [PATCH 21/40] Update local_gym.py --- explorationlib/local_gym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index d58389b..f75430b 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -677,7 +677,7 @@ def scent_fn(state): def step(self, action): # Move super().step(action) # sets self.ind, etc - countSteps += 1 + global countSteps += 1 # Scent if self.scent_fn is not None: From f4b45abc0ccf1678b0063b4293aeddf385ed1858 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:16:24 -0500 Subject: [PATCH 22/40] Update local_gym.py --- explorationlib/local_gym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index f75430b..8a0d1e7 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -677,7 +677,7 @@ def scent_fn(state): def step(self, action): # Move super().step(action) # sets self.ind, etc - global countSteps += 1 + global countSteps = global countSteps + 1 # Scent if self.scent_fn is not None: From 3a5ebb9d0f0acc7fbdcc2e713377585eb192791f Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:19:47 -0500 Subject: [PATCH 23/40] Update local_gym.py --- explorationlib/local_gym.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 8a0d1e7..2a58015 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -18,7 +18,7 @@ import warnings warnings.filterwarnings("ignore") -countSteps = 0 +#countSteps = 0 # ------------------------------------------------------------------------- # Enviroments @@ -677,7 +677,7 @@ def scent_fn(state): def step(self, action): # Move super().step(action) # sets self.ind, etc - global countSteps = global countSteps + 1 + #global countSteps += 1 # Scent if self.scent_fn is not None: @@ -688,18 +688,18 @@ def step(self, action): # New FP Code for target in self.targets: - if countSteps%50 == 0: - print("countSteps = ", countSteps) - target[0] += random.randint(-3, 3) - if target[0] > 10: - target[0] = 10 - elif target[0] < -10: - target[0] = -10 - target[1] += random.randint(-3, 3) - if target[1] > 10: - target[1] = 10 - elif target[1] < -10: - target[1] = -10 + #if countSteps%50 == 0: + #print("countSteps = ", countSteps) + target[0] += random.randint(-3, 3) + if target[0] > 10: + target[0] = 10 + elif target[0] < -10: + target[0] = -10 + target[1] += random.randint(-3, 3) + if target[1] > 10: + target[1] = 10 + elif target[1] < -10: + target[1] = -10 # ! self.state_obs = (self.state, self.obs) From 4e922d1ee315472f81c515096db3fcbb505009da Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:33:29 -0500 Subject: [PATCH 24/40] Update plot.py --- explorationlib/plot.py | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index e763e46..f09fb2d 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -284,37 +284,19 @@ def plot_targets2d(env, ax = fig.add_subplot(111) - if differ == None: - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color="black", - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") + + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color="black", + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") - else: - dx = ["black", "red"] - for i in range(len(env.targets)): ##Change the color hopefully - dy = env.targets[i - 1] - dz = dx[dy] - - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color=dz, - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") - # Labels, legends, titles? if title is not None: From afe674874dc4a262d7e312bd78201270184f5467 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:35:30 -0500 Subject: [PATCH 25/40] Update plot.py --- explorationlib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index f09fb2d..a5ca171 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -289,7 +289,7 @@ def plot_targets2d(env, vec[:, 0], vec[:, 1], env.values, # value is size, literal - color="black", + color=color, label=label, alpha=alpha) ax.set_xlim(-boundary[0], boundary[0]) From e74e9ba59a88bfe298b3815e8d8eb018f00444f2 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:49:27 -0500 Subject: [PATCH 26/40] Update local_gym.py --- explorationlib/local_gym.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 2a58015..84e7f09 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -555,14 +555,14 @@ def scent_fn(state): # Sum scents from all targets @ pos summed = 0.0 - for ind in range(self.num_targets): - i = find_nearest(self.scent_x_coords[ind], x) - j = find_nearest(self.scent_y_coords[ind], y) - summed += self.scent_pdfs[ind][i, j] + #for ind in range(self.num_targets): + #i = find_nearest(self.scent_x_coords[ind], x) + #j = find_nearest(self.scent_y_coords[ind], y) + #summed += self.scent_pdfs[ind][i, j] # Add noise? - noise = np.abs(self.np_random.normal(0, self.noise_sigma)) - return summed + noise + #noise = np.abs(self.np_random.normal(0, self.noise_sigma)) + #return summed + noise self.scent_fn = scent_fn From 61ebadbd891c051d2383d9bf06e9e2df430ae400 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:51:25 -0500 Subject: [PATCH 27/40] Update plot.py --- explorationlib/plot.py | 59 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index a5ca171..c23b65e 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -257,7 +257,7 @@ def plot_scent_grid(env, return ax - +''' def plot_targets2d(env, figsize=(3, 3), boundary=(1, 1), @@ -305,7 +305,64 @@ def plot_targets2d(env, ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) return ax +''' +def plot_targets2d(env, + figsize=(3, 3), + boundary=(1, 1), + color=None, + alpha=1.0, + label=None, + title=None, + differ=None, + ax=None): + + # No targets no plot + if env.targets is None: + return None + + # Fmt + try: + vec = np.vstack(env.initial_targets) + except AttributeError: + vec = np.vstack(env.targets) + + # Create a fig obj? + if ax is None: + fig = plt.figure(figsize=figsize) + ax = fig.add_subplot(111) + + if differ == None: + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color="black", + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") + else: + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color="red", + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") + + # Labels, legends, titles? + if title is not None: + ax.set_title(title) + if label is not None: + ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) + return ax def plot_position2d(exp_data, boundary=(1, 1), From c975725ca8af55b0060471445efa295f45e33e9f Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:53:40 -0500 Subject: [PATCH 28/40] Update local_gym.py --- explorationlib/local_gym.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 84e7f09..7f4559c 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -657,7 +657,7 @@ def add_scents( self.scent_x_coords.append(coord[0] + target[0]) self.scent_y_coords.append(coord[1] + target[1]) - def scent_fn(state): + '''def scent_fn(state): # Pos x, y = state @@ -672,7 +672,7 @@ def scent_fn(state): noise = np.abs(self.np_random.normal(0, self.noise_sigma)) return summed + noise - self.scent_fn = scent_fn + self.scent_fn = scent_fn''' def step(self, action): # Move From caee9ef90ec30a85be1e7ff45d4de22aa13c65f4 Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:56:23 -0500 Subject: [PATCH 29/40] Update plot.py --- explorationlib/plot.py | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index c23b65e..def4ec0 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -332,29 +332,22 @@ def plot_targets2d(env, ax = fig.add_subplot(111) if differ == None: - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color="black", - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") + color = "black" + else: - ax.scatter( - vec[:, 0], - vec[:, 1], - env.values, # value is size, literal - color="red", - label=label, - alpha=alpha) - ax.set_xlim(-boundary[0], boundary[0]) - ax.set_ylim(-boundary[1], boundary[1]) - ax.set_xlabel("x") - ax.set_ylabel("y") + color = "red" + + ax.scatter( + vec[:, 0], + vec[:, 1], + env.values, # value is size, literal + color=color, + label=label, + alpha=alpha) + ax.set_xlim(-boundary[0], boundary[0]) + ax.set_ylim(-boundary[1], boundary[1]) + ax.set_xlabel("x") + ax.set_ylabel("y") # Labels, legends, titles? if title is not None: From 4cfad29a4fe07cf367d22ee9f9deeca265b962bf Mon Sep 17 00:00:00 2001 From: JaredEu <112651539+JaredEu@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:59:05 -0500 Subject: [PATCH 30/40] Update plot.py --- explorationlib/plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/explorationlib/plot.py b/explorationlib/plot.py index def4ec0..13dc87a 100644 --- a/explorationlib/plot.py +++ b/explorationlib/plot.py @@ -257,7 +257,7 @@ def plot_scent_grid(env, return ax -''' + def plot_targets2d(env, figsize=(3, 3), boundary=(1, 1), @@ -356,7 +356,7 @@ def plot_targets2d(env, ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) return ax - +''' def plot_position2d(exp_data, boundary=(1, 1), figsize=(3, 3), From 0b7f6ef8ff671220985aae812ad452f3dd029f93 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:06:47 -0500 Subject: [PATCH 31/40] Update local_gym.py --- explorationlib/local_gym.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 7f4559c..2a58015 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -555,14 +555,14 @@ def scent_fn(state): # Sum scents from all targets @ pos summed = 0.0 - #for ind in range(self.num_targets): - #i = find_nearest(self.scent_x_coords[ind], x) - #j = find_nearest(self.scent_y_coords[ind], y) - #summed += self.scent_pdfs[ind][i, j] + for ind in range(self.num_targets): + i = find_nearest(self.scent_x_coords[ind], x) + j = find_nearest(self.scent_y_coords[ind], y) + summed += self.scent_pdfs[ind][i, j] # Add noise? - #noise = np.abs(self.np_random.normal(0, self.noise_sigma)) - #return summed + noise + noise = np.abs(self.np_random.normal(0, self.noise_sigma)) + return summed + noise self.scent_fn = scent_fn @@ -657,7 +657,7 @@ def add_scents( self.scent_x_coords.append(coord[0] + target[0]) self.scent_y_coords.append(coord[1] + target[1]) - '''def scent_fn(state): + def scent_fn(state): # Pos x, y = state @@ -672,7 +672,7 @@ def add_scents( noise = np.abs(self.np_random.normal(0, self.noise_sigma)) return summed + noise - self.scent_fn = scent_fn''' + self.scent_fn = scent_fn def step(self, action): # Move From 4518973900a5f9662c0269d55691cff12446c48e Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:32:34 -0500 Subject: [PATCH 32/40] Update local_gym.py --- explorationlib/local_gym.py | 1 + 1 file changed, 1 insertion(+) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 2a58015..8f3fa05 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -666,6 +666,7 @@ def scent_fn(state): for ind in range(self.num_targets): i = find_nearest(self.scent_x_coords[ind], x) j = find_nearest(self.scent_y_coords[ind], y) + print(summed) summed += self.scent_pdfs[ind][i, j] # Add noise? From d0e8d8b391e7ad1f503320cfa58fb754001ded28 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:43:09 -0500 Subject: [PATCH 33/40] Update local_gym.py --- explorationlib/local_gym.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 8f3fa05..dd166f2 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -559,6 +559,7 @@ def scent_fn(state): i = find_nearest(self.scent_x_coords[ind], x) j = find_nearest(self.scent_y_coords[ind], y) summed += self.scent_pdfs[ind][i, j] + print("regular scentgrid = ", self.scent_pdfs[ind][i, j]) # Add noise? noise = np.abs(self.np_random.normal(0, self.noise_sigma)) @@ -666,7 +667,8 @@ def scent_fn(state): for ind in range(self.num_targets): i = find_nearest(self.scent_x_coords[ind], x) j = find_nearest(self.scent_y_coords[ind], y) - print(summed) + print("movinggrid summed = ", summed) + print("movinggrid = ", self.scent_pdfs[ind][i, j]) summed += self.scent_pdfs[ind][i, j] # Add noise? From aea058f54070d213a756de78932c24c4de62a391 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:57:45 -0500 Subject: [PATCH 34/40] Update local_gym.py --- explorationlib/local_gym.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index dd166f2..2a58015 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -559,7 +559,6 @@ def scent_fn(state): i = find_nearest(self.scent_x_coords[ind], x) j = find_nearest(self.scent_y_coords[ind], y) summed += self.scent_pdfs[ind][i, j] - print("regular scentgrid = ", self.scent_pdfs[ind][i, j]) # Add noise? noise = np.abs(self.np_random.normal(0, self.noise_sigma)) @@ -667,8 +666,6 @@ def scent_fn(state): for ind in range(self.num_targets): i = find_nearest(self.scent_x_coords[ind], x) j = find_nearest(self.scent_y_coords[ind], y) - print("movinggrid summed = ", summed) - print("movinggrid = ", self.scent_pdfs[ind][i, j]) summed += self.scent_pdfs[ind][i, j] # Add noise? From 5abd75084e9527ed0aa80ced2c445777d69cb2fb Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Thu, 8 Dec 2022 16:55:51 -0500 Subject: [PATCH 35/40] Update local_gym.py --- explorationlib/local_gym.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 2a58015..69b3e5a 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -687,6 +687,7 @@ def step(self, action): self.obs = 0.0 # New FP Code + newTargets = [] for target in self.targets: #if countSteps%50 == 0: #print("countSteps = ", countSteps) @@ -700,6 +701,8 @@ def step(self, action): target[1] = 10 elif target[1] < -10: target[1] = -10 + newTargets.append(target) + self.add_targets(newTargets, self.values) # ! self.state_obs = (self.state, self.obs) From add24719cb9bbfb282c447f6708dc86ea2ed5509 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:10:42 -0500 Subject: [PATCH 36/40] Update local_gym.py --- explorationlib/local_gym.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 69b3e5a..c6bed1b 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -702,7 +702,25 @@ def step(self, action): elif target[1] < -10: target[1] = -10 newTargets.append(target) - self.add_targets(newTargets, self.values) + #self.add_targets(newTargets, self.values) + values = self.values + targets = newTargets + + scentsX = [] + count = 0 + for _ in range(num_targets): + if values[count] == 1: + newAmp = 1 + newSig = 2 + else: + newAmp = 1.5 + newSig = 1.75 + + coord, scent = create_grid_scent_patches( + target_boundary, p=1.0, amplitude=newAmp, sigma=newSig) + scentsX.append(scent) + count += 1 + self.add_scents(targets, values, coord, scentsX, noise_sigma=noise_sigma) # ! self.state_obs = (self.state, self.obs) From d80d50b2d9b7189f9f2de4778b03705a35d0f8a7 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:13:43 -0500 Subject: [PATCH 37/40] Update local_gym.py --- explorationlib/local_gym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index c6bed1b..1efcb62 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -708,7 +708,7 @@ def step(self, action): scentsX = [] count = 0 - for _ in range(num_targets): + for _ in range(len(targets): if values[count] == 1: newAmp = 1 newSig = 2 From 061f021a96227b15a309e98e9bd7bad9412fa1bb Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:15:29 -0500 Subject: [PATCH 38/40] Update local_gym.py --- explorationlib/local_gym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 1efcb62..63b851c 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -708,7 +708,7 @@ def step(self, action): scentsX = [] count = 0 - for _ in range(len(targets): + for _ in range(len(targets)): if values[count] == 1: newAmp = 1 newSig = 2 From bd113673218131b02226c8acd106a3cbe88269f4 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:23:37 -0500 Subject: [PATCH 39/40] Update local_gym.py --- explorationlib/local_gym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 63b851c..7e4fd2c 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -717,7 +717,7 @@ def step(self, action): newSig = 1.75 coord, scent = create_grid_scent_patches( - target_boundary, p=1.0, amplitude=newAmp, sigma=newSig) + (10, 10), p=1.0, amplitude=newAmp, sigma=newSig) scentsX.append(scent) count += 1 self.add_scents(targets, values, coord, scentsX, noise_sigma=noise_sigma) From 7ee413d21e142cc06c0d7519f4f003948a676e05 Mon Sep 17 00:00:00 2001 From: arshiaua <112977038+arshiaua@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:30:59 -0500 Subject: [PATCH 40/40] Update local_gym.py --- explorationlib/local_gym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorationlib/local_gym.py b/explorationlib/local_gym.py index 7e4fd2c..68034eb 100644 --- a/explorationlib/local_gym.py +++ b/explorationlib/local_gym.py @@ -720,7 +720,7 @@ def step(self, action): (10, 10), p=1.0, amplitude=newAmp, sigma=newSig) scentsX.append(scent) count += 1 - self.add_scents(targets, values, coord, scentsX, noise_sigma=noise_sigma) + self.add_scents(targets, values, coord, scentsX, noise_sigma=self.noise_sigma) # ! self.state_obs = (self.state, self.obs)