public VaccinationSimulation(MonteCarloSettings monteCarloSettings, EventSimulationSettings eventSimulationSettings, VaccinationSettings vaccinationSettings) : base(monteCarloSettings, eventSimulationSettings) { VaccinSettings = vaccinationSettings; _afterEventObservables = new SimulationObservable <AfterEventValues>(); _afterReplicationObservables = new SimulationObservable <AfterReplicationValues>(); _experimentObservables = new SimulationObservable <DoctorsExperimentValues>(); ExaminationGen = new ExponentialGenerator(1d / 260); VaccinationGen = new TriangularGenerator(20, 100, 75); RegistrationGen = new UniformGenerator(140, 220); WaitingGen = new Random(); PatientsGen = new Random(); ArrivalGen = new Random(); if (VaccinSettings.DoctorsExperimentEnabled) { MCSettings.Replications = (VaccinSettings.DoctorsMax - VaccinSettings.DoctorsMin + 1) * VaccinSettings.ExperimentReplications; _currentDoctorsCount = VaccinSettings.DoctorsMin; } Init(); }
private async void GenerateButton_Click(object sender, EventArgs e) { string distribution = DistributionComboBox.SelectedItem.ToString(); int count = (int)CountInput.Value; int seed = (int)SeedInput.Value; int multiplier = (int)MultiplierInput.Value; int range = (int)RangeInput.Value; bool showAllNumbers = !DisplayedNumbersLimiter.Checked; IGenerator generator; MLCG generatorMLCG = new MLCG(seed, multiplier, range); ClearComponents(); GeneratingProgress.Maximum = count; switch (distribution) { case "Uniform": generator = new UniformGenerator(Input1.Value, Input2.Value, generatorMLCG); break; case "Gauss": generator = new GaussGenerator(Input1.Value, Input2.Value, Input3.Value, count, generatorMLCG); break; case "Exponential": generator = new ExponentialGenerator(Input1.Value, generatorMLCG); break; case "Gamma": generator = new GammaGenerator(Input1.Value, Input2.Value, count, generatorMLCG); break; case "Triangular": generator = new TriangularGenerator(Input1.Value, Input2.Value, TriangularMinCheckBox.Checked, count, generatorMLCG); break; case "Simpson": generator = new SimpsonGenerator(Input1.Value, Input2.Value, count, generatorMLCG); break; default: generator = generatorMLCG; break; } await Task.Factory.StartNew(() => { ProgressStage("Generating numbers..."); for (int i = 0; i < count; i++) { if (showAllNumbers || i < 100) { string row = $"{i + 1}. {generator.NextNumber()}"; ExecuteInUIThread(() => NumbersList.Items.Add(row)); } else { generator.NextNumber(); } ExecuteInUIThread(() => GeneratingProgress.Value++); } ProgressStage("Calculating statistics..."); Calculations calculations = new Calculations(generator); AddToOutputBox($"M = {calculations.ExpectedValue:F5}"); AddToOutputBox($"D = {calculations.Variance:F5}"); AddToOutputBox($"σ = {calculations.StandardDeviation:F5}"); ProgressStage("Building plot..."); calculations.BuildHistogram(Plot.plt); Plot.Render(); ProgressStage("Complete."); }); }