Skip to content

Commit

Permalink
added mixed acqf support (#9)
Browse files Browse the repository at this point in the history
* added mixed acqf support

* added option for db name
  • Loading branch information
aquaorifice authored Feb 13, 2024
1 parent 0f211c7 commit 46d00ce
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 186 deletions.
38 changes: 24 additions & 14 deletions endure.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ disable_tqdm = false
# Generic IO settings for experiments, saving data, etc
# =============================================================================
[io]
data_dir = "/data"
data_dir = "data"

# =============================================================================
# HEADER JOB
Expand Down Expand Up @@ -153,9 +153,18 @@ drop_last = true
[job.BayesianOptimization]
# -----------------------------------------------------------------------------
num_iterations = 15
num_restarts = 20
raw_samples = 100
initial_samples = 50
num_restarts = 200
raw_samples = 512
initial_samples = 30
max_levels = 16
# This will take value 0 and 1 where 1 means write each cost and run details into the MySqlLite database
# and 0 means run details are not stored in the database
write_to_db = 1
#by default the databases directory will be created inside the data director. To change this, you need to change ["io"]["data_dir"]
db_path = "databases"
# This must be a .db file for code to function. It will create a sqllite database
db_name = "db_cost.db"


# This is the q value used in BoTorch Acquisition functions.
# if it is set to a value above 1 sequential processing will stop in acquisition function and batch processing will start
Expand All @@ -166,23 +175,24 @@ batch_size = 1
# Acquisition function options
# [ExpectedImprovement, UpperConfidenceBound, qExpectedImprovement]
acquisition_function = "ExpectedImprovement"
beta_value = 0.3

[job.BayesianOptimization.system]
E = 8192
s = 4e-7
B = 4
N = 1000000000
H = 10.0
E = 1024
s = 1.905581e-8
B = 64.0
N = 522365629
H = 5.705814
phi = 1.0

[job.BayesianOptimization.workload]
z0 = 0.25
z1 = 0.25
q = 0.25
w = 0.25
z0 = 0.063
z1 = 0.190
q = 0.545
w = 0.202

[job.BayesianOptimization.bounds]
h_min = 0.0
h_min = 1.0
h_max = 10.0
T_min = 2.0
T_max = 31.0
Expand Down
59 changes: 59 additions & 0 deletions endure/util/db_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import sqlite3
from endure.data.io import Reader


def initialize_database(db_path='cost_log.db'):
connector = sqlite3.connect(db_path)
cursor = connector.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS runs (
run_id INTEGER PRIMARY KEY AUTOINCREMENT,
empty_reads REAL,
non_empty_reads REAL,
range_queries REAL,
writes REAL,
max_bits_per_element REAL,
physical_entries_per_page INT,
range_selectivity REAL,
entries_per_page INT,
total_elements INT,
read_write_asymmetry REAL
);''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS design_costs (
idx INTEGER PRIMARY KEY AUTOINCREMENT,
run_id INTEGER,
bits_per_element REAL,
size_ratio INTEGER,
policy INTEGER,
cost REAL,
FOREIGN KEY (run_id) REFERENCES runs(run_id)
);''')
connector.commit()
return connector


def log_new_run(connector, system, workload):
cursor = connector.cursor()
cursor.execute('INSERT INTO runs (empty_reads, non_empty_reads, range_queries, writes, '
'max_bits_per_element, physical_entries_per_page, range_selectivity, '
'entries_per_page, total_elements, read_write_asymmetry) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
(workload.z0, workload.z1, workload.q, workload.w, system.H, system.E, system.s, system.B, system.N, system.phi))
connector.commit()
return cursor.lastrowid


def log_design_cost(connector, run_id, design, cost):
cursor = connector.cursor()

policy_value = design.policy.value if hasattr(design.policy, 'value') else design.policy
cursor.execute('INSERT INTO design_costs (run_id, bits_per_element, size_ratio, policy, cost) '
'VALUES (?, ?, ?, ?, ?)',(run_id, design.h, design.T, policy_value, cost))
connector.commit()


if __name__ == "__main__":
config = Reader.read_config("endure.toml")
conn = initialize_database()
conn.close()
Loading

0 comments on commit 46d00ce

Please sign in to comment.