//Methods /// <summary> /// Checks if given predictor is enabled /// </summary> /// <param name="predictorID">Identificator of the predictor</param> public bool IsPredictorEnabled(PredictorID predictorID) { return(_cfg.IsEnabled(predictorID)); }
/// <summary> /// Creates new initialized instance. /// </summary> /// <param name="cfg">Configuration to be used. Note that ParamsCfg member inside the cfg must not be null.</param> public PredictorsProvider(PredictorsSettings cfg) { //Check if (cfg.ParamsCfg == null) { throw new ArgumentException("Invalid configuration. ParamsCfg inside the configuration is null.", "cfg"); } //Store configuration _cfg = cfg; //Determine necessary size of the activation moving window and instantiate it int activationMWSize = 0; if (_cfg.IsEnabled(PredictorID.ActivationMWAvg)) { switch (_cfg.ParamsCfg.ActivationMWAvgCfg.Weights) { case PredictorMWAvgWeightsType.Exponential: _activationMWAvgWeights = _expWeightsCache; activationMWSize = Math.Min(_cfg.ParamsCfg.ActivationMWAvgCfg.Window, _expWeightsCache.Length); break; case PredictorMWAvgWeightsType.Linear: _activationMWAvgWeights = _linWeightsCache; activationMWSize = Math.Min(_cfg.ParamsCfg.ActivationMWAvgCfg.Window, _linWeightsCache.Length); break; case PredictorMWAvgWeightsType.Constant: _activationMWAvgWeights = null; activationMWSize = _cfg.ParamsCfg.ActivationMWAvgCfg.Window; break; default: throw new InvalidOperationException($"Unsupported weights type {_cfg.ParamsCfg.ActivationMWAvgCfg.Weights}."); } } _activationMDW = activationMWSize == 0 ? null : new MovingDataWindow(activationMWSize); //Determine necessary size of the firing moving window and instantiate it int firingMWSize = 0; if (_cfg.IsEnabled(PredictorID.FiringMWAvg)) { switch (_cfg.ParamsCfg.FiringMWAvgCfg.Weights) { case PredictorMWAvgWeightsType.Exponential: _firingMWAvgWeights = _expWeightsCache; firingMWSize = Math.Min(_cfg.ParamsCfg.FiringMWAvgCfg.Window, _expWeightsCache.Length); break; case PredictorMWAvgWeightsType.Linear: _firingMWAvgWeights = _linWeightsCache; firingMWSize = Math.Min(_cfg.ParamsCfg.FiringMWAvgCfg.Window, _linWeightsCache.Length); break; case PredictorMWAvgWeightsType.Constant: _firingMWAvgWeights = null; firingMWSize = _cfg.ParamsCfg.FiringMWAvgCfg.Window; break; default: throw new InvalidOperationException($"Unsupported weights type {_cfg.ParamsCfg.FiringMWAvgCfg.Weights}."); } } if (_cfg.IsEnabled(PredictorID.FiringBinPattern)) { firingMWSize = Math.Max(firingMWSize, _cfg.ParamsCfg.FiringBinPatternCfg.Window); } if (_cfg.IsEnabled(PredictorID.FiringCount)) { firingMWSize = Math.Max(firingMWSize, _cfg.ParamsCfg.FiringCountCfg.Window); } _firingMDW = firingMWSize == 0 ? null : new Bitwise.Window(firingMWSize); Reset(); return; }