From 26a64db6d67e91fb00caccd446faff71cbe88fcb Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 7 Jun 2023 17:10:57 +0200 Subject: [PATCH] debugging --- .../BayesianOptimization/BayesianOptimization.py | 5 +++++ src/active_bo_ros/active_bo_ros/active_rl_topic.py | 1 + src/active_bo_ros/active_bo_ros/interactive_bo.py | 9 ++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/active_bo_ros/active_bo_ros/BayesianOptimization/BayesianOptimization.py b/src/active_bo_ros/active_bo_ros/BayesianOptimization/BayesianOptimization.py index 9880e0c..93a78c7 100644 --- a/src/active_bo_ros/active_bo_ros/BayesianOptimization/BayesianOptimization.py +++ b/src/active_bo_ros/active_bo_ros/BayesianOptimization/BayesianOptimization.py @@ -7,6 +7,11 @@ from active_bo_ros.AcquisitionFunctions.ExpectedImprovement import ExpectedImpro from active_bo_ros.AcquisitionFunctions.ProbabilityOfImprovement import ProbabilityOfImprovement from active_bo_ros.AcquisitionFunctions.ConfidenceBound import ConfidenceBound +from sklearn.exceptions import ConvergenceWarning +import warnings + +warnings.filterwarnings('ignore', category=ConvergenceWarning) + class BayesianOptimization: def __init__(self, env, nr_steps, nr_init=3, acq='ei', nr_weights=6, policy_seed=None): diff --git a/src/active_bo_ros/active_bo_ros/active_rl_topic.py b/src/active_bo_ros/active_bo_ros/active_rl_topic.py index 090cb10..41df5b4 100644 --- a/src/active_bo_ros/active_bo_ros/active_rl_topic.py +++ b/src/active_bo_ros/active_bo_ros/active_rl_topic.py @@ -208,6 +208,7 @@ class ActiveRLService(Node): self.best_pol_shown = False self.eval_response_received = False self.rl_pending = False + elif self.interactive_run == 1: if not self.policy_sent: self.rl_step = 0 diff --git a/src/active_bo_ros/active_bo_ros/interactive_bo.py b/src/active_bo_ros/active_bo_ros/interactive_bo.py index 993c72d..4255f99 100644 --- a/src/active_bo_ros/active_bo_ros/interactive_bo.py +++ b/src/active_bo_ros/active_bo_ros/interactive_bo.py @@ -129,7 +129,7 @@ class ActiveBOTopic(Node): self.seed_array = np.zeros((1, self.bo_runs)) # initialize - self.reward = np.zeros((self.bo_episodes, self.bo_runs)) + self.reward = np.zeros((self.bo_episodes+self.nr_init, self.bo_runs)) self.best_pol_reward = np.zeros((1, self.bo_runs)) self.best_policy = np.zeros((self.bo_steps, self.bo_runs)) self.best_weights = np.zeros((self.bo_nr_weights, self.bo_runs)) @@ -194,6 +194,7 @@ class ActiveBOTopic(Node): # self.BO.initialize() self.init_pending = True self.get_logger().info('BO Initialization is starting!') + self.get_logger().info(f'{self.rl_pending}') if self.init_pending and not self.rl_pending: @@ -275,6 +276,7 @@ class ActiveBOTopic(Node): active_rl_request.policy = self.best_policy[:, best_policy_idx].tolist() active_rl_request.weights = self.best_weights[:, best_policy_idx].tolist() active_rl_request.interactive_run = 1 + active_rl_request.display_run = True self.active_rl_pub.publish(active_rl_request) @@ -365,13 +367,14 @@ class ActiveBOTopic(Node): self.reward[:, self.current_run] = self.BO.best_reward.T - self.BO = None + if self.current_run < self.bo_runs - 1: + self.BO = None self.current_episode = 0 if self.bo_fixed_seed: self.seed_array[0, self.current_run] = self.seed self.seed = int(np.random.randint(1, 2147483647, 1)[0]) - self.get_logger().info(f'{self.seed}') + # self.get_logger().info(f'{self.seed}') self.current_run += 1 self.get_logger().info(f'Current Run: {self.current_run}')