Esempio n. 1
0
        public List <ProposedSimulationCase> GenerateProposedSimulationCase()
        {
            List <ProposedSimulationCase> ret = new List <ProposedSimulationCase>();
            int accumulativeTime = 0;

            for (int i = 0; i < _listOfRandomizedBearings.Count; i += NumberOfBearings)
            {
                ProposedSimulationCase ps = new ProposedSimulationCase();
                int idx = 0;
                for (int j = i; j < i + NumberOfBearings; j++)
                {
                    ps.Bearings.Add(_listOfRandomizedBearings[j]);
                    if (ps.Bearings[j - i].Hours < ps.Bearings[idx].Hours)
                    {
                        idx = j - i;
                    }
                }
                ps.FirstFailure     = ps.Bearings[idx].Hours;
                accumulativeTime   += ps.Bearings[idx].Hours;
                ps.AccumulatedHours = accumulativeTime;
                int randomDelay = GetDelayRand();
                int delay       = GetTime(randomDelay, DelayTimeDistribution);
                ps.RandomDelay      = randomDelay;
                ps.Delay            = delay;
                ps.AccumulatedHours = accumulativeTime;
                ret.Add(ps);
            }
            return(ret);
        }
        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++;
            }
        }
Esempio n. 3
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;
        }
        private void runProposedPolicy()
        {
            int c = 0, hours = 0;

            for (int i = 0; c < NumberOfHours; i++)
            {
                // need to add more Random numbers
                ProposedSimulationCase proposedSimulationCase = new ProposedSimulationCase();
                for (int j = 0; j < NumberOfBearings; j++)
                {
                    addRandomNumber(j, i);
                    proposedSimulationCase.Bearings.Add(getBearing(j, i));
                }
                proposedSimulationCase.FirstFailure = getFirstFaliure(proposedSimulationCase.Bearings);
                c += proposedSimulationCase.FirstFailure;
                proposedSimulationCase.AccumulatedHours = c;

                proposedSimulationCase.RandomDelay = r.Next(1, 101);

                proposedSimulationCase.Delay = getDelay(proposedSimulationCase.RandomDelay);
                ProposedSimulationTable.Add(proposedSimulationCase);
            }
        }
        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);
        }
Esempio n. 6
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;
        }