From 30c48b238012dd5ad849f18bc3762c09aa0e8911 Mon Sep 17 00:00:00 2001 From: anweshasaha Date: Mon, 26 Feb 2024 17:10:19 -0500 Subject: [PATCH] fixed minor issues str to enum conv --- jobs/bayesian_pipeline.py | 10 ++++------ jobs/bo_job_runs.py | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/jobs/bayesian_pipeline.py b/jobs/bayesian_pipeline.py index dab3a9f..e47d8e0 100644 --- a/jobs/bayesian_pipeline.py +++ b/jobs/bayesian_pipeline.py @@ -103,14 +103,14 @@ def generate_initial_bounds(self, system: System) -> torch.Tensor: t_bounds = torch.tensor([int(self.bayesian_setting["bounds"]["T_min"]), int(self.bayesian_setting["bounds"]["T_max"])]) policy_bounds = torch.tensor([0, 1]) - if self.model_type == "QHybrid": + if self.model_type == Policy.QFixed: q_bounds = torch.tensor([1, self.bayesian_setting["bounds"]["T_max"] - 1]) bounds = torch.stack([h_bounds, t_bounds, q_bounds], dim=-1) - elif self.model_type == "YZHybrid": + elif self.model_type == Policy.YZHybrid: y_bounds = torch.tensor([1, self.bayesian_setting["bounds"]["T_max"] - 1]) z_bounds = torch.tensor([1, self.bayesian_setting["bounds"]["T_max"] - 1]) bounds = torch.stack([h_bounds, t_bounds, y_bounds, z_bounds], dim=-1) - # elif self.model_type == "KHybrid": # TODO add support for KHybrid model + # elif self.model_type == Policy.KHybrid: # TODO add support for KHybrid model else: bounds = torch.stack([h_bounds, t_bounds, policy_bounds], dim=-1) return bounds @@ -184,7 +184,7 @@ def get_next_points(self, x: torch.Tensor, y: torch.Tensor, best_y: float, bound single_model = MixedSingleTaskGP(x, y, cat_dims=[1, 2], input_transform=Normalize(d=x.shape[1], bounds=bounds), outcome_transform=Standardize(m=1)) - elif self.model_type == "YZHybrid": + elif self.model_type == Policy.YZHybrid: single_model = MixedSingleTaskGP(x, y, cat_dims=[1, 2, 3], input_transform=Normalize(d=x.shape[1], bounds=bounds), outcome_transform=Standardize(m=1)) @@ -273,8 +273,6 @@ def _update_best_designs(self, best_designs: List[Tuple[LSMDesign, float]], new_ # TODO: code for KHybrid to be added else: h, size_ratio, policy = x[0], x[1], x[2] - if(policy.item == 0.0): - print ("0 value for policy!") best_designs.append((LSMDesign(h.item(), np.ceil(size_ratio.item()), policy.item()), y.item())) return best_designs diff --git a/jobs/bo_job_runs.py b/jobs/bo_job_runs.py index c7beada..b29ef4d 100644 --- a/jobs/bo_job_runs.py +++ b/jobs/bo_job_runs.py @@ -49,16 +49,16 @@ def compare_designs(n_runs=3, csv_filename='design_comparison.csv'): writer.writerow(['Entries per page(E)', 'Physical Entries per page(B)', 'Selectivity(s)', 'Max bits per element(H)', 'Total elements (N)', 'Empty Reads', 'Non-Empty Reads', 'Range Queries', 'Writes', 'BO Design', 'Analytical Design', 'BO Cost', - 'Analytical Cost', 'Diff(Analytical-Bayesian)', "Elapsed Time"]) + 'Analytical Cost', 'Diff(Analytical-Bayesian)']) for i in range(n_runs): print(f"Iteration {i + 1}/{n_runs} running") system = generator._sample_system() z0, z1, q, w = generator._sample_workload(4) - bo_design, bo_cost, time = bayesian_optimizer.run(system, z0, z1, q, w) + bo_design, bo_cost = bayesian_optimizer.run(system, z0, z1, q, w) analytical_design, analytical_cost = bayesian_optimizer._find_analytical_results(system, z0, z1, q, w) writer.writerow([system.E, system.B, system.s, system.H, system.N, z0, z1, q, w, - bo_design, analytical_design, bo_cost, analytical_cost, analytical_cost - bo_cost, time]) + bo_design, analytical_design, bo_cost, analytical_cost, analytical_cost - bo_cost]) if __name__ == "__main__":