Esempio n. 1
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (Binding != null)
            {
                p.Add(new KeyValuePair <string, string>("Binding", Binding));
            }

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (FactorType != null)
            {
                p.Add(new KeyValuePair <string, string>("FactorType", FactorType.ToString()));
            }

            if (Config != null)
            {
                p.Add(new KeyValuePair <string, string>("Config", Config));
            }

            return(p);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the value factor mapping reference.
        /// </summary>
        /// <param name="factor">The factor.</param>
        /// <param name="factorType">Type of the factor.</param>
        /// <param name="generatorType">Type of the generator.</param>
        /// <returns></returns>
        public static double GetValueFactorMappingReference(BaseFactor factor, FactorType factorType, GeneratorType generatorType)
        {
            double factorMappingReferenceData = 0;

            // Make sure to initialize the mapping information
            if (Constants.GeneratorsTypeToFactorMapper.ContainsKey(generatorType))
            {
                if (factorType == FactorType.ValueFactor)
                {
                    var valueFactorMappingTuple = Constants.GeneratorsTypeToFactorMapper[generatorType];
                    var valueFactorMapping      = valueFactorMappingTuple.Item1.Value;

                    switch (valueFactorMapping)
                    {
                    case ValueFactorType.Low:
                        factorMappingReferenceData = factor.Low;
                        break;

                    case ValueFactorType.Medium:
                        factorMappingReferenceData = factor.Medium;
                        break;

                    case ValueFactorType.High:
                        factorMappingReferenceData = factor.High;
                        break;
                    }
                    ;
                }
                else
                {
                    var emissionFactorMappingTuple = Constants.GeneratorsTypeToFactorMapper[generatorType];
                    var emissionFactorMapping      = emissionFactorMappingTuple.Item2.Value;

                    switch (emissionFactorMapping)
                    {
                    case EmissionsFactorType.NA:
                        factorMappingReferenceData = 0;
                        break;

                    case EmissionsFactorType.Low:
                        factorMappingReferenceData = factor.Low;
                        break;

                    case EmissionsFactorType.Medium:
                        factorMappingReferenceData = factor.Medium;
                        break;

                    case EmissionsFactorType.High:
                        factorMappingReferenceData = factor.High;
                        break;
                    }
                    ;
                }
            }

            return(factorMappingReferenceData);
        }
Esempio n. 3
0
        public Debtor(Person person)
        {
            Person      = person;
            Factor      = person.DebtFactor;
            Factor_Type = FactorType.Standart;

            int beginDebt = 0;

            Debt = beginDebt;
        }
Esempio n. 4
0
        public static IUserFactor NewFactor(FactorType factorType, string provider, Resource profile)
        {
            var data = new Dictionary <string, object>(StringComparer.Ordinal)
            {
                ["factorType"] = factorType,
                ["provider"]   = provider,
                ["profile"]    = profile,
            };

            return(Create <UserFactor>(data));
        }
Esempio n. 5
0
        private BaseFactor GetFactors(FactorType factorType)
        {
            var factors = (from factor in base.SimpleStreamAxis(FileName, factorType.ToString())
                           select new BaseFactor
            {
                High = Convert.ToDouble(factor.ElementAnyNS(EmissionsFactorType.High.ToString()).Value),
                Medium = Convert.ToDouble(factor.ElementAnyNS(EmissionsFactorType.Medium.ToString()).Value),
                Low = Convert.ToDouble(factor.ElementAnyNS(EmissionsFactorType.Low.ToString()).Value),
            }).Select(x => { x.ErrorMessages = x.Validate(); return(x); }).FirstOrDefault();


            return(factors);
        }
