Пример #1
0
        public void InitBearings()
        {
            _listOfRandomizedBearings = new List <Bearing>();
            int accumulativeTime = 0;

            while (accumulativeTime < NumberOfHours)
            {
                int min = -1;
                for (int i = 0; i < NumberOfBearings; i++)
                {
                    int     randomHours = GetBearingRand();
                    int     hours       = GetTime(randomHours, BearingLifeDistribution);
                    int     index       = i;
                    Bearing ring        = new Bearing();
                    ring.Index       = index;
                    ring.RandomHours = randomHours;
                    ring.Hours       = hours;
                    _listOfRandomizedBearings.Add(ring);
                    if (min == -1 || hours < min)
                    {
                        min = hours;
                    }
                }
                accumulativeTime += min;
            }
        }
        private Bearing getBearing(int index, int i)
        {
            Bearing bearing = new Bearing();

            bearing.Index       = index + 1;
            bearing.RandomHours = randomHours[index][i];
            bearing.Hours       = getBearingLifeTime(bearing.RandomHours);
            return(bearing);
        }
        public void ProposedSimulation()
        {
            int totalAccumlatedHours = 0;
            int row = 0;

            while (totalAccumlatedHours < NumberOfHours)
            {
                ProposedSimulationCase proposedSimulationCase = new ProposedSimulationCase();
                proposedSimulationCase.FirstFailure = BearingLifeDistribution[BearingLifeDistribution.Count - 1].Time + 100;

                List <Bearing> currentBearings = new List <Bearing>();

                for (int i = 0; i < NumberOfBearings; i++)
                {
                    Bearing bearing = new Bearing();

                    if (row < bearingMaximumChanges[i])
                    {
                        bearing = bearings[i][row];
                    }
                    else
                    {
                        //Generate new bearing
                        bearing.Index = i + 1;
                        Tuple <int, int> lifeHours = HelperFunctions.GetBearingRandomNumbers("Life", BearingLifeDistribution);
                        bearing.RandomHours = lifeHours.Item1;
                        bearing.Hours       = lifeHours.Item2;
                    }
                    if (bearing.Hours < proposedSimulationCase.FirstFailure)
                    {
                        proposedSimulationCase.FirstFailure = bearing.Hours;
                    }
                    currentBearings.Add(bearing);
                }

                proposedSimulationCase.Bearings = currentBearings;

                TotalProposedBearings += currentBearings.Count;
                proposedBearingsSet   += 1;

                Tuple <int, int> delayVariables = HelperFunctions.GetBearingRandomNumbers("Delay", DelayTimeDistribution);

                proposedSimulationCase.RandomDelay = delayVariables.Item1;
                proposedSimulationCase.Delay       = delayVariables.Item2;

                totalProposedDelayTime += proposedSimulationCase.Delay;

                totalAccumlatedHours += proposedSimulationCase.FirstFailure;
                proposedSimulationCase.AccumulatedHours = totalAccumlatedHours;

                ProposedSimulationTable.Add(proposedSimulationCase);
                row++;
            }
        }
Пример #4
0
        public void sec_step(List <Bearing>[] mylist)
        {
            Random rnd = new Random();
            int    acc = 0;

            for (int j = 0; acc < NumberOfHours; j++)
            {
                ProposedSimulationCase prp = new ProposedSimulationCase();
                prp.Bearings = new List <Bearing>();
                int first_fail = NumberOfHours;
                for (int k = 0; k < NumberOfBearings; k++)
                {
                    if (mylist[k].Count > j)
                    {
                        prp.Bearings.Add(mylist[k][j]);
                        if (first_fail > prp.Bearings[k].Hours)
                        {
                            first_fail = prp.Bearings[k].Hours;
                        }
                    }
                    else
                    {
                        Bearing curbear = new Bearing();
                        curbear.Index       = k + 1;
                        curbear.RandomHours = rnd.Next(1, 100);
                        curbear.Hours       = life_dist(curbear.RandomHours);
                        prp.Bearings.Add(curbear);
                        if (first_fail > prp.Bearings[k].Hours)
                        {
                            first_fail = prp.Bearings[k].Hours;
                        }
                    }
                }
                prp.AccumulatedHours = acc;
                prp.FirstFailure     = first_fail;
                acc += first_fail;
                prp.AccumulatedHours = acc;
                prp.RandomDelay      = rnd.Next(1, 100);
                prp.Delay            = delay_dist(prp.RandomDelay);
                ProposedPerformanceMeasures.DelayCost += (decimal)prp.Delay * DowntimeCost;

                ProposedSimulationTable.Add(prp);
            }

            ProposedPerformanceMeasures.BearingCost  = (decimal)ProposedSimulationTable.Count * NumberOfBearings * BearingCost;
            ProposedPerformanceMeasures.DowntimeCost = (decimal)ProposedSimulationTable.Count * RepairTimeForAllBearings * DowntimeCost;
            decimal nrcost = (decimal)RepairPersonCost / 60;

            ProposedPerformanceMeasures.RepairPersonCost = (decimal)(ProposedSimulationTable.Count * RepairTimeForAllBearings) * nrcost;
            ProposedPerformanceMeasures.TotalCost        = (decimal)ProposedPerformanceMeasures.BearingCost + ProposedPerformanceMeasures.DelayCost
                                                           + ProposedPerformanceMeasures.DowntimeCost + ProposedPerformanceMeasures.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);
        }
 public void GenerateBearings()
 {
     for (int i = 0; i < NumberOfBearings; i++)
     {
         List <Bearing> currentList      = new List <Bearing>();
         int            accumulatedHours = 0;
         while (accumulatedHours < NumberOfHours)
         {
             Bearing currentBering = new Bearing();
             currentBering.Index = i + 1;
             Tuple <int, int> lifeHours = HelperFunctions.GetBearingRandomNumbers("Life", BearingLifeDistribution);
             currentBering.RandomHours = lifeHours.Item1;
             currentBering.Hours       = lifeHours.Item2;
             currentList.Add(currentBering);
             accumulatedHours += currentBering.Hours;
         }
         bearings.Add(currentList);
         bearingMaximumChanges.Add(currentList.Count());
     }
 }
