Ejemplo n.º 1
0
        public void calc_bearing()
        {
            Random rand  = new Random();
            int    index = 0;
            int    j;

            for (int i = 1; i <= NumberOfBearings; i++)
            {
                j = 0;
                while (true)
                {
                    CurrentSimulationCase Current_case = new CurrentSimulationCase();

                    Current_case.Bearing.Index = i;
                    int ran_hours = rand.Next(1, 101);
                    Current_case.Bearing.RandomHours = ran_hours;
                    for (int k = 0; k < BearingLifeDistribution.Count; k++)
                    {
                        if (ran_hours <= BearingLifeDistribution[k].MaxRange && ran_hours >= BearingLifeDistribution[k].MinRange)
                        {
                            Current_case.Bearing.Hours = BearingLifeDistribution[k].Time;
                            break;
                        }
                    }
                    if (j == 0)
                    {
                        Current_case.AccumulatedHours = Current_case.Bearing.Hours;
                    }
                    else
                    {
                        Current_case.AccumulatedHours = Current_case.Bearing.Hours + CurrentSimulationTable[index - 1].AccumulatedHours;
                    }

                    int ran_delay = rand.Next(1, 101);
                    Current_case.RandomDelay = ran_delay;
                    for (int k = 0; k < DelayTimeDistribution.Count; k++)
                    {
                        if (ran_delay <= DelayTimeDistribution[k].MaxRange && ran_delay >= DelayTimeDistribution[k].MinRange)
                        {
                            Current_case.Delay = DelayTimeDistribution[k].Time;
                            break;
                        }
                    }

                    CurrentSimulationTable.Add(Current_case);
                    index++;
                    if (Current_case.AccumulatedHours >= NumberOfHours)
                    {
                        break;
                    }
                    else
                    {
                        j++;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void fillSimulationTableForCurrent()
        {
            int SumOfDelayTime = 0;

            Sets = new List <int>();
            AccumulatedSetsNumbers = new List <int>();
            AccumulatedSetsNumbers.Add(0);

            //Console.WriteLine(AccumulatedSetsNumbers.Count.ToString());
            AccumulatedSetsNumbers[0] = 0;
            Random rand = new Random();
            CurrentSimulationCase row = new CurrentSimulationCase();

            for (int i = 0; i < NumberOfBearings; i++)
            {
                int cnt = 1;
                row = new CurrentSimulationCase();
                row.Bearing.Index       = i + 1;
                row.Bearing.RandomHours = rand.Next(1, 100);
                row.Bearing.Hours       = SearchForHours(row.Bearing.RandomHours, BearingLifeDistribution);
                row.AccumulatedHours    = row.Bearing.Hours;
                row.RandomDelay         = rand.Next(1, 100);
                row.Delay = SearchForHours(row.RandomDelay, DelayTimeDistribution);
                CurrentSimulationTable.Add(row);
                SumOfDelayTime += row.Delay;

                while (true)
                {
                    if (row.AccumulatedHours >= NumberOfHours)
                    {
                        break;
                    }


                    row = new CurrentSimulationCase();
                    row.Bearing.Index       = i + 1;
                    row.Bearing.RandomHours = rand.Next(1, 100);
                    row.Bearing.Hours       = SearchForHours(row.Bearing.RandomHours, BearingLifeDistribution);
                    row.AccumulatedHours    = row.Bearing.Hours + CurrentSimulationTable[CurrentSimulationTable.Count - 1].AccumulatedHours;
                    row.RandomDelay         = rand.Next(1, 100);
                    row.Delay = SearchForHours(row.RandomDelay, DelayTimeDistribution);
                    CurrentSimulationTable.Add(row);
                    SumOfDelayTime += row.Delay;
                    cnt++;
                }
                MaxNumOfSets = Math.Max(MaxNumOfSets, cnt);
                Sets.Add(cnt);
                AccumulatedSetsNumbers.Add(AccumulatedSetsNumbers[i] + Sets[i]);
            }
            CurrentPerformanceMeasures.BearingCost      = Convert.ToDecimal(CurrentSimulationTable.Count) * Convert.ToDecimal(BearingCost);
            CurrentPerformanceMeasures.DelayCost        = Convert.ToDecimal(SumOfDelayTime) * Convert.ToDecimal(DowntimeCost);
            CurrentPerformanceMeasures.DowntimeCost     = Convert.ToDecimal(CurrentSimulationTable.Count) * Convert.ToDecimal(RepairTimeForOneBearing) * Convert.ToDecimal(DowntimeCost);
            CurrentPerformanceMeasures.RepairPersonCost = Convert.ToDecimal(CurrentSimulationTable.Count) * Convert.ToDecimal(RepairTimeForOneBearing) * Convert.ToDecimal(RepairPersonCost) / Convert.ToDecimal(60);
            CurrentPerformanceMeasures.TotalCost        = CurrentPerformanceMeasures.BearingCost + CurrentPerformanceMeasures.DelayCost + CurrentPerformanceMeasures.DowntimeCost + CurrentPerformanceMeasures.RepairPersonCost;
        }
        public void GetCurrentMethodSimulation(SimulationSystem SimSystem, SimulationOutput SimOutput)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Index");
            dt.Columns.Add("Life RD");
            dt.Columns.Add("Life");
            dt.Columns.Add("Accumulated Life");
            dt.Columns.Add("Delay RD");
            dt.Columns.Add("Delay");
            Random rnd1 = new Random();
            Random rnd2 = new Random();
            int    NumberOfChangedBearings = 0;
            int    TotalDelayTime          = 0;
            int    start = 0;

            for (int i = 0; i < SimSystem.NumberOfBearings; i++)
            {
                int index            = 1;
                int AccumulatedHours = 0;
                int TotalDelay       = 0;
                while (AccumulatedHours < SimSystem.NumberOfHours)
                {
                    int RndLifeTime  = rnd1.Next(1, SimSystem.BearingLifeDistribution[SimSystem.BearingLifeDistribution.Count - 1].MaxRange);
                    int RndDelayTime = rnd2.Next(1, SimSystem.DelayTimeDistribution[SimSystem.DelayTimeDistribution.Count - 1].MaxRange);
                    int LifeTime     = GetTime(RndLifeTime, SimSystem.BearingLifeDistribution);
                    int DelayTime    = GetTime(RndDelayTime, SimSystem.DelayTimeDistribution);
                    AccumulatedHours += LifeTime;
                    TotalDelay       += DelayTime;
                    CurrentSimulationCase CSC = new CurrentSimulationCase();
                    Bearing bearing           = new Bearing();
                    bearing.Index        = i;
                    bearing.RandomHours  = RndLifeTime;
                    bearing.Hours        = LifeTime;
                    CSC.Bearing          = bearing;
                    CSC.AccumulatedHours = AccumulatedHours;
                    CSC.RandomDelay      = RndDelayTime;
                    CSC.Delay            = DelayTime;
                    SimSystem.CurrentSimulationCases.Add(CSC);
                    dt.Rows.Add(index.ToString(), RndLifeTime.ToString(), LifeTime.ToString(), AccumulatedHours.ToString(), RndDelayTime.ToString(), DelayTime.ToString());
                    index++;
                    NumberOfChangedBearings++;
                }
                dt.Rows.Add('-', '-', '-', '-', '-', TotalDelay.ToString());
                TotalDelayTime += TotalDelay;
                StartAndEnd.Add(new KeyValuePair <int, int>(start, (index - 2) + start));
                start = (index - 2) + start + 1;
            }
            SimOutput.CurrentSimulation            = dt;
            SimOutput.CurrentSimulationPerformance = GetCurrentMethodPerformance(SimSystem, NumberOfChangedBearings, TotalDelayTime);
        }
        private int replaceOneBearing(int index, int i, int b)
        {
            CurrentSimulationCase currentSimulationCase = new CurrentSimulationCase();

            currentSimulationCase.Bearing = getBearing(index, i);
            b += currentSimulationCase.Bearing.Hours;
            currentSimulationCase.AccumulatedHours = b;
            currentSimulationCase.RandomDelay      = r.Next(1, 101);//#TODO it should be 0 , 9 ??

            currentSimulationCase.Delay = getDelay(currentSimulationCase.RandomDelay);

            CurrentSimulationTable.Add(currentSimulationCase);
            return(b);
        }
Ejemplo n.º 5
0
        public List <CurrentSimulationCase> GenerateCurrentSimulationCase()
        {
            List <CurrentSimulationCase> ret = new List <CurrentSimulationCase>();

            for (int i = 0; i < NumberOfBearings; i++)
            {
                int accumulateTime = 0;
                for (int j = 0; accumulateTime < NumberOfHours; j++)
                {
                    Bearing ring        = _listOfRandomizedBearings[j * NumberOfBearings + i];
                    int     randomDelay = GetDelayRand();
                    int     delay       = GetTime(randomDelay, DelayTimeDistribution);
                    accumulateTime += ring.Hours;
                    CurrentSimulationCase cs = new CurrentSimulationCase();
                    cs.Bearing          = ring;
                    cs.Delay            = delay;
                    cs.RandomDelay      = randomDelay;
                    cs.AccumulatedHours = accumulateTime;
                    ret.Add(cs);
                }
            }
            return(ret);
        }
Ejemplo n.º 6
0
        public void simulate()
        {
            Random rnd = new Random();

            List <Bearing> [] my_bears = new List <Bearing> [NumberOfBearings];

            for (int i = 0; i < NumberOfBearings; i++)
            {
                int accum = 0;
                my_bears[i] = new List <Bearing>();
                while (accum < NumberOfHours)
                {
                    CurrentSimulationCase curbear = new CurrentSimulationCase();
                    curbear.Bearing.Index       = i + 1;
                    curbear.Bearing.RandomHours = rnd.Next(1, 100);
                    curbear.Bearing.Hours       = life_dist(curbear.Bearing.RandomHours);

                    accum = accum + curbear.Bearing.Hours;

                    curbear.AccumulatedHours              = accum;
                    curbear.RandomDelay                   = rnd.Next(1, 100);
                    curbear.Delay                         = delay_dist(curbear.RandomDelay);
                    CurrentPerformanceMeasures.DelayCost += (decimal)curbear.Delay * DowntimeCost;
                    my_bears[i].Add(curbear.Bearing);
                    CurrentSimulationTable.Add(curbear);
                }
            }
            CurrentPerformanceMeasures.BearingCost  = (decimal)CurrentSimulationTable.Count * BearingCost;
            CurrentPerformanceMeasures.DowntimeCost = (decimal)CurrentSimulationTable.Count * RepairTimeForOneBearing * DowntimeCost;
            decimal nrcost = (decimal)RepairPersonCost / 60;

            CurrentPerformanceMeasures.RepairPersonCost = (decimal)(CurrentSimulationTable.Count * RepairTimeForOneBearing) * nrcost;
            CurrentPerformanceMeasures.TotalCost        = (decimal)CurrentPerformanceMeasures.BearingCost + CurrentPerformanceMeasures.DelayCost
                                                          + CurrentPerformanceMeasures.DowntimeCost + CurrentPerformanceMeasures.RepairPersonCost;

            sec_step(my_bears);
        }
        public void CurrentSimulation()
        {
            totalCurrentDelayTime = 0;
            int accumulatedHours;

            for (int i = 0; i < NumberOfBearings; i++)
            {
                accumulatedHours = 0;
                for (int j = 0; j < bearings[i].Count(); j++)
                {
                    CurrentSimulationCase currentCase = new CurrentSimulationCase();
                    currentCase.Bearing.Hours       = bearings[i][j].Hours;
                    currentCase.Bearing.RandomHours = bearings[i][j].RandomHours;
                    currentCase.Bearing.Index       = bearings[i][j].Index;
                    accumulatedHours            += currentCase.Bearing.Hours;
                    currentCase.AccumulatedHours = accumulatedHours;
                    Tuple <int, int> delay = HelperFunctions.GetBearingRandomNumbers("Delay", DelayTimeDistribution);
                    currentCase.RandomDelay = delay.Item1;
                    currentCase.Delay       = delay.Item2;
                    CurrentSimulationTable.Add(currentCase);
                    totalCurrentDelayTime += currentCase.Delay;
                }
            }
        }