Example #1
0
        //this is the main method:
        public void UpdateVirusesStateOfThePatient(PatientStatistics o_PatientStatistics)
        {
            GenerateReproducmentProbability(); // determine what is the real probability by the parameters of number of viruses compared to the number of cells times the given growth constant
            int NumberOfVirusesThatReproduced = 0;

            foreach (Virus virus in VirusPopulation)
            {
                bool DoesTheVirusReproduced = virus.UpdateSelfStateAndCheckWhetherToReproduce(ReproducmentProbability, VirusDisconnectionProbability);
                if (DoesTheVirusReproduced)
                {
                    NumberOfVirusesThatReproduced++;
                }
            }
            // at the end of this phase, we add the new viruses that have been reproduced:
            for (int i = 0; i < NumberOfVirusesThatReproduced; i++)
            {
                VirusPopulation.Add(new Virus());
            }


            // at the end, lets make a new record for our statistics object:
            PatientDayRecord patientDayRecord = new PatientDayRecord(CalculateNumberOfAliveViruses(), CalculateNumberOfDeadViruses());

            o_PatientStatistics.DaysRecords.Add(patientDayRecord);
        }
Example #2
0
        public PatientStatistics RunSimulation(int i_NumberOfDays)
        {
            PatientStatistics patientStatistics = new PatientStatistics();

            if (Medications != null)
            {
                for (int i = 1; i <= i_NumberOfDays; i++)
                {
                    foreach (Medication medication in Medications)
                    {
                        if (medication.OnDay == i)
                        {
                            ThePatient.TakeMedication(medication.PeriodEffect);
                        }
                    }
                    ThePatient.UpdateVirusesStateOfThePatient(patientStatistics);
                }
                return(patientStatistics);
            }
            else
            {
                for (int i = 0; i < i_NumberOfDays; i++)
                {
                    ThePatient.UpdateVirusesStateOfThePatient(patientStatistics);
                }
                return(patientStatistics);
            }
        }
Example #3
0
        public void UpdateVirusesStateOfThePatient(PatientStatistics o_PatientStatistics)
        {
            GenerateReproducmentProbability();                   // determine what is the real probability by the parameters of number of viruses compared to the number of cells times the given growth constant
            List <Virus> ReproducedViruses = new List <Virus>(); // the viruses that have been reproduced in one (this) phase

            foreach (Virus virus in VirusPopulation)
            {
                Virus newVirus = virus.UpdateSelfStateAndCheckWhetherToReproduce(ReproducmentProbability);
                if (newVirus != null)
                {
                    ReproducedViruses.Add(newVirus);
                }
            }
            // at the end of this phase, we add the new viruses that have been reproduced:
            if (ReproducedViruses.Count > 0)
            {
                VirusPopulation.AddRange(ReproducedViruses);
            }
            // a day (iteration) has passed, so:
            ADayPass();
            // at the end, lets make a new record for our statistics object:
            PatientDayRecord patientDayRecord = new PatientDayRecord(CalculateNumberOfAliveViruses(), CalculateNumberOfDeadViruses());

            o_PatientStatistics.DaysRecords.Add(patientDayRecord);
        }
Example #4
0
        public PatientStatistics RunSimulation(int i_NumberOfDays)
        {
            PatientStatistics patientStatistics = new PatientStatistics();

            if (Medications != null)
            {
                for (int i = 1; i <= i_NumberOfDays; i++)
                {
                    if (Medications.Contains(i))
                    {
                        // in this day the patient should get medication.
                        ThePatient.TakeMedication();
                    }
                    ThePatient.UpdateVirusesStateOfThePatient(patientStatistics);
                }
                return(patientStatistics);
            }
            else
            {
                for (int i = 0; i < i_NumberOfDays; i++)
                {
                    ThePatient.UpdateVirusesStateOfThePatient(patientStatistics);
                }
                return(patientStatistics);
            }
        }