Пример #7
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);
        }
        public void GetProposedMethodSimulation(SimulationSystem SimSystem, SimulationOutput SimOutput)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Index");
            for (int i = 0; i < SimSystem.NumberOfBearings; i++)
            {
                dt.Columns.Add("Bearing " + (i + 1).ToString() + " Life");
            }
            dt.Columns.Add("First Failure");
            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    AccumulatedHours        = 0;
            int    index = 1;

            while (AccumulatedHours < SimSystem.NumberOfHours)
            {
                List <Bearing> Bearings = new List <Bearing>();
                NumberOfChangedBearings++;
                int MnLife = 99999999;
                for (int i = 0; i < SimSystem.NumberOfBearings; i++)
                {
                    if ((StartAndEnd[i].Key + (index - 1)) <= StartAndEnd[i].Value)
                    {
                        Bearings.Add(SimSystem.CurrentSimulationCases[StartAndEnd[i].Key + (index - 1)].Bearing);
                        if (SimSystem.CurrentSimulationCases[StartAndEnd[i].Key + (index - 1)].Bearing.Hours < MnLife)
                        {
                            MnLife = SimSystem.CurrentSimulationCases[StartAndEnd[i].Key + (index - 1)].Bearing.Hours;
                        }
                    }
                    else
                    {
                        int     RndLifeTime = rnd1.Next(1, SimSystem.BearingLifeDistribution[SimSystem.BearingLifeDistribution.Count - 1].MaxRange);
                        int     LifeTime    = GetTime(RndLifeTime, SimSystem.BearingLifeDistribution);
                        Bearing bearing     = new Bearing();
                        bearing.Index       = i;
                        bearing.RandomHours = RndLifeTime;
                        bearing.Hours       = LifeTime;
                        Bearings.Add(bearing);
                        if (LifeTime < MnLife)
                        {
                            MnLife = LifeTime;
                        }
                    }
                }
                AccumulatedHours += MnLife;
                int RndDelayTime = rnd2.Next(1, SimSystem.DelayTimeDistribution[SimSystem.DelayTimeDistribution.Count - 1].MaxRange);
                int DelayTime    = GetTime(RndDelayTime, SimSystem.DelayTimeDistribution);
                TotalDelayTime += DelayTime;
                ProposedSimulationCase PSC = new ProposedSimulationCase();
                PSC.Bearings         = Bearings;
                PSC.FirstFailure     = MnLife;
                PSC.AccumulatedHours = AccumulatedHours;
                PSC.RandomDelay      = RndDelayTime;
                PSC.Delay            = DelayTime;
                SimSystem.ProposedSimulationCases.Add(PSC);
                DataRow dr = dt.NewRow();
                dr["Index"] = index.ToString();
                for (int i = 0; i < Bearings.Count(); i++)
                {
                    string name = "Bearing " + (i + 1).ToString() + " Life";
                    dr[name] = Bearings[i].Hours.ToString();
                }
                dr["First Failure"]    = MnLife.ToString();
                dr["Accumulated Life"] = AccumulatedHours.ToString();
                dr["Delay RD"]         = RndDelayTime.ToString();
                dr["Delay"]            = DelayTime.ToString();
                dt.Rows.Add(dr);
                index++;
            }
            DataRow rw = dt.NewRow();

            rw["Index"] = "-";
            for (int i = 0; i < SimSystem.NumberOfBearings; i++)
            {
                string name = "Bearing " + (i + 1).ToString() + " Life";
                rw[name] = "-";
            }
            rw["First Failure"]    = "-";
            rw["Accumulated Life"] = "-";
            rw["Delay RD"]         = "-";
            rw["Delay"]            = TotalDelayTime.ToString();
            dt.Rows.Add(rw);
            SimOutput.ProposedSimulation            = dt;
            SimOutput.ProposedSimulationPerformance = GetProposedMethodPerformance(SimSystem, NumberOfChangedBearings, TotalDelayTime);
        }
