Пример #1
0
        public TrafficFlow(IDistributionLaw timeBetweenCarsGenerator, double probabilityOfStoppingAtGasStation)
        {
            this.timeBetweenCarsGenerator = timeBetweenCarsGenerator ?? throw new NullReferenceException();

            if (probabilityOfStoppingAtGasStation < 0 || probabilityOfStoppingAtGasStation > 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.probabilityOfStoppingAtGasStation = probabilityOfStoppingAtGasStation;
        }
        private void btnOpenModeling_Click(object sender, EventArgs e)
        {
            if (rbRandomFlow.Checked == true)
            {
                try
                {
                    switch (cbChooseDistributionLaw.SelectedIndex)
                    {
                    case (int)DistributionLaws.UniformDistribution:
                        randNumGenerator = new UniformDistribution((double)nudUniformDistParamA.Value, (double)nudUniformDistParamB.Value);
                        break;

                    case (int)DistributionLaws.NormalDistribution:
                        randNumGenerator = new NormalDistribution((double)nudNormalDistrExpectedValue.Value, (double)nudNormalDistrVariance.Value);
                        break;

                    case (int)DistributionLaws.ExponentialDistribution:
                        randNumGenerator = new ExponentialDistribution((double)nudExponentialDistrLambda.Value);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                    return;
                }
            }
            else
            {
                randNumGenerator = new DeterminedDistribution((double)nudDeterminedFlow.Value);
            }

            TrafficFlow trafficFlow = new TrafficFlow(randNumGenerator, (double)nudProbabilityOfStoppingAtGasStation.Value);

            ModelingForm modeling = new ModelingForm(topology, trafficFlow);

            modeling.Show();

            Dispose();
            Close();
        }