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);
        }
Exemplo n.º 2
0
        public SimulationOutput StartSimulation(string TestCasePath)
        {
            SimulationOutput SimOutput = new SimulationOutput();
            Helper           helper    = new Helper();

            helper.LoadData(TestCasePath, this);
            if (!helper.GetFullDistribution(DelayTimeDistribution))
            {
                return(SimOutput);
            }
            if (!helper.GetFullDistribution(BearingLifeDistribution))
            {
                return(SimOutput);
            }
            helper.GetCurrentMethodSimulation(this, SimOutput);
            helper.GetProposedMethodSimulation(this, SimOutput);
            return(SimOutput);
        }
 void Display(BearingMachineModels.SimulationOutput SimOutput, SimulationSystem SimSystem)
 {
     dataGridView1.DataSource = SimOutput.CurrentSimulation;
     dataGridView3.DataSource = SimOutput.CurrentSimulationPerformance;
     dataGridView2.DataSource = SimOutput.ProposedSimulation;
     dataGridView4.DataSource = SimOutput.ProposedSimulationPerformance;
     if (SimSystem.CurrentPerformanceMeasures.TotalCost < SimSystem.ProposedPerformanceMeasures.TotalCost)
     {
         MessageBox.Show("The current method is better than the proposed method.");
     }
     else if (SimSystem.CurrentPerformanceMeasures.TotalCost > SimSystem.ProposedPerformanceMeasures.TotalCost)
     {
         MessageBox.Show("The proposed method is better than the current method.");
     }
     else
     {
         MessageBox.Show("The two methods have the same efficiency.");
     }
 }
        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);
        }