Пример #1
0
        private void Initialize()
        {
            this.InitializeStatusStrip();

            var  radius = (int)udRadius.Value;
            var  people = 1;
            byte steps  = (byte)udSteps.Value;

            this.TicksMax = (int)udTicks.Value;
            CoViD.CL.Person.IsolationThreshold = (byte)this.udIsolation.Value;


            this.regionL.SetXY(radius, "People");
            this.regionR.SetXY(radius, "Contamination");

            var tv = (this.TicksMax / 1);

            this.xyViruses.SetXY(
                0, tv, "0", tv.ToText(), "Ticks",
                0, 1, "0", 1.ToText(), ""
                );

            // ------------------------------------------------------------------------------------- //

            var population = new CoViD.CL.Population();

            for (int i = 0; i < people; i++)
            {
                var locations = new CoViD.CL.Locations(radius, steps);
                var person    = new CoViD.CL.Person(locations);
                person.Sneeze += this.Person_Sneeze;
                person.Inhale += this.Person_Inhale;

                population.Add(person);
            }

            // ------------------------------------------------------------------------------------- //

            var hospitals = new CoViD.CL.Hospitals()
            {
                new CoViD.CL.Hospital(new CoViD.CL.Point(radius, radius), 500)
            };

            this.Grid = new CoViD.CL.Grid(radius, population, hospitals);

            this.Grid.Remove += this.Grid_Remove;
            this.Grid.Add    += this.Grid_Add;

            // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX //
            // Simulate the sneeze of the first infected person. This creates a contaminated grid
            this.Grid.Contaminate(1000, new CoViD.CL.Point(0, 0));
            // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX //
        }
Пример #2
0
        /// <summary>
        /// Main Constructor: initializes the grid
        /// </summary>
        /// <param name="radius">The extention of the grid.</param>
        /// <param name="population">One instance of the Population object.</param>
        /// <param name="hospitals">The collection of Hospitals where people with 'severe' illnes are sent</param>
        public Grid(int radius, CoViD.CL.Population population, CoViD.CL.Hospitals hospitals)
        {
            this.IndexMax = (int)Math.Ceiling(((decimal)2 * (decimal)radius) / (decimal)100);
            int _radius = 50 * this.IndexMax;

            this.Contamination = new decimal[this.IndexMax, this.IndexMax];
            this.Contaminated  = new List <CoViD.CL.Point>();

            this.M  = (decimal)(this.IndexMax - 1) / ((decimal)2 * (decimal)_radius);
            this.Y0 = (decimal)_radius * this.M;


            this.Population = population;
            this.Hospitals  = hospitals;

            this.Radius = radius;
        }
Пример #3
0
		private void Initialize()
		{
			this.InitializeStatusStrip();

			var radius = (int)this.INICoViD.Radius; ;
			var people = this.INICoViD.People;
			byte steps = this.INICoViD.Steps; ;
			this.TicksMax = this.INICoViD.Ticks; ;

			this.tsPeople.Text = people.ToText();
			this.tsIsolation.Text = this.INICoViD.Isolation.ToText();

			this.regionL.SetXY(radius, "People");
			this.regionR.SetXY(radius, "Contamination");

			this.xySIR.SetXY(
				0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks",
				0, people, "0", people.ToText(), ""
			);

			int deltaMax = 10; /// (int)Math.Round((double)(people / (double)10));
			this.xyDSIR.SetXY(
				0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks",
				-deltaMax, deltaMax, (-deltaMax).ToText(), deltaMax.ToText(), ""
			);

			var y2Max = 4 * (radius / 100) * (radius / 100);
			this.xyContaminated.SetXY(
				0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks",
				0, y2Max, "0", y2Max.ToText(), "Contaminated grids"
			);

			this.xyPerformances.SetXY(
				0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks",
				0, 150, "0", 150.ToText(), "Milliseconds"
			);

			// ------------------------------------------------------------------------------------- //
			this.regionL.Cartesian.Clear();
			this.regionR.Cartesian.Clear();

			Application.DoEvents();
			// ------------------------------------------------------------------------------------- //

			var population = new CoViD.CL.Population();
			var locations0 = new CoViD.CL.Locations(radius, steps);
			var p0 = new CoViD.CL.Person(locations0);

			for (int i = 0; i < people; i++)
			{
				var locations = new CoViD.CL.Locations(radius, steps);
				var person = new CoViD.CL.Person(locations);

				person.Sneeze += this.Person_Sneeze;
				person.Inhale += this.Person_Inhale;

				population.Add(person);
			}

			// ------------------------------------------------------------------------------------- //

			var hospitals = new CoViD.CL.Hospitals(){
				new CoViD.CL.Hospital(new CoViD.CL.Point(radius, radius), 500)
			};

			this.Grid = new CoViD.CL.Grid(radius, population, hospitals);

			this.Grid.Remove += this.Grid_Remove;
			this.Grid.Add += this.Grid_Add;

			this.Contaminate();

		}