Example #5
0
        private void ShowStatisticalResults(PatientStatistics patientStatistics)
        {
            foreach (var series in chart1.Series)
            {
                series.Points.Clear();
            }
            for (int i = 1; i <= patientStatistics.DaysRecords.Count; i++)
            {
                chart1.Series["Alive Viruses"].Points.AddXY(i, patientStatistics.DaysRecords[i - 1].NumberOfAliveViruses);
                chart1.Series["Dead Viruses"].Points.AddXY(i, patientStatistics.DaysRecords[i - 1].NumberOfDeadViruses);
                chart1.Series["Cells"].Points.AddXY(i, 1000);
            }

            var seriesCollection = new SeriesCollection();

            var lineSeries = new LineSeries();

            //lineSeries.Name = "Alive Viruses";
            lineSeries.Stroke = System.Windows.Media.Brushes.Black;
            lineSeries.Fill   = System.Windows.Media.Brushes.Red;
            var chartValues = new ChartValues <ObservablePoint>();

            var lineSeries2  = new LineSeries();
            var chartValues2 = new ChartValues <ObservablePoint>();

            lineSeries2.Stroke = System.Windows.Media.Brushes.Black;
            lineSeries2.Fill   = System.Windows.Media.Brushes.Blue;

            var lineSeries3  = new LineSeries();
            var chartValues3 = new ChartValues <ObservablePoint>();

            lineSeries3.Stroke = System.Windows.Media.Brushes.Black;
            //lineSeries3.Fill = System.Windows.Media.Brushes.MediumSeaGreen;

            for (int i = 0; i < patientStatistics.DaysRecords.Count; i++)
            {
                //chart1.Series["Alive Viruses"].Points.AddXY(i, patientStatistics.DaysRecords[i].NumberOfAliveViruses);
                //chart1.Series["Dead Viruses"].Points.AddXY(i, patientStatistics.DaysRecords[i].NumberOfDeadViruses);
                //chart1.Series["Cells"].Points.AddXY(i, AmountOfCells);
                chartValues.Add(new ObservablePoint(i, patientStatistics.DaysRecords[i].NumberOfAliveViruses));
                chartValues2.Add(new ObservablePoint(i, patientStatistics.DaysRecords[i].NumberOfDeadViruses));
                chartValues3.Add(new ObservablePoint(i, 1000));
            }
            lineSeries.Values  = chartValues;
            lineSeries2.Values = chartValues2;
            lineSeries3.Values = chartValues3;
            seriesCollection.Add(lineSeries);
            seriesCollection.Add(lineSeries2);
            seriesCollection.Add(lineSeries3);
            cartesianChart1.Series = seriesCollection;
        }
Example #6
0
 private void buttonRunSimulation_Click(object sender, EventArgs e)
 {
     NumberOfDays = int.Parse(textBoxDays.Text);
     if (NumberOfDays > 0)
     {
         PatientStatistics patientStatistics = fetchSimulationResult();
         ShowStatisticalResults(patientStatistics);
     }
     else
     {
         MessageBox.Show("Some of the parameters that you have entered are not legal to the simulation!");
         MessageBox.Show("Simulation Canceled.");
     }
 }
 public PatientStatistics RunSimulation(int i_NumberOfDays)
 {
     if (IsEverythingInitializedCorrectly())
     {
         PatientStatistics patientStatistics = new PatientStatistics();
         for (int i = 0; i < i_NumberOfDays; i++)
         {
             ThePatient.UpdateVirusesStateOfThePatient(patientStatistics);
         }
         return(patientStatistics);
     }
     else
     {
         throw new Exception("Some parameters were not initialized correctly.. :( ");
     }
 }
Example #8
0
 private void ShowStatisticalResults(PatientStatistics patientStatistics)
 {
     foreach (var series in chart1.Series)
     {
         series.Points.Clear();
     }
     chart2.Series["s1"].Points.Clear();
     for (int i = 1; i <= patientStatistics.DaysRecords.Count; i++)
     {
         chart1.Series["Alive Viruses"].Points.AddXY(i, patientStatistics.DaysRecords[i - 1].NumberOfAliveViruses);
         //chart1.Series["Dead Viruses"].Points.AddXY(i, patientStatistics.DaysRecords[i - 1].NumberOfDeadViruses);
         chart1.Series["Cells"].Points.AddXY(i, 1000);
     }
     var size = patientStatistics.DaysRecords.Count;
     var record = patientStatistics.DaysRecords[size - 1];
     chart2.Series["s1"].Points.AddXY("Alive Viruses",record.NumberOfAliveViruses);
     chart2.Series["s1"].Points.AddXY("Healthy cells", 1000 - record.NumberOfAliveViruses);
 }
Example #9
0
        private void buttonRunSimulation_Click(object sender, EventArgs e)
        {
            AmountOfCells          = int.Parse(textBoxCells.Text);
            AmountOfInitialViruses = int.Parse(textBoxInitialViruses.Text);
            NumberOfDays           = int.Parse(textBoxDays.Text);
            int precentageDisconnection = int.Parse(textBoxDisconnection.Text);
            int precentageReproducment  = int.Parse(textBoxReproduction.Text);

            //converting to double:
            VirusDisconnectionProbability = (double)precentageDisconnection / 100;
            VirusGrowthProbability        = (double)precentageReproducment / 100;

            if (AmountOfInitialViruses > 0 && AmountOfCells > AmountOfInitialViruses && NumberOfDays > 0 & precentageDisconnection < 100 && precentageReproducment < 100)
            {
                PatientStatistics patientStatistics = fetchSimulationResult();
                ShowStatisticalResults(patientStatistics);
            }
            else
            {
                MessageBox.Show("Some of the parameters that you have entered are not legal to the simulation!");
                MessageBox.Show("Simulation Canceled.");
            }
        }