Пример #9
0
        public void fillSimulationTableForProposed()
        {
            int    SumOfDelayTime      = 0;
            int    min                 = 1000000;
            Random rand                = new Random();
            ProposedSimulationCase row = new ProposedSimulationCase();

            for (int j = 0; j < NumberOfBearings; j++)
            {
                Bearing bearing = new Bearing();
                bearing.Index       = j + 1;
                bearing.RandomHours = CurrentSimulationTable[AccumulatedSetsNumbers[j]].Bearing.RandomHours;
                bearing.Hours       = CurrentSimulationTable[AccumulatedSetsNumbers[j]].Bearing.Hours;
                row.Bearings.Add(bearing);
                if (min > bearing.Hours)
                {
                    min = bearing.Hours;
                }
            }
            row.FirstFailure     = min;
            row.AccumulatedHours = row.FirstFailure;
            row.RandomDelay      = rand.Next(1, 100);
            row.Delay            = SearchForHours(row.RandomDelay, DelayTimeDistribution);
            ProposedSimulationTable.Add(row);
            SumOfDelayTime += row.Delay;
            min             = 100000;
            int i = 1;

            while (ProposedSimulationTable[i - 1].AccumulatedHours <= NumberOfHours)
            {
                row = new ProposedSimulationCase();

                for (int j = 0; j < NumberOfBearings; j++)
                {
                    Bearing bearing = new Bearing();
                    bearing.Index = j + 1;
                    if (AccumulatedSetsNumbers[j] + i < AccumulatedSetsNumbers[j + 1])
                    {
                        bearing.RandomHours = CurrentSimulationTable[AccumulatedSetsNumbers[j] + i].Bearing.RandomHours;
                        bearing.Hours       = CurrentSimulationTable[AccumulatedSetsNumbers[j] + i].Bearing.Hours;
                        row.Bearings.Add(bearing);
                    }
                    else
                    {
                        bearing.RandomHours = rand.Next(1, 100);
                        bearing.Hours       = SearchForHours(bearing.RandomHours, BearingLifeDistribution);
                        row.Bearings.Add(bearing);
                    }
                    if (min > bearing.Hours)
                    {
                        min = bearing.Hours;
                    }
                }
                row.FirstFailure     = min;
                row.AccumulatedHours = row.FirstFailure + ProposedSimulationTable[i - 1].AccumulatedHours;
                row.RandomDelay      = rand.Next(1, 100);
                row.Delay            = SearchForHours(row.RandomDelay, DelayTimeDistribution);
                ProposedSimulationTable.Add(row);
                SumOfDelayTime += row.Delay;
                min             = 100000;
                i++;
            }
            ProposedPerformanceMeasures.BearingCost      = Convert.ToDecimal(ProposedSimulationTable.Count) * NumberOfBearings * Convert.ToDecimal(BearingCost);
            ProposedPerformanceMeasures.DelayCost        = Convert.ToDecimal(SumOfDelayTime) * Convert.ToDecimal(DowntimeCost);
            ProposedPerformanceMeasures.DowntimeCost     = Convert.ToDecimal(ProposedSimulationTable.Count) * Convert.ToDecimal(RepairTimeForAllBearings) * Convert.ToDecimal(DowntimeCost);
            ProposedPerformanceMeasures.RepairPersonCost = Convert.ToDecimal(ProposedSimulationTable.Count) * Convert.ToDecimal(RepairTimeForAllBearings) * (Convert.ToDecimal(RepairPersonCost) / Convert.ToDecimal(60));
            ProposedPerformanceMeasures.TotalCost        = ProposedPerformanceMeasures.BearingCost + ProposedPerformanceMeasures.DelayCost + ProposedPerformanceMeasures.DowntimeCost + ProposedPerformanceMeasures.RepairPersonCost;
        }
 public CurrentSimulationCase()
 {
     Bearing = new Bearing();
 }