Skip to content

Commit c567e59

Browse files
authored
Merge pull request #74 from BoostV/73-plot-uncertainty-of-individual-experiment-plot
73 plot uncertainty of individual experiment plot
2 parents a79bcbd + e817c6c commit c567e59

3 files changed

Lines changed: 51 additions & 10 deletions

File tree

optimizerapi/optimizer.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ def do_run_work(body) -> dict:
111111

112112
def __handle_run(body) -> dict:
113113
""" "Handle the run request"""
114-
# print("Receive: " + str(body))
115114
data = [(run["xi"], run["yi"]) for run in body["data"]]
116115
cfg = body["optimizerConfig"]
117116
constraints = cfg["constraints"] if "constraints" in cfg else []
118117
extras = body["extras"] if "extras" in body else {}
119-
print("Received extras " + str(extras))
118+
use_actual_measurement_histogram = json.loads(
119+
extras.get("useActualMeasurementHistogram", "true").lower()
120+
)
120121
space = [
121122
(
122123
convert_number_type(x["from"], x["type"]),
@@ -159,6 +160,9 @@ def __handle_run(body) -> dict:
159160
Yi = [elm[0] for elm in Yi]
160161
result = optimizer.tell(Xi, Yi)
161162
if n_objectives == 1:
163+
if use_actual_measurement_histogram:
164+
optimizer.add_modelled_noise()
165+
result = optimizer.get_result()
162166
result = [result]
163167
else:
164168
result = []
@@ -227,7 +231,7 @@ def process_result(result, optimizer, dimensions, cfg, extras, data, space):
227231
# as "None" at the moment.
228232
graph_format = extras.get("graphFormat", "png")
229233
max_quality = int(extras.get("maxQuality", "5"))
230-
graphs_to_return = extras.get("graphs", ['objective', 'convergence', 'pareto'])
234+
graphs_to_return = extras.get("graphs", ["objective", "convergence", "pareto"])
231235

232236
objective_pars = extras.get("objectivePars", "result")
233237

@@ -251,19 +255,21 @@ def process_result(result, optimizer, dimensions, cfg, extras, data, space):
251255
result_details["models"] = [process_model(model, optimizer) for model in result]
252256
if graph_format == "png":
253257
for idx, model in enumerate(result):
254-
if 'single' in graphs_to_return:
258+
if "single" in graphs_to_return:
255259
bb_plots = plot_brownie_bee(model, max_quality=max_quality)
256260
for i, plot in enumerate(bb_plots):
257261
pic_io_bytes = io.BytesIO()
258262
plot.savefig(pic_io_bytes, format="png")
259263
pic_io_bytes.seek(0)
260264
pic_hash = base64.b64encode(pic_io_bytes.read())
261-
plots.append({"id": f"single_{idx}_{i}", "plot": str(pic_hash, "utf-8")})
262-
if 'convergence' in graphs_to_return:
265+
plots.append(
266+
{"id": f"single_{idx}_{i}", "plot": str(pic_hash, "utf-8")}
267+
)
268+
if "convergence" in graphs_to_return:
263269
plot_convergence(model)
264270
add_plot(plots, f"convergence_{idx}")
265271

266-
if 'objective' in graphs_to_return:
272+
if "objective" in graphs_to_return:
267273
plot_objective(
268274
model,
269275
dimensions=dimensions,
@@ -279,7 +285,7 @@ def process_result(result, optimizer, dimensions, cfg, extras, data, space):
279285
round_to_length_scales(minimum[0], optimizer.space),
280286
minimum[1],
281287
]
282-
elif 'pareto' in graphs_to_return:
288+
elif "pareto" in graphs_to_return:
283289
plot_Pareto(optimizer)
284290
add_plot(plots, "pareto")
285291

requirements-freeze.txt

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1+
a2wsgi==1.7.0
2+
anyio==3.6.2
3+
asgiref==3.6.0
14
async-timeout==4.0.2
25
attrs==23.1.0
6+
black==23.3.0
37
bokeh==2.4.3
48
certifi==2022.12.7
59
cffi==1.15.1
610
charset-normalizer==3.1.0
711
click==8.1.3
812
clickclick==20.10.2
13+
colorama==0.4.6
914
connexion==2.14.2
1015
cryptography==3.4.7
1116
cycler==0.11.0
1217
deap==1.3.3
1318
deprecation==2.1.0
19+
docopt==0.6.2
1420
ecdsa==0.18.0
21+
flake8==6.1.0
1522
Flask==2.2.3
1623
Flask-Cors==3.0.10
1724
fonttools==4.39.3
25+
h11==0.14.0
26+
httpcore==0.16.3
27+
httptools==0.5.0
28+
httpx==0.23.3
1829
idna==3.4
1930
importlib-metadata==6.4.1
2031
inflection==0.5.1
32+
iniconfig==2.0.0
2133
itsdangerous==2.1.2
2234
Jinja2==3.1.2
2335
joblib==1.2.0
@@ -26,31 +38,54 @@ jsonschema==4.15.0
2638
kiwisolver==1.4.4
2739
MarkupSafe==2.1.2
2840
matplotlib==3.5.3
41+
mccabe==0.7.0
42+
mypy-extensions==1.0.0
2943
numpy==1.23.3
3044
packaging==23.1
45+
pathspec==0.11.1
3146
Pillow==9.5.0
32-
ProcessOptimizer[browniebee]==0.8.0
47+
platformdirs==3.5.0
48+
pluggy==0.13.1
49+
ProcessOptimizer[browniebee]==0.8.1
50+
py==1.11.0
51+
py-swagger-ui==1.1.0
3352
pyasn1==0.4.8
53+
pycodestyle==2.11.0
3454
pycparser==2.21
55+
pyflakes==3.1.0
3556
pyparsing==3.0.9
3657
pyrsistent==0.19.3
58+
pytest==6.2.2
59+
pytest-watch==4.2.0
3760
python-dateutil==2.8.2
61+
python-dotenv==1.0.0
3862
python-jose==3.3.0
3963
python-keycloak==2.13.2
64+
python-multipart==0.0.6
4065
PyYAML==6.0
4166
redis==4.5.4
4267
requests==2.28.2
4368
requests-toolbelt==0.10.1
69+
rfc3986==1.5.0
4470
rq==1.10.0
4571
rsa==4.9
4672
scikit-learn==1.1.2
4773
scipy==1.9.1
4874
six==1.16.0
75+
sniffio==1.3.0
76+
starlette==0.25.0
4977
swagger-ui-bundle==0.0.9
5078
threadpoolctl==3.1.0
79+
toml==0.10.2
80+
tomli==2.0.1
5181
tornado==6.2
5282
typing_extensions==4.5.0
5383
urllib3==1.26.15
84+
uvicorn==0.17.6
85+
uvloop==0.17.0
5486
waitress==2.1.2
87+
watchdog==3.0.0
88+
watchgod==0.8.2
89+
websockets==11.0.2
5590
Werkzeug==2.2.3
5691
zipp==3.15.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ connexion[swagger-ui]
33
python-keycloak==2.13.2
44
Flask==2.2.3
55
Flask-Cors==3.0.10
6-
ProcessOptimizer[browniebee]==0.8.0
6+
ProcessOptimizer[browniebee]==0.8.1
77
json-tricks==3.15.5
88
jsonschema==4.15.0
99
cryptography==3.4.7

0 commit comments

Comments
 (0)