Source code for pypesto.optimize.options

from typing import Dict, Union


[docs]class OptimizeOptions(dict): """ Options for the multistart optimization. Parameters ---------- startpoint_resample: Flag indicating whether initial points are supposed to be resampled if function evaluation fails at the initial point allow_failed_starts: Flag indicating whether we tolerate that exceptions are thrown during the minimization process. report_sres: Flag indicating whether sres will be stored in the results object. Deactivating this option will improve memory consumption for large scale problems. report_hess: Flag indicating whether hess will be stored in the results object. Deactivating this option will improve memory consumption for large scale problems. """
[docs] def __init__(self, startpoint_resample: bool = False, allow_failed_starts: bool = True, report_sres: bool = True, report_hess: bool = True): super().__init__() self.startpoint_resample: bool = startpoint_resample self.allow_failed_starts: bool = allow_failed_starts self.report_sres: bool = report_sres self.report_hess: bool = report_hess
def __getattr__(self, key): try: return self[key] except KeyError: raise AttributeError(key) __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__
[docs] @staticmethod def assert_instance( maybe_options: Union['OptimizeOptions', Dict] ) -> 'OptimizeOptions': """ Return a valid options object. Parameters ---------- maybe_options: OptimizeOptions or dict """ if isinstance(maybe_options, OptimizeOptions): return maybe_options options = OptimizeOptions(**maybe_options) return options