public TimeDistribution setData(string data)
        {
            data.Replace(" ", "");
            string[]         spilter = data.Split(',');
            TimeDistribution temp    = new TimeDistribution();

            temp.Time        = int.Parse(spilter[0]);
            temp.Probability = decimal.Parse(spilter[1]);
            return(temp);
        }
Exemplo n.º 2
0
        public void getSystemInformation(string filePath)
        {
            string line;

            System.IO.StreamReader file = new System.IO.StreamReader(filePath);
            List <string>          data = new List <string>();

            while ((line = file.ReadLine()) != null)
            {
                if (line.Length > 0 && line[0] >= '0' && line[0] <= '9')
                {
                    data.Add(line);
                }
            }
            DowntimeCost             = int.Parse(data[0]);
            RepairPersonCost         = int.Parse(data[1]);
            BearingCost              = int.Parse(data[2]);
            NumberOfHours            = int.Parse(data[3]);
            NumberOfBearings         = int.Parse(data[4]);
            RepairTimeForOneBearing  = int.Parse(data[5]);
            RepairTimeForAllBearings = int.Parse(data[6]);
            TimeDistribution DelayTimeDistributionTemp = new TimeDistribution();

            for (int i = 7; i < 10; i++)
            {
                DelayTimeDistributionTemp = new TimeDistribution();
                DelayTimeDistribution.Add(DelayTimeDistributionTemp.setData(data[i]));
            }
            DelayTimeDistribution = DelayTimeDistributionTemp.postProcess(DelayTimeDistribution);
            TimeDistribution BearingLifeDistributionTemp = new TimeDistribution();

            for (int i = 10; i < data.Count; i++)
            {
                BearingLifeDistributionTemp = new TimeDistribution();
                BearingLifeDistribution.Add(BearingLifeDistributionTemp.setData(data[i]));
            }
            BearingLifeDistribution = BearingLifeDistributionTemp.postProcess(BearingLifeDistribution);
            file.Close();
        }
 public void LoadData(string TestCasePath, SimulationSystem SimSystem)
 {
     string[] lines = System.IO.File.ReadAllLines(TestCasePath);
     for (int i = 0; i < lines.Count(); i++)
     {
         if (lines[i] == "DowntimeCost")
         {
             i++;
             SimSystem.DowntimeCost = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "RepairPersonCost")
         {
             i++;
             SimSystem.RepairPersonCost = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "BearingCost")
         {
             i++;
             SimSystem.BearingCost = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "NumberOfHours")
         {
             i++;
             SimSystem.NumberOfHours = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "NumberOfBearings")
         {
             i++;
             SimSystem.NumberOfBearings = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "RepairTimeForOneBearing")
         {
             i++;
             SimSystem.RepairTimeForOneBearing = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "RepairTimeForAllBearings")
         {
             i++;
             SimSystem.RepairTimeForAllBearings = Int32.Parse(lines[i]);
         }
         else if (lines[i] == "DelayTimeDistribution")
         {
             i++;
             while (lines[i] != "")
             {
                 string[]         dist            = lines[i].Split(',');
                 TimeDistribution TimeDitribution = new TimeDistribution();
                 TimeDitribution.Time        = Int32.Parse(dist[0]);
                 TimeDitribution.Probability = decimal.Parse(dist[1]);
                 SimSystem.DelayTimeDistribution.Add(TimeDitribution);
                 i++;
             }
         }
         else if (lines[i] == "BearingLifeDistribution")
         {
             i++;
             while (i < lines.Count())
             {
                 string[]         dist            = lines[i].Split(',');
                 TimeDistribution TimeDitribution = new TimeDistribution();
                 TimeDitribution.Time        = Int32.Parse(dist[0]);
                 TimeDitribution.Probability = decimal.Parse(dist[1]);
                 SimSystem.BearingLifeDistribution.Add(TimeDitribution);
                 i++;
             }
             break;
         }
     }
 }
Exemplo n.º 4
0
        public static void InputData(string[] lines, ref SimulationSystem simulationSystem)
        {
            int stringType = 0;

            char[] delimiters = { ',', ' ' };
            foreach (string line in lines)
            {
                if (line == "\n" || line.Length == 0)
                {
                    continue;
                }
                switch (line)
                {
                case "DowntimeCost":
                    stringType = 1;
                    continue;

                case "RepairPersonCost":
                    stringType = 2;
                    continue;

                case "BearingCost":
                    stringType = 3;
                    continue;

                case "NumberOfHours":
                    stringType = 4;
                    continue;

                case "NumberOfBearings":
                    stringType = 5;
                    continue;

                case "RepairTimeForOneBearing":
                    stringType = 6;
                    continue;

                case "RepairTimeForAllBearings":
                    stringType = 7;
                    continue;

                case "DelayTimeDistribution":
                    stringType = 8;
                    continue;

                case "BearingLifeDistribution":
                    stringType = 9;
                    continue;
                }

                switch (stringType)
                {
                case 1:
                    simulationSystem.DowntimeCost = int.Parse(line);
                    break;

                case 2:
                    simulationSystem.RepairPersonCost = int.Parse(line);
                    break;

                case 3:
                    simulationSystem.BearingCost = int.Parse(line);
                    break;

                case 4:
                    simulationSystem.NumberOfHours = int.Parse(line);
                    break;

                case 5:
                    simulationSystem.NumberOfBearings = int.Parse(line);
                    break;

                case 6:
                    simulationSystem.RepairTimeForOneBearing = int.Parse(line);
                    break;

                case 7:
                    simulationSystem.RepairTimeForAllBearings = int.Parse(line);
                    break;

                default:
                {
                    string[] distributions = line.Split(delimiters);

                    if (distributions.Length > 2)
                    {
                        TimeDistribution timeDistribution = new TimeDistribution();
                        timeDistribution.Time        = int.Parse(distributions[0]);
                        timeDistribution.Probability = decimal.Parse(distributions[2]);

                        switch (stringType)
                        {
                        case 8:
                            simulationSystem.DelayTimeDistribution.Add(timeDistribution);
                            break;

                        case 9:
                            simulationSystem.BearingLifeDistribution.Add(timeDistribution);
                            break;
                        }
                    }
                    break;
                }
                }
            }
        }
