示例#1
0
        public List <CoronaPatient> infect(Random r, CoronaParameter c)
        {
            List <CoronaPatient> infect_list = new List <CoronaPatient>();

            if (this.care_level < 4)
            {
                for (int i = 0; i < contact_number; i++)
                {
                    CoronaPatient contact_p = new CoronaPatient(r, c);
                    if (contact_p.health_factor < 0.5)
                    {
                        contact_p.health_factor += 0.5;
                    }
                    contact_p.care_level     = 1;   //感染されたばかりではなにもしない
                    contact_p.serious_factor = 0.1; //発症したばかりではひどくない

                    double infect_rate = activitiy_factor * train_fator * room_factor * serious_factor * (1.0 - use_mask) * (1.0 - contact_p.health_factor) * (1.0 - contact_p.use_mask);

                    if (dice(r, infect_rate) == 1)
                    {
                        infected_number++;
                        infect_list.Add(contact_p);
                    }
                    ;
                }

                for (int i = 0; i < family_number; i++)
                {
                    CoronaPatient family_p = new CoronaPatient(r, c);
                    family_p.family_id      = id;
                    family_p.source_id      = id;
                    family_p.care_level     = 1;   //感染されたばかりではなにもしない
                    family_p.serious_factor = 0.1; //発症したばかりではひどくない
                    if (family_p.health_factor < 0.5)
                    {
                        family_p.health_factor += 0.5;
                    }

                    double family_infect_rate = room_factor * 2 * serious_factor * (1.0 - family_p.health_factor);

                    if (dice(r, family_infect_rate) == 1)
                    {
                        infected_number++;
                        infect_list.Add(family_p);
                    }
                }
            }

            this.day++;

            return(infect_list);
        }
示例#2
0
        static void Main(string[] args)
        {
            //-----コマンドライン処理-------------
            string[] cmds = System.Environment.GetCommandLineArgs();

            //パラメータ識別
            for (int i = 0; i < cmds.Length; i++)
            {
                if (cmds[i].Trim() == "/org_num")
                {
                    if (cmds.Length - 1 >= i + 1) //パラメータが存在するなら
                    {
                        org_patient_number = int.Parse(cmds[i + 1].Trim());
                    }

                    Console.WriteLine("numbers of patient at first phase: " + org_patient_number.ToString());
                }
                else if (cmds[i].Trim() == "/bed")
                {
                    if (cmds.Length - 1 >= i + 1) //パラメータが存在するなら
                    {
                        g.bed_count = int.Parse(cmds[i + 1].Trim());
                    }

                    Console.WriteLine("Hostipal's bed count at all: " + g.bed_count.ToString());
                }
                else if (cmds[i].Trim() == "/death_rate")
                {
                    if (cmds.Length - 1 >= i + 1) //パラメータが存在するなら
                    {
                        c.death_rate = double.Parse(cmds[i + 1].Trim());
                    }

                    Console.WriteLine("Death rate: " + c.death_rate);
                }
                else if (cmds[i].Trim() == "/death_rate2")
                {
                    if (cmds.Length - 1 >= i + 1) //パラメータが存在するなら
                    {
                        c.death_rate_no_bed = double.Parse(cmds[i + 1].Trim());
                    }

                    Console.WriteLine("Death rate when not be hospitalized: " + c.death_rate_no_bed);
                }
                else if (cmds[i].Trim() == "/contact_number")
                {
                    if (cmds.Length - 1 >= i + 1) //パラメータが存在するなら
                    {
                        c.max_contact_number = int.Parse(cmds[i + 1].Trim());
                    }

                    Console.WriteLine("Max contact number: " + c.max_contact_number);
                }
            }
            //-----コマンドライン処理-------------

            for (int i = 0; i < org_patient_number; i++)
            {
                CoronaPatient new_p = new CoronaPatient(r, c);
                new_p.id             = p_list.Count;
                new_p.family_id      = p_list.Count;
                new_p.care_level     = 1;   //感染されたばかりではなにもしない
                new_p.serious_factor = 0.1; //発症したばかりではひどくない
                p_list.Add(new_p);
            }

            Console.WriteLine("DAY:" + day.ToString() + " patient_number:" + p_list.Count);
            Console.WriteLine(" complete_cured:" + complete_cure_count.ToString() + " dead:" + dead_count.ToString());


            for (int j = 0; j < 100; j++)
            {
                int    today_infect_sum    = 0;
                int    today_mask_sum      = 0;
                int    today_mask_predict  = (int)(yesterday_mask_sum * mask_step_rate);
                double r0_mean             = 0;
                int    all_infected_number = 0;
                int    care_level_4_count  = 0;


                for (int i = 0; i < p_list.Count; i++)
                {
                    if (p_list[i].dead == 0 && p_list[i].complete_cure == 0)
                    {
                        List <CoronaPatient> new_list = p_list[i].infect(r, c);
                        dead_count              += p_list[i].sick_step(r, c);
                        complete_cure_count     += p_list[i].complete_cure_step();
                        today_infect_sum        += p_list[i].use_mask;
                        p_list[i].contact_number = (int)(p_list[i].contact_number * contact_step_rate);

                        if (p_list[i].care_level >= 4)
                        {
                            care_level_4_count += 1;
                        }

                        if (new_list.Count > 0)
                        {
                            today_infect_sum += new_list.Count;
                            //Console.WriteLine("ID:" + i.ToString() + " infected " + new_list.Count.ToString() + " peoples");
                            p_list.AddRange(new_list);
                        }
                    }



                    if (i < 100) //r0は死亡と関係ない
                    {
                        all_infected_number += p_list[i].infected_number;
                    }

                    r0_mean = (double)all_infected_number / 100;
                }

                if (care_level_4_count > g.bed_count)
                {
                    c.org_death_rate = c.death_rate;
                    c.death_rate     = c.death_rate_no_bed;
                }
                else
                {
                    c.death_rate = c.org_death_rate;
                }

                in_hospital_sum = care_level_4_count;

                if (in_hospital_sum > g.bed_count)
                {
                    in_hospital_sum = g.bed_count;
                }

                c.left_bed_count = g.bed_count - in_hospital_sum;

                yesterday_mask_sum = today_mask_sum;

                day++;
                Console.WriteLine("---");
                Console.WriteLine("DAY:" + day.ToString() + " patient_number:" + p_list.Count + " in_hospital:" + in_hospital_sum.ToString());
                Console.WriteLine("infected:" + today_infect_sum.ToString() + " R0_mean:" + r0_mean.ToString("N2") + " cured:" + complete_cure_count.ToString() + " dead:" + dead_count.ToString());

                //list_patient(0, p_list.Count - 1);
                Console.ReadKey();
            }
        }