Esempio n. 6
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (FactorType != null)
            {
                p.Add(new KeyValuePair <string, string>("FactorType", FactorType.ToString()));
            }

            if (BindingAlg != null)
            {
                p.Add(new KeyValuePair <string, string>("Binding.Alg", BindingAlg));
            }

            if (BindingPublicKey != null)
            {
                p.Add(new KeyValuePair <string, string>("Binding.PublicKey", BindingPublicKey.ToString()));
            }

            if (ConfigAppId != null)
            {
                p.Add(new KeyValuePair <string, string>("Config.AppId", ConfigAppId));
            }

            if (ConfigNotificationPlatform != null)
            {
                p.Add(new KeyValuePair <string, string>("Config.NotificationPlatform", ConfigNotificationPlatform.ToString()));
            }

            if (ConfigNotificationToken != null)
            {
                p.Add(new KeyValuePair <string, string>("Config.NotificationToken", ConfigNotificationToken));
            }

            if (ConfigSdkVersion != null)
            {
                p.Add(new KeyValuePair <string, string>("Config.SdkVersion", ConfigSdkVersion));
            }

            return(p);
        }
        private decimal ExecuteFactor(FactorType type, Dictionary <FactorType, List <FactorInfo> > factors, Dictionary <FactorType, List <FactorInfo> > defenderFactors, Hero hero, Creature creature, TextWriter log, decimal i2 = 1, decimal r2 = 1)
        {
            decimal value = 0;

            if (!factors.ContainsKey(type))
            {
                return(value);
            }

            List <FactorInfo> factorInfos = factors[type];


            foreach (FactorInfo info in factorInfos)
            {
                log.WriteLine("Executing bonus: {0} for {1}. Factor type: {2}", info.ParentRef.Name, creature.Name, type.ToString());

                object modificator = null;

                if (info.Factor.Item is Modificator)
                {
                    modificator = info.Factor.Item;
                }
                else if (info.Factor.Item is Reference)
                {
                    object refModificator = World.Modificators[((Reference)info.Factor.Item).Name];
                    modificator = (Modificator)refModificator;
                }
                else if (info.Factor.Item is LevelModificator)
                {
                    modificator = info.Factor.Item;
                }

                value += EvalModificator(modificator, info, defenderFactors, hero, creature, log, i2, r2);
            }

            log.WriteLine("Factor Type: {0} evaluationg finished with value: '{1}' for {2}.", type.ToString(), value, creature.Name);

            return(value);
        }
Esempio n. 8
0
        public Debtor(Person person, FactorType factorType, double value)
        {
            Person           = person;
            this.Factor_Type = factorType;

            if (factorType == FactorType.SpecialForProduct)
            {
                Factor = value;
                int beginDebt = 0;
                Debt = beginDebt;
            }
            else if (factorType == FactorType.WithoutFactor)
            {
                Factor = GeneralInfo.FixedDebtFactor;
                Debt   = value;
            }
            else
            {
                Factor = Person.DebtFactor;
                int beginDebt = 0;
                Debt = beginDebt;
            }
        }
Esempio n. 9
0
 public Xavier(RandType randType = RandType.Gaussian, FactorType factorType = FactorType.Average, float magnitude = 3)
 {
     this.Rand      = randType;
     this.Factor    = factorType;
     this.Magnitude = magnitude;
 }
Esempio n. 10
0
 public MSPReLU(FactorType factorType = FactorType.Average, float slope = 0.25f)
     : base(RandType.Gaussian, factorType, (float)(2d / (1 + slope * slope)))
 {
 }
Esempio n. 11
0
 public Xavier(RndType rnd_type = RndType.Uniform, FactorType factor_type = FactorType.Avg, float magnitude = 3)
 {
     this._rnd_type    = rnd_type;
     this._factor_type = factor_type;
     this._magnitude   = magnitude;
 }
Esempio n. 12
0
 public Factor(FactorType type, NonTerminal expression)
 {
     Type       = type;
     Expression = expression;
 }
Esempio n. 13
0
 public Factor(FactorType type, string digit)
 {
     Type  = type;
     Digit = digit;
 }
Esempio n. 14
0
 public Factor(FactorType type, Identifier identifier)
 {
     Type       = type;
     Identifier = identifier;
 }
Esempio n. 15
0
 public FabWeightFactor(string name, float weightFactor, float sequence, FactorType type, OrderType orderType, string criteria, bool isAllowFilter)
     : base(name, weightFactor, sequence, type, orderType)
 {
     this.OrigCriteria  = criteria;
     this.IsAllowFilter = IsAllowFilter;
 }