From 5c44281a64238986598ebcc25818e0c06b979221 Mon Sep 17 00:00:00 2001 From: philipposk Date: Fri, 1 Mar 2024 17:23:35 +0100 Subject: [PATCH] made a class that contains the resultss the optimizer returns --- mcstasscript/helper/optimizer_helper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mcstasscript/helper/optimizer_helper.py b/mcstasscript/helper/optimizer_helper.py index 13dbc4c4..bfa1a835 100644 --- a/mcstasscript/helper/optimizer_helper.py +++ b/mcstasscript/helper/optimizer_helper.py @@ -57,6 +57,14 @@ def get_history(self): def starter_fom(data): return -data[0].metadata.total_I +""" +We make a class that will contain all the results that optimizer will return +""" +class Result: + def __init__(self, xopt, fopt, histories): + self.xopt = xopt + self.fopt = fopt + self.histories = histories def optimizer(instrument, param_names, lb, ub, fom=starter_fom, maxiter=25, swarmsize=15, ncount=1E5 ): # # We the user do the following part by, per example: @@ -92,8 +100,8 @@ def optimizer(instrument, param_names, lb, ub, fom=starter_fom, maxiter=25, swar for history_line in histories[0:10]: print(history_line) - print("The user now has the option to depict the correlation between two parameters by using any of the, plot_2d(param_names, histories), plot_3d_scatter(param_names, histories), plot_3d_surface(param_names, histories)") - return xopt,fopt,histories + print("The user now has the option to depict the correlation the parameters by using any of the, plot_2d(param_names, histories), plot_3d_scatter(param_names, histories), plot_3d_surface(param_names, histories)") + return Result(xopt,fopt,histories) # How to give the user xopt