UGParameterEstimator.evaluators package
Submodules
UGParameterEstimator.evaluators.clusterEvaluator module
- class UGParameterEstimator.evaluators.clusterEvaluator.ClusterEvaluator(luafilename, directory, parametermanager: ParameterManager, evaluation_type, parameter_output_adapter: ParameterOutputAdapter, fixedparameters={}, threadcount=10, cliparameters=[], ugsubmitparameters=[])
Bases:
EvaluatorEvaluator for Clusters supporting UGSUBMIT.
Implements the Evaluator AbcstractBaseClass. Calls UGSUBMIT and UGINFO using the subprocess module to schedule tasks and get infos about them.
Implements a handler to catch unexpected program interruption while evaluating (for example, if the user cancels the operation). In this case, all open jobs will be cancelled.
Output of UG4 is redirected into a separate <id>_ug_output.txt file.
- evaluate(evaluationlist, transform=True, tag='')
Evaluates the parameters given in evaluationlist using UG4, and the adapters set in the constructor.
- Parameters
evaluationlist (list of numpy arrays) – parametersets to evaluate
transform (boolean, optional) – wether to transform the parameters with parametermanager set in this object, defaults to true
tag (string) – tag-string attached to all produced evaluations for analysis purposes
- Returns
list of parsed evaluation objects with the type given in the constructor, or ErroredEvaluation
- Return type
list of Evaluation
- property parallelism
Returns the parallelism of the evaluator
- Returns
parallelism of the evaluator
- Return type
int
UGParameterEstimator.evaluators.evaluator module
- class UGParameterEstimator.evaluators.evaluator.Evaluator
Bases:
ABCEvaluator abstract base class
Defines the interface for evaluators. Implements a cache to avoid unnecessary evaluations.
- classmethod ConstructEvaluator(luafile, directory, parametermanager: ParameterManager, evaluation_type: Evaluation, parameter_output_adapter: ParameterOutputAdapter, fixedparameters={}, threadcount=10, cliparameters=[])
Factory method to construct a suitable evaluator.
If UGSUBMIT can be detected on the system, a ClusterEvaluator will be used, if not, a LocalEvaluator.
- Parameters
luafilename (string) – path to the luafile to call for every evaluation
directory (string) – directory to use for exchanging data with UG4
parametermanager (ParameterManager) – ParameterManager to transform the parameters/get parameter information
evaluation_type (type implementing Evaluation) – TYPE the evaluation shoould be parsed as.
parameter_output_adapter (ParameterOutputAdapter) – output adapter to write the parameters
fixedparameters (dictionary<string, string|number>, optional) – optional dictionary of fixed parameters to pass
jobcount (int, optional) – optional maximum number of parallel jobs to submit in UGSUBMIT, defaults to 10
cliparameters (list of strings, optional) – list of command line parameters to append to subprocess call. use separate entries for places that would normally require a space.
- cache = {}
- cached_evaluation_count = 0
- checkCache(parameters)
Checks the internal evaluation cache and returns the stored result, if there is one, or None, if not.
- Parameters
parameters (numpy array) – parameters to check
- Returns
Evaluation, if in cache, or None
- Return type
- abstract evaluate(evaluationlist, transform=True, tag='')
Evaluates the parameters given in evaluationlist using UG4, and the adapters set in the constructor.
- Parameters
evaluationlist (list of numpy arrays) – parametersets to evaluate
transform (boolean, optional) – wether to transform the parameters with parametermanager set in this object, defaults to true
tag (string) – tag-string attached to all produced evaluations for analysis purposes
- Returns
list of parsed evaluation objects with the type given in the constructor, or ErroredEvaluation
- Return type
list of Evaluation
- getStatistics()
returns the internal statistics as a string representation :return: string with statistics information :rtype: string
- handleNewEvaluations(evaluations, tag)
Updates the internal evaluation cache and writes evaluations and new caching statistics to the set result object.
- Parameters
evaluations (list of Evaluation) – evaluations to handle
tag (string) – tag to store the evaluations under in the result object
- abstract property parallelism
Returns the parallelism of the evaluator
- Returns
parallelism of the evaluator
- Return type
int
- reset()
resets the internal cache and statistics
- resultobj = None
- serial_evaluation_count = 0
- setResultObject(res)
Sets the result object to write statistics to.
- Parameters
res (Result) – resultobject to set
- total_evaluation_count = 0
UGParameterEstimator.evaluators.localEvaluator module
- class UGParameterEstimator.evaluators.localEvaluator.LocalEvaluator(luafile, directory, parametermanager: ParameterManager, evaluation_type: Evaluation, parameter_output_adapter: ParameterOutputAdapter, fixedparameters={}, threadcount=10, cliparameters=[])
Bases:
EvaluatorEvaluator for usage on PCs without UGSUBMIT.
Implements the Evaluator AbcstractBaseClass. Can use MPI for local speedup, if threadcount > 1 is passed. Output of UG4 is redirected into a separate <id>_ug_output.txt file.
- evaluate(evaluationlist, transform=True, tag='')
Evaluates the parameters given in evaluationlist using UG4, and the adapters set in the constructor.
- Parameters
evaluationlist (list of numpy arrays) – parametersets to evaluate
transform (boolean, optional) – wether to transform the parameters with parametermanager set in this object, defaults to true
tag (string) – tag-string attached to all produced evaluations for analysis purposes
- Returns
list of parsed evaluation objects with the type given in the constructor, or ErroredEvaluation
- Return type
list of Evaluation
- property parallelism
Returns the parallelism of the evaluator. here it is one, as only one evaluation is handled in parallel.
- Returns
parallelism of the evaluator
- Return type
int