/// <summary>
        /// Creates an initialized instance.
        /// </summary>
        /// <param name="elem">A xml element containing the configuration data.</param>
        public PredictorsProviderSettings(XElement elem)
        {
            //Validation
            XElement settingsElem = Validate(elem, XsdTypeName);

            //Allocation
            PredictorCfgCollection = new List <IPredictorSettings>();
            //Parsing
            foreach (XElement predictorElem in settingsElem.Elements())
            {
                IPredictorSettings predictorCfg = PredictorFactory.LoadPredictorSettings(predictorElem);
                if (predictorCfg != null)
                {
                    PredictorCfgCollection.Add(predictorCfg);
                }
            }
            Check();
            return;
        }
Example #2
0
        /// <summary>
        /// Creates new initialized instance.
        /// </summary>
        /// <param name="cfg">The configuration.</param>
        public PredictorsProvider(PredictorsProviderSettings cfg)
        {
            int reqAMDWCapacity = 0;
            int reqFMDWCapacity = 0;

            _predictorCollection = new List <IPredictor>(cfg.NumOfPredictors);
            _activationMDW       = null;
            _firingMDW           = null;
            _activationStat      = null;
            _activationDiffStat  = null;

            foreach (IPredictorSettings predictorCfg in cfg.PredictorCfgCollection)
            {
                IPredictor predictor = PredictorFactory.CreatePredictor(predictorCfg);
                reqAMDWCapacity = Math.Max(reqAMDWCapacity, predictor.Cfg.RequiredWndSizeOfActivations);
                reqFMDWCapacity = Math.Max(reqFMDWCapacity, predictor.Cfg.RequiredWndSizeOfFirings);
                if (predictor.Cfg.NeedsContinuousActivationStat && _activationStat == null)
                {
                    _activationStat = new BasicStat();
                }
                if (predictor.Cfg.NeedsContinuousActivationDiffStat && _activationDiffStat == null)
                {
                    _activationDiffStat = new BasicStat();
                }
                _predictorCollection.Add(predictor);
            }

            if (reqAMDWCapacity > 0)
            {
                _activationMDW = new MovingDataWindow(reqAMDWCapacity);
            }
            if (reqFMDWCapacity > 0)
            {
                _firingMDW = new SimpleQueue <byte>(reqFMDWCapacity);
            }
            Reset();
            return;
        }
Example #3
0
 /// <inheritdoc/>
 public override XElement GetXml(bool suppressDefaults)
 {
     return(GetXml(PredictorFactory.GetXmlName(ID), suppressDefaults));
 }