@@ -111,12 +111,13 @@ def do_run_work(body) -> dict:
111111
112112def __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
0 commit comments