Ejemplo n.º 1
0
        public int getInterArrivalTimeByRandomRange(int randomNumber)
        {
            int arrivalTime = 0;

            for (int i = 0; i < InterarrivalDistribution.Count(); ++i)
            {
                int minRange = InterarrivalDistribution[i].MinRange, maxRange = InterarrivalDistribution[i].MaxRange;
                if (randomNumber >= minRange && randomNumber <= maxRange)
                {
                    arrivalTime = InterarrivalDistribution[i].Time;
                    break;
                }
            }
            return(arrivalTime);
        }
Ejemplo n.º 2
0
        ///////////// OPERATIONS /////////////
        public void CalculateInterArrivalTimeDistribution()
        {
            decimal oldProb  = 0;
            int     maxRange = 0;

            for (int i = 0; i < InterarrivalDistribution.Count(); ++i)
            {
                InterarrivalDistribution[i].CummProbability = oldProb + InterarrivalDistribution[i].Probability;
                oldProb = InterarrivalDistribution[i].CummProbability;

                InterarrivalDistribution[i].MinRange = maxRange + 1;

                maxRange = (int)(InterarrivalDistribution[i].CummProbability * 100);
                InterarrivalDistribution[i].MaxRange = maxRange;
            }
        }
        //===================================================================================================================
        //===============================CASE HANDLER (FOR NUMBER OF CUS OR TIME)=========================================
        public void GenerateRand(SimulationSystem s)
        {
            int RINER, RSERVICE_T;

            //=================FOR CEREATION NUMBER OF CUSTOMERS==========================
            if (s.StoppingCriteria == Enums.StoppingCriteria.NumberOfCustomers)
            {
                for (int i = 0; i < s.StoppingNumber; i++)
                {
                    RINER = Randomize();
                    SimulationTable.Add(new SimulationCase());
                    SimulationTable[i].RandomInterArrival = RINER;
                    countofcustomer++;
                }
                SimulationTable[0].InterArrival = 0;
                for (int x = 1; x < countofcustomer; x++)
                {
                    for (int i = 0; i < InterarrivalDistribution.Count(); i++)
                    {
                        if (SimulationTable[x].RandomInterArrival >= InterarrivalDistribution[i].MinRange && SimulationTable[x].RandomInterArrival <= InterarrivalDistribution[i].MaxRange)
                        {
                            SimulationTable[x].InterArrival = InterarrivalDistribution[i].Time;
                            break;
                        }
                    }
                }
                for (int i = 0; i < countofcustomer; i++)
                {
                    RSERVICE_T = Randomize();
                    SimulationTable[i].RandomService = RSERVICE_T;
                }
            }
            //=========================FOR CEREATION TIME============================================
            else if (s.StoppingCriteria == Enums.StoppingCriteria.SimulationEndTime)
            {
                while (shrouk <= s.StoppingNumber)
                {
                    RINER = Randomize();
                    SimulationTable.Add(new SimulationCase());
                    SimulationTable[countofcustomer].RandomInterArrival = RINER;
                    for (int i = 0; i < InterarrivalDistribution.Count(); i++)
                    {
                        if (SimulationTable[countofcustomer].RandomInterArrival >= InterarrivalDistribution[i].MinRange && SimulationTable[countofcustomer].RandomInterArrival <= InterarrivalDistribution[i].MaxRange)
                        {
                            SimulationTable[countofcustomer].InterArrival = InterarrivalDistribution[i].Time;
                            shrouk += SimulationTable[countofcustomer].InterArrival;
                            break;
                        }
                    }
                    if (shrouk == s.StoppingNumber)
                    {
                        countofcustomer++;
                        break;
                    }
                    countofcustomer++;
                }
            }
            for (int i = 0; i < countofcustomer; i++)
            {
                RSERVICE_T = Randomize();
                SimulationTable[i].RandomService = RSERVICE_T;
            }
        }