Exemplo n.º 5
0
        public void readfile(string fna)
        {
            FileStream   fs = new FileStream(fna, FileMode.Open);
            StreamReader sr = new StreamReader(fs);

            while (sr.Peek() != -1)
            {
                string fineline = sr.ReadLine();
                if (fineline == "")
                {
                    continue;
                }
                else if (fineline == "DowntimeCost")
                {
                    DowntimeCost = int.Parse(sr.ReadLine());
                }
                else if (fineline == "RepairPersonCost")
                {
                    RepairPersonCost = int.Parse(sr.ReadLine());
                }
                else if (fineline == "BearingCost")
                {
                    BearingCost = int.Parse(sr.ReadLine());
                }
                else if (fineline == "NumberOfHours")
                {
                    NumberOfHours = int.Parse(sr.ReadLine());
                }
                else if (fineline == "NumberOfBearings")
                {
                    NumberOfBearings = int.Parse(sr.ReadLine());
                }

                else if (fineline == "RepairTimeForOneBearing")
                {
                    RepairTimeForOneBearing = int.Parse(sr.ReadLine());
                }
                else if (fineline == "RepairTimeForAllBearings")
                {
                    RepairTimeForAllBearings = int.Parse(sr.ReadLine());
                }
                else if (fineline == "DelayTimeDistribution")
                {
                    int cp = 0;
                    while (true)
                    {
                        string td = sr.ReadLine();
                        if (td == "")
                        {
                            break;
                        }
                        string[]         l = td.Split(',');
                        TimeDistribution x = new TimeDistribution();
                        x.Time = int.Parse(l[0]);
                        int pro = Convert.ToInt32(float.Parse(l[1]) * 100);
                        x.Probability     = pro;
                        x.CummProbability = cp + pro;
                        x.MinRange        = cp + 1;
                        cp        += pro;
                        x.MaxRange = cp;
                        DelayTimeDistribution.Add(x);
                    }
                }
                else if (fineline == "BearingLifeDistribution")
                {
                    int cp = 0;
                    while (true)
                    {
                        string td = sr.ReadLine();
                        if (td == "" || td == null)
                        {
                            break;
                        }
                        string[]         l = td.Split(',');
                        TimeDistribution x = new TimeDistribution();
                        x.Time = int.Parse(l[0]);
                        int pro = Convert.ToInt32(float.Parse(l[1]) * 100);
                        x.Probability     = pro;
                        x.CummProbability = cp + pro;
                        x.MinRange        = cp + 1;
                        cp        += pro;
                        x.MaxRange = cp;
                        BearingLifeDistribution.Add(x);
                    }
                }
            }
            fs.Close();
        }
Exemplo n.º 6
0
        public void ReadInput(string filepath)
        {
            string       str;
            FileStream   fs = new FileStream(filepath, FileMode.Open);
            StreamReader SR = new StreamReader(fs);

            while (SR.Peek() != -1)
            {
                str = SR.ReadLine();
                if (str == "DowntimeCost")
                {
                    DowntimeCost = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "RepairPersonCost")
                {
                    RepairPersonCost = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "BearingCost")
                {
                    BearingCost = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "NumberOfHours")
                {
                    NumberOfHours = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "NumberOfBearings")
                {
                    NumberOfBearings = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "RepairTimeForOneBearing")
                {
                    RepairTimeForOneBearing = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "RepairTimeForAllBearings")
                {
                    RepairTimeForAllBearings = int.Parse(SR.ReadLine());
                    SR.ReadLine();
                    continue;
                }
                else if (str == "DelayTimeDistribution")
                {
                    str = SR.ReadLine();
                    while (str != "")
                    {
                        TimeDistribution TD         = new TimeDistribution();
                        string[]         substrings = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        TD.Time        = int.Parse(substrings[0]);
                        TD.Probability = decimal.Parse(substrings[1]);
                        str            = SR.ReadLine();
                        DelayTimeDistribution.Add(TD);
                    }
                    generate_cumulative_range(DelayTimeDistribution);
                    continue;
                }
                else if (str == "BearingLifeDistribution")
                {
                    str = SR.ReadLine();
                    while (str != "" && str != null)
                    {
                        TimeDistribution TD         = new TimeDistribution();
                        string[]         substrings = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        TD.Time        = int.Parse(substrings[0]);
                        TD.Probability = decimal.Parse(substrings[1]);
                        str            = SR.ReadLine();
                        BearingLifeDistribution.Add(TD);
                    }
                    generate_cumulative_range(BearingLifeDistribution);
                    continue;
                }
            }
            SR.Close();
        }