Skip to content

Commit

Permalink
#59 added verbose argument so that verbose validation is possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jkriwet committed Apr 15, 2024
1 parent 8608bce commit 3f2f16c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions aixcalibuha/calibration/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _check_for_termination(self):
)


def obj(self, xk, *args):
def obj(self, xk, *args, verbose: bool = False):
"""
Default objective function.
The usual function will be implemented here:
Expand All @@ -214,9 +214,15 @@ def obj(self, xk, *args):
Array with normalized values for the minimizer
:param int work_id:
id for worker in Multiprocessing
:param bool verbose:
If True, returns the objective value and the unweighted objective dict (for validation).
If False, returns only the objective value (for optimization).
:return:
Objective value based on the used quality measurement
:rtype: float
If verbose == False (default)
Objective value based on the used quality measurement
If verbose == True
Objective value and unweighted objective dict as a tuple
:rtype: float or tuple
"""
# Info: This function is called by the optimization framework (scipy, dlib, etc.)
# Initialize class objects
Expand Down Expand Up @@ -270,6 +276,9 @@ def obj(self, xk, *args):
)
self._check_for_termination()

if verbose:
return total_res, unweighted_objective

return total_res

def mp_obj(self, x, *args):
Expand Down Expand Up @@ -544,7 +553,7 @@ def validate(self, validation_class: CalibrationClass, calibration_result: Dict,
# Scale the tuner parameters
xk = self.tuner_paras.scale(tuner_values)
# Evaluate objective
obj, unweighted_objective = self.obj(xk=xk)
obj, unweighted_objective = self.obj(xk=xk, verbose=True)
self.logger.validation_callback_func(
obj=obj
)
Expand Down

0 comments on commit 3f2f16c

Please sign in to comment.