Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added mixed acqf support #9

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions endure.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ 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 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 +167,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
Loading