예제 #1
0
        private void IncubationEndsSevere(Human agent, IRandomProvider random)
        {
            agent.SevereToHospital = random.Chance(Parameters.PropStoH);
            var meanTimeToAdmission = agent.SevereToHospital ? Parameters.TimeStoH : Parameters.TimeStoC;
            var progressionRate     = 1d / meanTimeToAdmission;

            agent.DaysIsolated = random.SampleDaysInState(progressionRate);
        }
예제 #2
0
        private void PersonMovedToIcu(Human agent, IRandomProvider random)
        {
            agent.DiesInIcu = random.Chance(Parameters.PropDieInIcu);
            var meanTimeInIcu = agent.DiesInIcu ? Parameters.TimeCtoD : Parameters.TimeCtoR;
            var rateOfExit    = 1d / meanTimeInIcu;

            agent.DaysInIntensiveCare = random.SampleDaysInState(rateOfExit);
        }
예제 #3
0
        public Task <IDelayedMessage[]> Pull(string channel, string key = null, int?max = null)
        {
            var discovered = pullFromMemCache(channel, key, max);

            //// Check empty key store too, 10% of the time
            if (_random.Chance(10) && !string.IsNullOrEmpty(key))
            {
                var nonSpecific = pullFromMemCache(channel, null, max);
                discovered = discovered.Concat(nonSpecific).ToArray();
            }

            return(Task.FromResult(discovered));
        }
예제 #4
0
        public override bool InfectionOccurs(SirAgent carrierAgent, Encounter <SirAgent> encounter, IRandomProvider random)
        {
            var sirContext = (SirContext)encounter.Agent.HomeArea;

            var p = sirContext.ProbabilityOfInfection;

            if (p < 0d || p > 1d)
            {
                throw new InvalidOperationException("Probability must be in [0, 1]");
            }

            return(random.Chance(p));
        }
예제 #5
0
        public override bool InfectionOccurs(Human carrierAgent, Encounter <Human> encounter, IRandomProvider randomProvider)
        {
            var p = _infectiousness(carrierAgent);

            return(randomProvider.Chance(p));
        }