private void compareProcess() { float t_time = 0; AlgorithmHelper lcrData = new AlgorithmHelper(); AlgorithmHelper kwmData = new AlgorithmHelper(); AlgorithmHelper rpwData = new AlgorithmHelper(); if (float.TryParse(tbTAKTTime.Text, out t_time)) { if (time_sequence != null) { if (t_time > 0) { // LCR implementation LCRAlgorithm lcr = new LCRAlgorithm(t_time, time_sequence.Count, precedence_data, time_sequence); precedence = lcr.AnalyzePrecedence(); lcrData.Workstations = lcr.AnalyzeWorkLoad(out efficiency, out totalTime, out numberOfWorkStation); lcrData.Efficiency = efficiency; lcrData.TotalTime = totalTime; lcrData.NumberOfWorkstations = numberOfWorkStation; lcrData.Type = AlgorithmType.LCR; // KWM Implementation KWMAlgorithm kwm = new KWMAlgorithm(t_time, time_sequence.Count, precedence_data, time_sequence); precedence = kwm.AnalyzePrecedence(); kwmData.Workstations = kwm.AnalyzeWorkload(out efficiency, out totalTime, out numberOfWorkStation); kwmData.Efficiency = efficiency; kwmData.TotalTime = totalTime; kwmData.NumberOfWorkstations = numberOfWorkStation; kwmData.Type = AlgorithmType.KWM; // RPW Implementation List <string[]> precedenceSequence = parsePrecedenceData(time_sequence); RPWAlgorithm rpw = new RPWAlgorithm(t_time, time_sequence.Count, precedence_data, precedenceSequence, time_sequence); //precedence = rpw.AnalyzePrecedence(); rpwData.Workstations = rpw.AnalyzeWorkload(out efficiency, out totalTime, out numberOfWorkStation); rpwData.Efficiency = efficiency; rpwData.TotalTime = totalTime; rpwData.NumberOfWorkstations = numberOfWorkStation; rpwData.Type = AlgorithmType.RPW; lcrData.WorkElements = kwmData.WorkElements = rpwData.WorkElements = work_element; lcrData.MachineNames = kwmData.MachineNames = rpwData.MachineNames = machine_data; lcrData.TimeSequence = kwmData.TimeSequence = rpwData.TimeSequence = time_sequence; } else { MessageBox.Show("Max time per workstation must be greater than zero", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please add data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Max time per workstation must be a decimal value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Dictionary <object, object> bundle = new Dictionary <object, object>(); bundle.Add(lcrData.Type, lcrData); bundle.Add(kwmData.Type, kwmData); bundle.Add(rpwData.Type, rpwData); new FormCompare(bundle).ShowDialog(this); }
public FormCompare(Dictionary <object, object> bundle) { InitializeComponent(); this.Text = Application.ProductName + " - Compare Results"; this.bundle = bundle; lcr = (AlgorithmHelper)bundle[AlgorithmType.LCR]; kwm = (AlgorithmHelper)bundle[AlgorithmType.KWM]; rpw = (AlgorithmHelper)bundle[AlgorithmType.RPW]; List <WorkStation> lcrWs = new List <WorkStation>(); List <WorkStation> kwmWs = new List <WorkStation>(); List <WorkStation> rpwWs = new List <WorkStation>(); for (int i = 0; i < lcr.NumberOfWorkstations; i++) { List <int> index = new List <int>(); List <float> st = new List <float>(); List <string> mdata = new List <string>(); for (int j = 0; lcr.Workstations[i, j] != -1; j++) { int data = lcr.Workstations[i, j]; mdata.Add(lcr.MachineNames[data - 1]); st.Add(lcr.TimeSequence.ElementAt(data - 1).Value); index.Add(lcr.TimeSequence.ElementAt(data - 1).Key); } WorkStation ws = new WorkStation(index, mdata, i); lcrWs.Add(ws); } for (int i = 0; i < kwm.NumberOfWorkstations; i++) { List <int> index = new List <int>(); List <float> st = new List <float>(); List <string> mdata = new List <string>(); for (int j = 0; kwm.Workstations[i, j] != -1; j++) { int data = kwm.Workstations[i, j]; mdata.Add(kwm.MachineNames[data - 1]); st.Add(kwm.TimeSequence.ElementAt(data - 1).Value); index.Add(kwm.TimeSequence.ElementAt(data - 1).Key); } WorkStation ws = new WorkStation(index, mdata, i); kwmWs.Add(ws); } for (int i = 0; i < rpw.NumberOfWorkstations; i++) { List <int> index = new List <int>(); List <float> st = new List <float>(); List <string> mdata = new List <string>(); for (int j = 0; rpw.Workstations[i, j] != -1; j++) { int data = rpw.Workstations[i, j]; mdata.Add(rpw.MachineNames[data - 1]); st.Add(rpw.TimeSequence.ElementAt(data - 1).Value); index.Add(rpw.TimeSequence.ElementAt(data - 1).Key); } WorkStation ws = new WorkStation(index, mdata, i); rpwWs.Add(ws); } int[] count = { lcr.NumberOfWorkstations, kwm.NumberOfWorkstations, rpw.NumberOfWorkstations }; int c = count.Max(); lvOutput.Items.Clear(); for (int i = 0; i < c; i++) { ListViewItem item = new ListViewItem(); item.Text = "WS " + (i + 1); if (i < lcrWs.Count) { item.SubItems.Add(lcrWs.ElementAt(i).GetIndex() + " | " + lcrWs.ElementAt(i).GetMachineNames()); } else { item.SubItems.Add("-"); } if (i < kwmWs.Count) { item.SubItems.Add(kwmWs.ElementAt(i).GetIndex() + " | " + kwmWs.ElementAt(i).GetMachineNames()); } else { item.SubItems.Add("-"); } if (i < rpwWs.Count) { item.SubItems.Add(rpwWs.ElementAt(i).GetIndex() + " | " + rpwWs.ElementAt(i).GetMachineNames()); } else { item.SubItems.Add("-"); } lvOutput.Items.Add(item); } lbKWME.Text = Math.Round(kwm.Efficiency, 2).ToString() + "%"; lbLCRE.Text = Math.Round(lcr.Efficiency, 2).ToString() + "%"; lbRPWE.Text = Math.Round(rpw.Efficiency, 2).ToString() + "%"; lbKWMN.Text = kwm.NumberOfWorkstations.ToString(); lbRPWN.Text = rpw.NumberOfWorkstations.ToString(); lblLCRN.Text = lcr.NumberOfWorkstations.ToString(); }