コード例 #1
0
ファイル: struct.cs プロジェクト: ferib/Apocalytics
 public PredictionMath(string country, HivNumber hivNumber, string year, wpopulation wpop)
 {
     this.value                = new List <HivNumber>();
     this.year                 = new List <int>();
     this.IncreaseProcent      = new List <decimal>();
     this.WorldIncreaseProcent = new List <decimal>();
     this.WorldProcent         = new List <decimal>();
     this.wpop                 = wpop;
     this.country              = country;
     this.value.Add(hivNumber);
     this.year.Add(Convert.ToInt32(year));
     this.outbreakScore = 0;
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: ferib/Apocalytics
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var         obj  = JsonConvert.DeserializeObject <DataSetObj>(File.ReadAllText("dataset/hiv.json"));
            wpopulation wpop = new wpopulation("dataset/WorldPopulation.csv");

            List <PredictionMath> Calculations = new List <PredictionMath>();

            Console.WriteLine("Read?");
            Console.ReadKey();

            foreach (var o in obj.fact)
            {
                o.ValueFixed = new HivNumber(o.Value); //fix values
                Console.WriteLine($"{o.ValueFixed.average} - {o.dims.COUNTRY} - {o.dims.GHO} - {o.dims.YEAR}");

                PredictionMath CurrentMath = Calculations.Find(x => x.country == o.dims.COUNTRY);
                if (CurrentMath == null)
                {
                    Calculations.Add(new PredictionMath(o.dims.COUNTRY, o.ValueFixed, o.dims.YEAR, wpop));
                }

                else
                {
                    CurrentMath.value.Add(o.ValueFixed);
                    CurrentMath.year.Add(Convert.ToInt32(o.dims.YEAR));
                }
            }

            foreach (var c in Calculations)
            {
                c.CalculateDiffrence();

                for (int i = 0; i < c.year.Count; i++)
                {
                    if (c.year[i] == c.year.Max()) //start jaar
                    {
                        Console.WriteLine($"{c.country}: {c.year[i]}: kills: {c.value[i].average}/{c.wpop.GetCountryMax(c.country, c.year[i])} ({c.WorldProcent[i].ToString("0.0000")}%)");
                    }
                    else
                    {
                        Console.WriteLine($"{c.country}: {c.year[i]}: kills: {c.value[i].average}/{c.wpop.GetCountryMax(c.country, c.year[i])} ({c.WorldProcent[i].ToString("0.0000")}%), Change: {c.IncreaseProcent[i].ToString("0.0000")}%");
                    }
                }
                Console.WriteLine("--------------------------------------");
            }

            FindOutbreakCountry(Calculations);

            //while (true)
            //{
            //Console.WriteLine("Calculate next decenia");
            Console.ReadKey();

            foreach (var c in Calculations)
            {
                c.CalculateNextDecenia();

                for (int i = 0; i < c.year.Count; i++)
                {
                    if (c.year[i] == c.year.Min())     //start jaar
                    {
                        Console.WriteLine($"{c.country}: {c.year[i]}: kills: {c.value[i].average}/{c.wpop.GetCountryMax(c.country, c.year[i])} ({c.WorldProcent[i].ToString("0.0000")}%)");
                    }
                    else
                    {
                        Console.WriteLine($"{c.country}: {c.year[i]}: kills: {c.value[i].average}/{c.wpop.GetCountryMax(c.country, c.year[i])} ({c.WorldProcent[i].ToString("0.0000")}%), Change: {c.IncreaseProcent[i].ToString("0.0000")}%");
                    }
                }
                Console.WriteLine("--------------------------------------");
            }
            //}

            MergerPredictions(Calculations, ref obj);
            string DatasetString = JsonConvert.SerializeObject(obj);

            File.WriteAllText("dataset/hiv_predict.json", DatasetString);
            File.WriteAllText("dataset/hiv_predict.csv", ConvertToCsv(Calculations));

            Console.WriteLine("Done!");
            Console.ReadKey();
        }