Ejemplo n.º 1
0
 /// <summary>
 /// The deep copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 public PredictorsSettings(PredictorsSettings source)
 {
     EnablingSwitchCollection = (bool[])source.EnablingSwitchCollection.Clone();
     //Params
     ParamsCfg = (PredictorsParamsSettings)source.ParamsCfg?.DeepClone();
     return;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 public PredictorsParamsSettings(PredictorsParamsSettings source)
 {
     ActivationFadingSumCfg = (ActivationFadingSumSettings)source.ActivationFadingSumCfg.DeepClone();
     ActivationMWAvgCfg     = (ActivationMWAvgSettings)source.ActivationMWAvgCfg.DeepClone();
     FiringFadingSumCfg     = (FiringFadingSumSettings)source.FiringFadingSumCfg.DeepClone();
     FiringMWAvgCfg         = (FiringMWAvgSettings)source.FiringMWAvgCfg.DeepClone();
     FiringCountCfg         = (FiringCountSettings)source.FiringCountCfg.DeepClone();
     FiringBinPatternCfg    = (FiringBinPatternSettings)source.FiringBinPatternCfg.DeepClone();
     return;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates an initialized instance
 /// </summary>
 /// <param name="enablingSwitchCollection">Enabling switches</param>
 /// <param name="paramsCfg">Parameters of the predictors</param>
 public PredictorsSettings(bool[] enablingSwitchCollection = null, PredictorsParamsSettings paramsCfg = null)
 {
     EnablingSwitchCollection = new bool[PredictorsProvider.NumOfSupportedPredictors];
     if (enablingSwitchCollection != null)
     {
         enablingSwitchCollection.CopyTo(EnablingSwitchCollection, 0);
     }
     else
     {
         EnablingSwitchCollection.Populate(true);
     }
     ParamsCfg = (PredictorsParamsSettings)paramsCfg?.DeepClone();
     return;
 }
Ejemplo n.º 4
0
 //Constructors
 /// <summary>
 /// Creates initialized instance as a result of L1, L2 and L3 predictors settings.
 /// (L1 overrides L2 overiddes L3)
 /// </summary>
 /// <param name="level1PredictorsCfg">Level1 (lowest level) predictors settings</param>
 /// <param name="level2PredictorsCfg">Level2 predictors settings</param>
 /// <param name="level3PredictorsCfg">Level3 (highest level) predictors settings</param>
 public PredictorsSettings(PredictorsSettings level1PredictorsCfg,
                           PredictorsSettings level2PredictorsCfg,
                           PredictorsSettings level3PredictorsCfg
                           )
 {
     EnablingSwitchCollection = new bool[PredictorsProvider.NumOfSupportedPredictors];
     //Params
     ParamsCfg = level1PredictorsCfg?.ParamsCfg != null ? (PredictorsParamsSettings)level1PredictorsCfg.ParamsCfg.DeepClone() : (level2PredictorsCfg?.ParamsCfg != null ? (PredictorsParamsSettings)level2PredictorsCfg.ParamsCfg.DeepClone() : (level3PredictorsCfg?.ParamsCfg != null ? (PredictorsParamsSettings)level3PredictorsCfg.ParamsCfg.DeepClone() : new PredictorsParamsSettings()));
     //Enabling switches
     foreach (PredictorsProvider.PredictorID predictorID in typeof(PredictorsProvider.PredictorID).GetEnumValues())
     {
         EnablingSwitchCollection[(int)predictorID] = ((level1PredictorsCfg == null ? true : level1PredictorsCfg.EnablingSwitchCollection[(int)predictorID]) &&
                                                       (level2PredictorsCfg == null ? true : level2PredictorsCfg.EnablingSwitchCollection[(int)predictorID]) &&
                                                       (level3PredictorsCfg == null ? true : level3PredictorsCfg.EnablingSwitchCollection[(int)predictorID])
                                                       );
     }
     return;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates an initialized instance.
        /// </summary>
        /// <param name="elem">Xml element containing the initialization settings</param>
        public PredictorsSettings(XElement elem)
        {
            //Validation
            XElement predictorsElem = Validate(elem, XsdTypeName);

            //Parsing of enabling switches
            EnablingSwitchCollection = new bool[PredictorsProvider.NumOfSupportedPredictors];
            foreach (PredictorsProvider.PredictorID predictorID in typeof(PredictorsProvider.PredictorID).GetEnumValues())
            {
                EnablingSwitchCollection[(int)predictorID] = bool.Parse(predictorsElem.Attribute(GetXmlName(predictorID)).Value);
            }
            //Parsing of params
            ParamsCfg = null;
            XElement paramsElem = predictorsElem.Elements("params").FirstOrDefault();

            if (paramsElem != null)
            {
                ParamsCfg = new PredictorsParamsSettings(paramsElem);
            }
            return;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates an initialized instance
 /// </summary>
 /// <param name="activation">Activation predictor enabling switch</param>
 /// <param name="activationSquare">ActivationSquare predictor enabling switch</param>
 /// <param name="activationFadingSum">ActivationFadingSum predictor enabling switch</param>
 /// <param name="activationMWAvg">ActivationMWAvg predictor enabling switch</param>
 /// <param name="firingFadingSum">FiringFadingSum predictor enabling switch</param>
 /// <param name="firingMWAvg">FiringMWAvg predictor enabling switch</param>
 /// <param name="firingCount">FiringCount predictor enabling switch</param>
 /// <param name="firingBinPattern">FiringBinPattern predictor enabling switch</param>
 /// <param name="paramsCfg">Parameters of the predictors</param>
 public PredictorsSettings(bool activation,
                           bool activationSquare,
                           bool activationFadingSum,
                           bool activationMWAvg,
                           bool firingFadingSum,
                           bool firingMWAvg,
                           bool firingCount,
                           bool firingBinPattern,
                           PredictorsParamsSettings paramsCfg = null
                           )
 {
     EnablingSwitchCollection = new bool[PredictorsProvider.NumOfSupportedPredictors];
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.Activation]          = activation;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.ActivationSquare]    = activationSquare;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.ActivationFadingSum] = activationFadingSum;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.ActivationMWAvg]     = activationMWAvg;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.FiringFadingSum]     = firingFadingSum;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.FiringMWAvg]         = firingMWAvg;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.FiringCount]         = firingCount;
     EnablingSwitchCollection[(int)PredictorsProvider.PredictorID.FiringBinPattern]    = firingBinPattern;
     ParamsCfg = (PredictorsParamsSettings)paramsCfg?.DeepClone();
     return;
 }