Skip to content

Commit cea6b5a

Browse files
committed
Relax assertion tolerance. Improve results tables for multi-objective optimization.
1 parent 9a9d5d7 commit cea6b5a

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎optimize.py‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def run_trial(frequency_MHz, coreVoltage_mV, trial_number):
123123
actual_coreVoltage_mV = stats.get("coreVoltage", 0)
124124

125125
try:
126-
np.testing.assert_allclose(actual_frequency_MHz, frequency_MHz, rtol=1e-3)
127-
np.testing.assert_allclose(actual_coreVoltage_mV, coreVoltage_mV, rtol=1e-3)
126+
np.testing.assert_allclose(actual_frequency_MHz, frequency_MHz, rtol=3 * 1e-3)
127+
np.testing.assert_allclose(actual_coreVoltage_mV, coreVoltage_mV, rtol=3 * 1e-3)
128128
except AssertionError:
129129
console.print_exception()
130130
console.print("[bold red]Real parameter not set within tolerance of 1%[/bold red]")
@@ -221,16 +221,19 @@ def entrypoint():
221221
study.optimize(run_study, n_trials=n_trials)
222222

223223
console.rule("[bold green]Optimization Complete[/bold green]")
224-
final = Table(title="Best Trial Results", show_lines=True)
225-
final.add_column("Parameter", style="cyan")
226-
final.add_column("Value", style="magenta")
227-
for trial in study.best_trials:
228-
for key, val in trial.params.items():
229-
final.add_row(key, str(val))
230-
231-
final.add_row("objectives", f"{trial.values}")
224+
console.print("Best trials per objective from multi-objective optimization:")
232225

233-
console.print(final)
226+
for i, trial in enumerate(study.best_trials, start=1):
227+
table = Table(
228+
title=f"Best Multi-Objective Result {i}/{len(study.best_trials)} - Trial {trial.number} ", show_lines=True
229+
)
230+
table.add_column("Parameter", style="cyan")
231+
table.add_column("Value", style="magenta")
232+
for key, val in trial.params.items():
233+
table.add_row(key, str(val))
234+
table.add_section()
235+
table.add_row("Objectives: hashRate (TH/s), efficiency (J/TH)", f"{trial.values}")
236+
console.print(table)
234237

235238

236239
if __name__ == "__main__":

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=78.1.0"]
33

44
[project]
55
name = "espminer-optim"
6-
version = "0.0.3"
6+
version = "0.0.4"
77
description = "Add your description here"
88
readme = "README.md"
99
requires-python = ">=3.12"
@@ -17,7 +17,7 @@ dependencies = [
1717
]
1818

1919
[project.scripts]
20-
espminer-optim = "optimize:main"
20+
espminer-optim = "optimize:entrypoint"
2121

2222
[tool.ruff]
2323
line-length = 120

‎uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)