diff --git a/cml/shared/parameter.py b/cml/shared/parameter.py index 8b964e68ee3e6a1430de8663c39d67d28735c47d..076b31a13a0afdfa5fd0ab3b2dfd9a42af9b6b4a 100644 --- a/cml/shared/parameter.py +++ b/cml/shared/parameter.py @@ -2,6 +2,7 @@ # TODO (dmt): Add doc! # TODO (dmt): Provide default values and the correct data type! PROTOCOL_LEVEL = 55 +HIGHEST_TIER = 8 class SetFeatures: @@ -432,43 +433,96 @@ class ReduceModelRedundancy: class DeconstStrategy: def __init__(self): - self.deconst_strategy = "" + self.deconst_strategy = "conservative" def __get__(self, instance, owner): return self.deconst_strategy def __set__(self, instance, value): - self.deconst_strategy = value + if value in ("conservative", "integrative", "oppurtunistic"): + self.deconst_strategy = value + else: + raise ValueError() class DeconstMode: def __init__(self): - self.deconst_mode = "" + self.deconst_mode = "minimal" def __get__(self, instance, owner): return self.deconst_mode def __set__(self, instance, value): - self.deconst_mode = value + if value in ("minimal", "full"): + self.deconst_mode = value + else: + raise ValueError() class DeconstMaxDistanceT: def __init__(self): - self.deconst_max_distance_t = 10 + self.deconst_max_distance_t = 1 def __get__(self, instance, owner): return self.deconst_max_distance_t def __set__(self, instance, value): - self.deconst_max_distance_t = value + if isinstance(value, float): + self.deconst_max_distance_t = value + elif isinstance(value, str): + try: + self.deconst_max_distance_t = float(value) + except TypeError as error: print(error) + + +class DeconstFullTolerance: + def __init__(self): + self.deconst_full_tolerance = 0.1 + + def __get__(self, instance, owner): + return self.deconst_full_tolerance + + def __set__(self, instance, value): + if isinstance(value, float): + self.deconst_full_tolerance = value + elif isinstance(value, str): + try: + self.deconst_full_tolerance = float(value) + except TypeError as error: print(error) class ForceTimeExpansion: def __init__(self): - self.force_time_expansion = 10 + self.force_time_expansion = True def __get__(self, instance, owner): return self.force_time_expansion def __set__(self, instance, value): - self.force_time_expansion = value + if isinstance(value, bool): + self.force_time_expansion = value + elif isinstance(value, str): + if value in ("False", "no"): + self.force_time_expansion = False + elif value in ("True", "yes"): + self.force_time_expansion = True + else: + raise ValueError() + + +class AllowWeakReliability: + def __init__(self): + self.allow_weak_reliability = False + + def __get__(self, instance, owner): + return self.allow_weak_reliability + + def __set__(self, instance, value): + if isinstance(value, bool): + self.allow_weak_reliability = value + elif isinstance(value, str): + if value in ("False", "no"): + self.allow_weak_reliability = False + elif value in ("True", "yes"): + self.allow_weak_reliability = True + else: raise ValueError() diff --git a/cml/shared/settings.py b/cml/shared/settings.py index 44bd371c63c37414e30efb317b72ca64cd402f6c..7d229dbed01082c7c22abbee6d81ddf5b0772bb0 100644 --- a/cml/shared/settings.py +++ b/cml/shared/settings.py @@ -47,7 +47,9 @@ class MetaSettings(type): DECONST_STRATEGY: str = DeconstStrategy() DECONST_MODE: str = DeconstMode() DECONST_MAX_DISTANCE_T: int = DeconstMaxDistanceT() + DECONST_FULL_TOLERANCE: float = DeconstFullTolerance() FORCE_TIME_EXPANSION: bool = ForceTimeExpansion() + ALLOW_WEAK_RELIABILITY: bool = AllowWeakReliability() class Settings(metaclass=MetaSettings): @@ -108,7 +110,12 @@ class ReconstructionSettings: @dataclass class DeconstructionSettings: - pass + deconst_strategy: str = DeconstStrategy() + deconst_mode: str = DeconstMode() + deconst_max_distance_T: int = DeconstMaxDistanceT() + deconst_full_tolerance: float = DeconstFullTolerance() + force_time_expansion: bool = ForceTimeExpansion() + allow_weak_reliability: bool = AllowWeakReliability() def specific_settings_factory(settings_type: str): @@ -147,8 +154,12 @@ def specific_settings_factory(settings_type: str): Settings.MIN_RELIABILITY, Settings.REDUCE_MODEL_REDUNDANCY)]), "deconstruction": starmap( - DeconstructionSettings, [()] - ) + DeconstructionSettings, [(Settings.DECONST_STRATEGY, + Settings.DECONST_MODE, + Settings.DECONST_MAX_DISTANCE_T, + Settings.DECONST_FULL_TOLERANCE, + Settings.FORCE_TIME_EXPANSION, + Settings.ALLOW_WEAK_RELIABILITY)]) } return next(factory[settings_type]) @@ -205,3 +216,11 @@ def configure_main_settings_class(config): Settings.RELIABILITY_SAMPLE = reconstruction["reliability_sample"] Settings.MIN_RELIABILITY = reconstruction["min_reliability"] Settings.REDUCE_MODEL_REDUNDANCY = reconstruction["reduce_model_redundancy"] + + deconstruction = config["DECONSTRUCTION"] + Settings.DECONST_STRATEGY = deconstruction["deconst_strategy"] + Settings.DECONST_MODE = deconstruction["deconst_mode"] + Settings.DECONST_MAX_DISTANCE_T = deconstruction["deconst_max_distance_t"] + Settings.DECONST_FULL_TOLERANCE = deconstruction["deconst_full_tolerance"] + Settings.FORCE_TIME_EXPANSION = deconstruction["force_time_expansion"] + Settings.ALLOW_WEAK_RELIABILITY = deconstruction["allow_weak_reliability"]