Example #1
0
 private bool IsExposureValidForTraits(ExposureType exposure_type)
 {
     if (exposure_type.required_traits != null && exposure_type.required_traits.Count > 0)
     {
         foreach (string required_trait in exposure_type.required_traits)
         {
             if (!traits.HasTrait(required_trait))
             {
                 return(false);
             }
         }
     }
     if (exposure_type.excluded_traits != null && exposure_type.excluded_traits.Count > 0)
     {
         foreach (string excluded_trait in exposure_type.excluded_traits)
         {
             if (traits.HasTrait(excluded_trait))
             {
                 return(false);
             }
         }
     }
     if (exposure_type.excluded_effects != null && exposure_type.excluded_effects.Count > 0)
     {
         Effects component = base.master.GetComponent <Effects>();
         foreach (string excluded_effect in exposure_type.excluded_effects)
         {
             if (component.HasEffect(excluded_effect))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #2
0
 internal void OnDeserialized()
 {
     integratedExposure.Clear();
     foreach (var info in totalExposure)
     {
         string       germID   = info.germID;
         ExposureType exposure = null;
         // Look for a matching germ exposure
         foreach (var candidate in TUNING.GERM_EXPOSURE.TYPES)
         {
             if (candidate.germ_id == germID)
             {
                 exposure = candidate;
                 break;
             }
         }
         if (exposure == null)
         {
             // Diagnostic for removed diseases
             PUtil.LogWarning("Found unknown germ exposure ID {0} when loading".F(
                                  germID));
         }
         else
         {
             integratedExposure.Add(new GermExposure(info.vector, exposure), info.total);
         }
     }
 }
Example #3
0
 public RITCharacteristic(long _ID, ExposureType _expType, double _tiv)
 {
     SubperilToAllocState = new Dictionary <string, AllocationState>();
     ID      = _ID;
     ExpType = _expType;
     TIV     = _tiv;
 }
Example #4
0
        public override HashSet <AtomicRITE> GetAtomicRites()
        {
            if (!IsDerived)
            {
                HashSet <CoverageAtomicRITE> ARITEs = new HashSet <CoverageAtomicRITE>();

                foreach (ExposureType expType in ExposureTypes)
                {
                    var RITChars = Schedule.RITChars.Where(RitChar => RitChar.ExpType == expType || ExposureTypeCollection.GetMappedType(RitChar.ExpType) == expType);
                    foreach (RITCharacteristic RITChar in RITChars)
                    {
                        HashSet <String> temp = CauseOfLossSet.GetSubperils();
                        foreach (string subperil in temp)
                        {
                            ExposureType       tempType = ExposureTypeCollection.GetMappedType(RITChar.ExpType);
                            CoverageAtomicRITE tempRite = new CoverageAtomicRITE(subperil, tempType, RITChar.ParentRITE, RITChar.ID);
                            ARITEs.Add(tempRite);
                            //IEnumerable<RITCharacteristic> RITChars;
                            //RITChars = rite.RiskCharacteristics.Where(RitChar => RitChar.ExpType == expType || ExposureTypeCollection.GetMappedType(RitChar.ExpType) == expType);
                            //foreach (RITCharacteristic RitChar in RITChars)
                            //{
                            //    ARITEs.Add(new CoverageAtomicRITE(subperil, ExposureTypeCollection.GetMappedType(RitChar.ExpType), rite, RitChar.ID));
                            //}
                        }
                    }
                }

                return(new HashSet <AtomicRITE>(ARITEs.Cast <AtomicRITE>()));
            }
            else
            {
                //    throw new InvalidOperationException("Cannot get Atomic Rites for derived subjects!");
                return(new HashSet <AtomicRITE>());
            }
        }
Example #5
0
        public void AddCharacteristic(long _ID, ExposureType _expType, double _tiv)
        {
            RITCharacteristic Char = new RITCharacteristic(_ID, _expType, _tiv);

            RiskCharacteristics.Add(Char);
            Char.ParentRITE = this;
        }
Example #6
0
        public int AssessDigestedGerms(ExposureType exposure_type, int count)
        {
            int exposure_threshold = exposure_type.exposure_threshold;
            int val = count / exposure_threshold;

            return(MathUtil.Clamp(1, 3, val));
        }
Example #7
0
 // Gets the threshold for infecting a duplicant via each vector.
 public static GermExposureThresholds ThresholdsFor(ExposureType exposure)
 {
     if (!thresholds.TryGetValue(exposure, out GermExposureThresholds threshold))
     {
         threshold = new GermExposureThresholds(0, 0, 0);
     }
     return(threshold);
 }
Example #8
0
        public Subject(UniversalSubjectPosition universalSubject,
                       Dictionary <SymbolicValue, Dictionary <int, Tuple <HashSet <long>, HashSet <long> > > > Components2Difference,
                       Dictionary <string, HashSet <long> > resolvedSchedule = null,
                       bool _Resolution       = false,
                       bool _isNotConstrained = false)
        {
            SetID();

            this.UniversalSubject = universalSubject;

            this.Schedule = new Schedule(new HashSet <SymbolicValue>()
            {
                "Residual"
            });

            this.PerRisk          = _Resolution;
            this.isNotConstrained = _isNotConstrained;

            if (resolvedSchedule != null)
            {
                this.ResolvedSchedule = resolvedSchedule;
            }

            this.ExposureTypes = new HashSet <SymbolicValue>();
            this.CausesOfLoss  = new HashSet <SymbolicValue>();
            this.RITEIds       = new HashSet <long>();

            this.Components = Components2Difference;

            foreach (SymbolicValue COL in Components.Keys)
            {
                CausesOfLoss.Add(COL);
                foreach (int ResolvedExposureType in Components[COL].Keys)
                {
                    ExposureTypes.Add(new SymbolicValue(((ExposureType.EExposureType)ResolvedExposureType).ToString()));
                    HashSet <long> Components_COL_ResolvedExposureType = Components[COL][ResolvedExposureType].Item1;
                    foreach (long RITEId in Components_COL_ResolvedExposureType)
                    {
                        this.RITEIds.Add(RITEId);
                    }
                }
            }

            this.ResolvedExposureTypes = new HashSet <int>();
            foreach (SymbolicValue _ExposureType in ExposureTypes)
            {
                //ExposureType.ExposureTypeGroup ExposureTypeGroup = new ExposureType.ExposureTypeGroup();
                //ExposureTypeGroup.Set((ExposureType.EExposureType)(Enum.Parse(typeof(ExposureType.EExposureType), _ExposureType.ToString())));
                //ResolvedExposureTypes.UnionWith(ExposureTypeGroup.GetIndividualIntExposureTypes());
                //TODO : Use the above approach (3 lines of code) when platform is fixed and ready
                ResolvedExposureTypes.UnionWith(
                    ExposureType.GetIndividualIntExposureTypes(
                        (ExposureType.EExposureType)(Enum.Parse(typeof(ExposureType.EExposureType), _ExposureType.ToString()))
                        )
                    );
            }
        }
Example #9
0
 public UniversalSubjectPosition(HashSet <long> allRITEIds, HashSet <long> allRiskItemIds)
 {
     AllRITEIds     = allRITEIds;
     AllRiskItemIds = allRiskItemIds;
     CausesOfLoss   = new HashSet <SymbolicValue>()
     {
         "EQ", "WS", "CS", "FL", "WT", "FR", "TR", "SH", "FF", "SL", "WI", "WA", "SU", "HA", "TO", "SW", "FZ", "IC", "SN", "WF", "TS"
     };
     ResolvedExposureTypes = new HashSet <int>(ExposureType.GetIndividualIntExposureTypes(ExposureType.EExposureType.Loss));
 }
Example #10
0
 public CoverageAtomicRITE(string _subperil, ExposureType _expType, RITE _rite, long ID)
 {
     SubPeril                         = _subperil;
     ExpType                          = _expType;
     RITE                             = _rite;
     RITCharacterisiticID             = ID;
     CurrentAllocationStateCollection = new AllocationStateCollection2(RITE.ActNumOfSampleBldgs);
     //CurrentAllocationStateSummed = new AllocationState();
     CurrentLossStateCollection = new LossStateCollection2(RITE.ActNumOfSampleBldgs);
 }
Example #11
0
        public ContractAtomicRITE(Graph _contractGraph, string _subPeril, ExposureType _expType)
        {
            contractGraph = _contractGraph;
            SubPeril      = _subPeril;
            ExpType       = _expType;

            CurrentAllocationStateCollection = new AllocationStateCollection(1);

            if (_contractGraph.IsExecuted)
            {
                subjectLoss = _contractGraph.exResults.GetFilteredTimeSeries(_subPeril, _expType);
            }
        }
Example #12
0
 public void InfectImmediately(ExposureType exposure_type)
 {
     if (exposure_type.infection_effect != null)
     {
         Effects component = base.master.GetComponent <Effects>();
         component.Add(exposure_type.infection_effect, true);
     }
     if (exposure_type.sickness_id != null)
     {
         string lastDiseaseSource           = GetLastDiseaseSource(exposure_type.germ_id);
         SicknessExposureInfo exposure_info = new SicknessExposureInfo(exposure_type.sickness_id, lastDiseaseSource);
         sicknesses.Infect(exposure_info);
     }
 }
Example #13
0
        public UniversalSubjectPosition2(SortedSet <long> allRITEIds)
        {
            CausesOfLoss = new HashSet <SymbolicValue>()
            {
                "EQ", "WS", "CS", "FL", "WT", "FR", "TR", "SH", "FF", "SL", "WI", "SU", "HA", "TO", "SW", "FZ", "IC", "SN", "WF", "TS"
            };
            ResolvedExposureTypes = new HashSet <int>(ExposureType.GetIndividualIntExposureTypes(ExposureType.EExposureType.Loss));

            AllRITEIds          = new EwahCompressedBitArray();
            OffsetForAllRITEIds = allRITEIds.First();
            foreach (long RITEId in allRITEIds)
            {
                AllRITEIds.Set((int)(RITEId - OffsetForAllRITEIds));
            }
        }
Example #14
0
        public float GetResistanceToExposureType(ExposureType exposureType, float overrideExposureTier = -1f)
        {
            float num = overrideExposureTier;

            if (num == -1f)
            {
                num = GetExposureTier(exposureType.germ_id);
            }
            num = Mathf.Clamp(num, 1f, 3f);
            float             num2 = GERM_EXPOSURE.EXPOSURE_TIER_RESISTANCE_BONUSES[(int)num - 1];
            AttributeInstance attributeInstance = Db.Get().Attributes.GermResistance.Lookup(base.gameObject);
            float             totalValue        = attributeInstance.GetTotalValue();

            return((float)exposureType.base_resistance + totalValue + num2);
        }
Example #15
0
 public bool AssessInhaledGerms(ExposureType exposure_type)
 {
     inhaleExposureTick.TryGetValue(exposure_type.germ_id, out InhaleTickInfo value);
     if (value == null)
     {
         value = new InhaleTickInfo();
         inhaleExposureTick[exposure_type.germ_id] = value;
     }
     if (!value.inhaled)
     {
         float exposureTier = GetExposureTier(exposure_type.germ_id);
         value.inhaled = true;
         return(value.ticks >= GERM_EXPOSURE.INHALE_TICK_THRESHOLD[(int)exposureTier]);
     }
     return(false);
 }
        private static string ReduceNotifications(List <Notification> list, object tooltipData)
        {
            string text = "";

            foreach (Notification n in list)
            {
                MinionIdentity minion            = (MinionIdentity)n.customClickData;
                string         sickness_id       = (string)tooltipData;
                string         name              = n.NotifierName;
                ExposureType   type              = TUNING.GERM_EXPOSURE.TYPES.First(x => x.sickness_id == sickness_id);
                GermExposureMonitor.Instance smi = minion.GetSMI <GermExposureMonitor.Instance>();
                float  chance            = ((!type.infect_immediately) ? GermExposureMonitor.GetContractionChance(smi.GetResistanceToExposureType(type, -1f)) : 1f);
                string contractionChance = GameUtil.GetFormattedPercent(chance * 100);
                text = text + $"\n{name} - {contractionChance}";
            }
            return(text);
        }
Example #17
0
        // Checks to see if the Duplicant is immune to a certain exposure.
        internal bool IsExposureValidForTraits(ExposureType exposure)
        {
            bool valid = true;
            ICollection <string> required = exposure.required_traits, excluded = exposure.
                                                                                 excluded_traits, noEffects = exposure.excluded_effects;

            if (required != null && required.Count > 0)
            {
                foreach (string traitID in required)
                {
                    if (!traits.HasTrait(traitID))
                    {
                        valid = false;
                        break;
                    }
                }
            }
            if (valid && excluded != null && excluded.Count > 0)
            {
                foreach (string traitID in excluded)
                {
                    if (traits.HasTrait(traitID))
                    {
                        valid = false;
                        break;
                    }
                }
            }
            if (valid && noEffects != null && noEffects.Count > 0)
            {
                var effects = gameObject.GetComponent <Effects>();
                if (effects != null)
                {
                    foreach (string effect_id in noEffects)
                    {
                        if (effects.HasEffect(effect_id))
                        {
                            valid = false;
                            break;
                        }
                    }
                }
            }
            return(valid);
        }
Example #18
0
        // Retrieves the total germ count for a given germ type across ALL infection vectors.
        internal int GetTotalGerms(ExposureType exposure)
        {
            int total = 0;

            if (exposure == null)
            {
                throw new ArgumentNullException("exposure");
            }
            foreach (var vector in ALL_VECTORS)
            {
                if (integratedExposure.TryGetValue(new GermExposure(vector, exposure),
                                                   out int byVector))
                {
                    total += byVector;
                }
            }
            return(total);
        }
 public static string ToString(ExposureType value)
 {
     if (value == ExposureType.Drugadmin)
     {
         return("drugadmin");
     }
     else if (value == ExposureType.Immuniz)
     {
         return("immuniz");
     }
     else if (value == ExposureType.Coincidental)
     {
         return("coincidental");
     }
     else
     {
         throw new ArgumentException("Unrecognized ExposureType value: " + value.ToString());
     }
 }
Example #20
0
        public LossTimeSeries GetFilteredTimeSeries(string subperil, ExposureType exType)
        {
            var timeGroups =
                from allocLoss in AllocatedLosses
                group allocLoss by allocLoss.timestamp into g
                select new { Time = g.Key, Payouts = g };

            LossTimeSeries series = new LossTimeSeries(1);

            foreach (var g in timeGroups)
            {
                double totalpayout = g.Payouts.Where(payout => payout.Subperil == subperil && payout.ExpType == exType)
                                     .Select(payout => payout.Loss)
                                     .Sum();
                series.AddLoss(g.Time, totalpayout);
            }

            return(series);
        }
            public static void Postfix(string germ_id, GermExposureMonitor.ExposureState exposure_state, GermExposureMonitor.Instance __instance)
            {
                if (exposure_state == GermExposureMonitor.ExposureState.Exposed)
                {
                    ExposureType exposure_type = null;

                    foreach (ExposureType type in TUNING.GERM_EXPOSURE.TYPES)
                    {
                        if (germ_id == type.germ_id)
                        {
                            exposure_type = type;
                            break;
                        }
                    }
                    Sickness sickness = exposure_type?.sickness_id != null?Db.Get().Sicknesses.Get(exposure_type.sickness_id) : null;

                    string sicknessName = sickness != null ? sickness.Name : "a disease";
                    string text         = string.Format(DUPE_EXPOSED_TO_GERMS_POPFX, sicknessName);
                    PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, text, __instance.gameObject.transform, 3f, true);
                    CreateAndAddNotification(__instance, sicknessName, exposure_type.sickness_id);
                }
            }
    public void AddExposure(ExposureType exposure_type, float amount)
    {
        accumulation.TryGetValue(exposure_type.germ_id, out float value);
        float num = value + amount;

        if (num > 1f)
        {
            foreach (MinionIdentity item in Components.LiveMinionIdentities.Items)
            {
                GermExposureMonitor.Instance sMI = item.GetSMI <GermExposureMonitor.Instance>();
                if (sMI.GetExposureState(exposure_type.germ_id) == GermExposureMonitor.ExposureState.Exposed)
                {
                    GermExposureMonitor.Instance sMI2 = item.GetSMI <GermExposureMonitor.Instance>();
                    float exposureWeight = sMI2.GetExposureWeight(exposure_type.germ_id);
                    if (exposureWeight > 0f)
                    {
                        exposure_candidates.Add(new WeightedExposure
                        {
                            weight  = exposureWeight,
                            monitor = sMI
                        });
                    }
                }
            }
            while (num > 1f)
            {
                num -= 1f;
                if (exposure_candidates.Count > 0)
                {
                    WeightedExposure weightedExposure = WeightedRandom.Choose(exposure_candidates, rng);
                    exposure_candidates.Remove(weightedExposure);
                    weightedExposure.monitor.ContractGerms(exposure_type.germ_id);
                }
            }
        }
        accumulation[exposure_type.germ_id] = num;
        exposure_candidates.Clear();
    }
            public static bool TryParse(string value, out ExposureType result)
            {
                result = default(ExposureType);

                if (value == "drugadmin")
                {
                    result = ExposureType.Drugadmin;
                }
                else if (value == "immuniz")
                {
                    result = ExposureType.Immuniz;
                }
                else if (value == "coincidental")
                {
                    result = ExposureType.Coincidental;
                }
                else
                {
                    return(false);
                }

                return(true);
            }
Example #24
0
        // Retrieves the worst chance for germ infection across all vectors.
        internal float GetWorstInfectionChance(ExposureType exposure, float resist)
        {
            float worstChance = 0.0f;

            if (exposure == null)
            {
                throw new ArgumentNullException("exposure");
            }
            foreach (var vector in ALL_VECTORS)
            {
                var ge = new GermExposure(vector, exposure);
                if (integratedExposure.TryGetValue(ge, out int byVector))
                {
                    // Resistance should be calculated by the SMI
                    float chance = GetInfectionChance(ge, byVector, resist);
                    if (chance > worstChance)
                    {
                        worstChance = chance;
                    }
                }
            }
            return(worstChance);
        }
Example #25
0
 public async Task<LivePortfolioPnl> GetLivePnl(CarbonClient cc_, ExposureType type_, bool forceRefresh_ = false)
 {
   return type_ == ExposureType.Allocated
     ? await GetLiveAllocatedPnl(cc_, forceRefresh_)
     : await GetLiveUnAllocatedPnl(cc_, forceRefresh_);
 }
Example #26
0
 public async Task<Tuple<string[], double[]>> GetLatestExposure(CarbonClient cc_, ExposureType type_, bool forceRefresh_ = false)
 {
   return type_ == ExposureType.Allocated
     ? await GetLatestAllocatedExposure(cc_, forceRefresh_)
     : await GetLatestUnAllocatedExposure(cc_, forceRefresh_);
 }
Example #27
0
 public async Task<SysTimeSeries> GetExposure(CarbonClient cc_, ExposureType type_, bool forceRefresh_ = false)
 {
   return type_ == ExposureType.Allocated
     ? await GetAllocatedExposure(cc_, forceRefresh_)
     : await GetUnAllocatedExposure(cc_, forceRefresh_);
 }
Example #28
0
 public async Task<PortfolioPnlCache> GetHistoricPnl(CarbonClient cc_, ExposureType type_, bool forceRefresh_ = false)
 {
   return type_ == ExposureType.Allocated
     ? await GetHistoricAllocatedPnl(cc_, forceRefresh_)
     : await GetHistoricUnAllocatedPnl(cc_, forceRefresh_);
 }
 private bool CreateImmuneInfo()
 {
     GermExposureMonitor.Instance sMI = selectedTarget.GetSMI <GermExposureMonitor.Instance>();
     if (sMI != null)
     {
         immuneSystemPanel.SetTitle(UI.DETAILTABS.DISEASE.CONTRACTION_RATES);
         immuneSystemPanel.SetLabel("germ_resistance", Db.Get().Attributes.GermResistance.Name + ": " + sMI.GetGermResistance(), DUPLICANTS.ATTRIBUTES.GERMRESISTANCE.DESC);
         for (int i = 0; i < Db.Get().Diseases.Count; i++)
         {
             Disease       disease = Db.Get().Diseases[i];
             ExposureType  exposureTypeForDisease = GameUtil.GetExposureTypeForDisease(disease);
             Sickness      sicknessForDisease     = GameUtil.GetSicknessForDisease(disease);
             bool          flag = true;
             List <string> list = new List <string>();
             if (exposureTypeForDisease.required_traits != null && exposureTypeForDisease.required_traits.Count > 0)
             {
                 for (int j = 0; j < exposureTypeForDisease.required_traits.Count; j++)
                 {
                     if (!selectedTarget.GetComponent <Traits>().HasTrait(exposureTypeForDisease.required_traits[j]))
                     {
                         list.Add(exposureTypeForDisease.required_traits[j]);
                     }
                 }
                 if (list.Count > 0)
                 {
                     flag = false;
                 }
             }
             bool          flag2 = false;
             List <string> list2 = new List <string>();
             if (exposureTypeForDisease.excluded_effects != null && exposureTypeForDisease.excluded_effects.Count > 0)
             {
                 for (int k = 0; k < exposureTypeForDisease.excluded_effects.Count; k++)
                 {
                     if (selectedTarget.GetComponent <Effects>().HasEffect(exposureTypeForDisease.excluded_effects[k]))
                     {
                         list2.Add(exposureTypeForDisease.excluded_effects[k]);
                     }
                 }
                 if (list2.Count > 0)
                 {
                     flag2 = true;
                 }
             }
             bool          flag3 = false;
             List <string> list3 = new List <string>();
             if (exposureTypeForDisease.excluded_traits != null && exposureTypeForDisease.excluded_traits.Count > 0)
             {
                 for (int l = 0; l < exposureTypeForDisease.excluded_traits.Count; l++)
                 {
                     if (selectedTarget.GetComponent <Traits>().HasTrait(exposureTypeForDisease.excluded_traits[l]))
                     {
                         list3.Add(exposureTypeForDisease.excluded_traits[l]);
                     }
                 }
                 if (list3.Count > 0)
                 {
                     flag3 = true;
                 }
             }
             string text = string.Empty;
             float  num;
             if (!flag)
             {
                 num = 0f;
                 string text2 = string.Empty;
                 for (int m = 0; m < list.Count; m++)
                 {
                     if (text2 != string.Empty)
                     {
                         text2 += ", ";
                     }
                     text2 += Db.Get().traits.Get(list[m]).Name;
                 }
                 text += string.Format(DUPLICANTS.DISEASES.IMMUNE_FROM_MISSING_REQUIRED_TRAIT, text2);
             }
             else if (flag3)
             {
                 num = 0f;
                 string text3 = string.Empty;
                 for (int n = 0; n < list3.Count; n++)
                 {
                     if (text3 != string.Empty)
                     {
                         text3 += ", ";
                     }
                     text3 += Db.Get().traits.Get(list3[n]).Name;
                 }
                 if (text != string.Empty)
                 {
                     text += "\n";
                 }
                 text += string.Format(DUPLICANTS.DISEASES.IMMUNE_FROM_HAVING_EXLCLUDED_TRAIT, text3);
             }
             else if (flag2)
             {
                 num = 0f;
                 string text4 = string.Empty;
                 for (int num2 = 0; num2 < list2.Count; num2++)
                 {
                     if (text4 != string.Empty)
                     {
                         text4 += ", ";
                     }
                     text4 += Db.Get().effects.Get(list2[num2]).Name;
                 }
                 if (text != string.Empty)
                 {
                     text += "\n";
                 }
                 text += string.Format(DUPLICANTS.DISEASES.IMMUNE_FROM_HAVING_EXCLUDED_EFFECT, text4);
             }
             else
             {
                 num = ((!exposureTypeForDisease.infect_immediately) ? GermExposureMonitor.GetContractionChance(sMI.GetResistanceToExposureType(exposureTypeForDisease, 3f)) : 1f);
             }
             string arg = (!(text != string.Empty)) ? string.Format(DUPLICANTS.DISEASES.CONTRACTION_PROBABILITY, GameUtil.GetFormattedPercent(num * 100f, GameUtil.TimeSlice.None), selectedTarget.GetProperName(), sicknessForDisease.Name) : text;
             immuneSystemPanel.SetLabel("disease_" + disease.Id, "    • " + disease.Name + ": " + GameUtil.GetFormattedPercent(num * 100f, GameUtil.TimeSlice.None), string.Format(DUPLICANTS.DISEASES.RESISTANCES_PANEL_TOOLTIP, arg, sicknessForDisease.Name));
         }
         return(true);
     }
     return(false);
 }
 public static string ToString(ExposureType value)
 {
     if( value==ExposureType.Drugadmin )
         return "drugadmin";
     else if( value==ExposureType.Immuniz )
         return "immuniz";
     else if( value==ExposureType.Coincidental )
         return "coincidental";
     else
         throw new ArgumentException("Unrecognized ExposureType value: " + value.ToString());
 }
Example #31
0
 // Gets the total resistance to a disease factoring in disease base and dupe traits.
 internal float GetResistance(ExposureType exposure)
 {
     return(exposure.base_resistance + GetDupeResistance());
 }
Example #32
0
 public GermExposure(Sickness.InfectionVector vector, ExposureType exposure)
 {
     Exposure = exposure ?? throw new ArgumentNullException("exposure");
     Vector   = vector;
 }
Example #33
0
 public LossTimeSeries GetFilteredTimeSeries(string subperil, ExposureType exType)
 {
     return(AllocatedPayoutLosses.GetFilteredTimeSeries(subperil, exType));
 }
            public static bool TryParse(string value, out ExposureType result)
            {
                result = default(ExposureType);

                if( value=="drugadmin")
                    result = ExposureType.Drugadmin;
                else if( value=="immuniz")
                    result = ExposureType.Immuniz;
                else if( value=="coincidental")
                    result = ExposureType.Coincidental;
                else
                    return false;

                return true;
            }
 public RITCharacteristic(long _ID, ExposureType _expType, double _tiv)
 {
     ID      = _ID;
     ExpType = _expType;
     TIV     = _tiv;
 }
Example #36
0
        public Subject(UniversalSubjectPosition universalSubject,
                       Schedule Schedule,
                       HashSet <SymbolicValue> CausesOfLoss,
                       HashSet <SymbolicValue> ExposuresTypes,
                       Dictionary <string, HashSet <long> > resolvedSchedule = null,
                       Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap = null,
                       bool Resolution = false)
        {
            SetID();

            this.UniversalSubject  = universalSubject;
            this.CoverageIdAttrMap = CoverageIdAttrMap;

            this.Schedule = Schedule;
            this.RITEIds  = new HashSet <long>();
            if (resolvedSchedule != null)
            {
                this.ResolvedSchedule = resolvedSchedule;

                foreach (SymbolicValue ScheduleSymbol in this.Schedule.ScheduleSymbols)
                {
                    if (ResolvedSchedule != null)
                    {
                        if (ResolvedSchedule.ContainsKey(ScheduleSymbol.ToString()))
                        {
                            RITEIds.UnionWith(ResolvedSchedule[ScheduleSymbol.ToString()]);
                        }
                    }
                }
            }

            //this.RiskItemIds = new HashSet<long>(this.RITEIds.Select(x => CoverageIdAttrMap[x].RITExposureId).Distinct());

            this.CausesOfLoss = CausesOfLoss;

            this.ExposureTypes         = ExposuresTypes;
            this.ResolvedExposureTypes = new HashSet <int>();
            foreach (SymbolicValue _ExposureType in ExposureTypes)
            {
                //ExposureType.ExposureTypeGroup ExposureTypeGroup = new ExposureType.ExposureTypeGroup();
                //ExposureTypeGroup.Set((ExposureType.EExposureType)(Enum.Parse(typeof(ExposureType.EExposureType), _ExposureType.ToString())));
                //ResolvedExposureTypes.UnionWith(ExposureTypeGroup.GetIndividualIntExposureTypes());
                //TODO : Use the above approach (3 lines of code) when platform is fixed and ready
                ResolvedExposureTypes.UnionWith(
                    ExposureType.GetIndividualIntExposureTypes(
                        (ExposureType.EExposureType)(Enum.Parse(typeof(ExposureType.EExposureType), _ExposureType.ToString()))
                        )
                    );
            }

            // If all dimensions are empty, then subject is not constrained

            if ((this.ResolvedExposureTypes.Count == 0) && (this.CausesOfLoss.Count == 0) && (this.RITEIds.Count == 0))
            {
                isNotConstrained = true;
            }

            // If any dimension is empty, set from universal subject

            if (UniversalSubject != null)
            {
                if (this.ResolvedExposureTypes.Count == 0)
                {
                    this.ResolvedExposureTypes = UniversalSubject.ResolvedExposureTypes;
                }

                if (this.CausesOfLoss.Count == 0)
                {
                    this.CausesOfLoss = UniversalSubjectPosition.CausesOfLoss;
                }

                if (this.RITEIds.Count == 0)
                {
                    this.RITEIds = UniversalSubject.AllRITEIds;
                }
            }

            this.PerRisk = Resolution;

            // Build components

            //Components = new HashSet<Tuple<int, long, SymbolicValue>>();
            Components = new Dictionary <SymbolicValue, Dictionary <int, Tuple <HashSet <long>, HashSet <long> > > >();

            if (this.RITEIds == null)
            {
                throw new NullReferenceException("Universal Subject RITEs cannot be null (can be empty)!");
            }
            if (this.RITEIds.Count != 0)
            {
                foreach (SymbolicValue CauseOfLoss in this.CausesOfLoss)
                {
                    if (!Components.ContainsKey(CauseOfLoss))
                    {
                        Components.Add(CauseOfLoss, new Dictionary <int, Tuple <HashSet <long>, HashSet <long> > >());
                    }
                    foreach (int ResolvedExposureType in this.ResolvedExposureTypes)
                    {
                        if (!Components[CauseOfLoss].ContainsKey(ResolvedExposureType))
                        {
                            Components[CauseOfLoss].Add(ResolvedExposureType, Tuple.Create(new HashSet <long>(), new HashSet <long>()));
                        }
                        foreach (long RITEId in this.RITEIds)
                        {
                            if (CoverageIdAttrMap.ContainsKey(RITEId) && CoverageIdAttrMap[RITEId].ExposureType.Equals(ResolvedExposureType))
                            {
                                Components[CauseOfLoss][ResolvedExposureType].Item1.Add(RITEId);
                            }
                            else
                            {
                                Components[CauseOfLoss][ResolvedExposureType].Item2.Add(RITEId);
                            }
                        }
                        if (Components[CauseOfLoss][ResolvedExposureType].Item1.Count == 0)
                        {
                            Components[CauseOfLoss].Remove(ResolvedExposureType);
                        }
                    }
                    if (Components[CauseOfLoss].Count == 0)
                    {
                        Components.Remove(CauseOfLoss);
                    }
                }
            }
        }