Digital Twin - GUI
ModelData.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Data.OleDb;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 using System.Windows.Forms;
9 using GUI.Datatypes;
10 
11 namespace GUI.IO_Modules
12 {
16  class ModelData
17  {
19  private String Dir;
21  private String[] locationNames;
23  private LocationCB[] locations;
25  private Dictionary<String, int> locationDictionary;
27  private Dictionary<String, int> usableLocationDictionary;
29  private String[] productNames;
31  private Dictionary<String, int> productDictionary;
33  private Dictionary<String, int> producableProductDictionary;
35  private List<Toolkit> usableToolkits;
36 
38  private double[] FuellgradBehaelter;
40  private double[] FuellgradTransportmittel;
42  private double[][] StockOfProdAtLocation;
44  private double[][] DauerBauteillogistik;
46  private double[][] KostenBauteillogistik;
48  private double[][] DauerWerkzeuglogistik;
50  private double[][] KostenWerkzeuglogistik;
52  private List<Order>[][] orders;
54  private List<Order>[][] relevantOrders;
56  public int maxN = 0;
57 
65  public ModelData(String dir, String[] locNames, LocationCB[] loc, Dictionary<String, int> locDic)
66  {
67  this.Dir = dir;
68  locationNames = locNames;
69  locations = loc;
70  locationDictionary = locDic;
71  productDictionary = new Dictionary<string, int>();
72  DauerBauteillogistik = new double[locations.Length][];
73  KostenBauteillogistik = new double[locations.Length][];
74  DauerWerkzeuglogistik = new double[locations.Length][];
75  KostenWerkzeuglogistik = new double[locations.Length][];
76  orders = new List<Order>[locations.Length][];
77  relevantOrders = new List<Order>[locations.Length][];
78 
79  getModelData();
80  }
81 
85  private void getModelData()
86  {
87  OleDbConnectionStringBuilder csbuilder = new OleDbConnectionStringBuilder();
88  csbuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
89  csbuilder.DataSource = Dir;
90  csbuilder.Add("Extended Properties", "Excel 12.0 Xml");
91 
92  DataTable sheet1 = new DataTable();
93  using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
94  {
95  connection.Open();
96  string sqlQuery = @"SELECT * FROM [Werkzeuge$]";
97  using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlQuery, connection))
98  {
99  adapter.Fill(sheet1);
100  }
101  getToolkitData(sheet1);
102  connection.Close();
103  }
104 
105  sheet1 = new DataTable();
106  using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
107  {
108  connection.Open();
109  string sqlQuery = @"SELECT * FROM [Behälter$]";
110  using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlQuery, connection))
111  {
112  adapter.Fill(sheet1);
113  }
114  getContainerData(sheet1);
115  connection.Close();
116  }
117 
118  sheet1 = new DataTable();
119  using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
120  {
121  connection.Open();
122  string sqlQuery = @"SELECT * FROM [Bestand$]";
123  using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlQuery, connection))
124  {
125  adapter.Fill(sheet1);
126  }
127  getStockData(sheet1);
128  connection.Close();
129  }
130 
131  String[] Matrices = { "Dauer Bauteillogistik", "Kosten Bauteillogistik", "Dauer Werkzeuglogistik", "Kosten Werkzeuglogistik" };
132  foreach (String s in Matrices)
133  {
134  sheet1 = new DataTable();
135  using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
136  {
137  connection.Open();
138  string sqlQuery = @"SELECT * FROM [" + s + "$]";
139  using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlQuery, connection))
140  {
141  adapter.Fill(sheet1);
142  }
143  getMatrixData(sheet1, s);
144  connection.Close();
145  }
146  }
147 
148  foreach (String SheetName in locationNames)
149  {
150  sheet1 = new DataTable();
151  using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
152  {
153  connection.Open();
154  // select everything from the worksheet that is named after a location
155  string sqlQuery = @"SELECT * FROM [Bedarf_" + SheetName + "$]";
156  using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlQuery, connection))
157  {
158  adapter.Fill(sheet1);
159  }
160  createOrderData(sheet1, SheetName);
161 
162  connection.Close();
163  }
164  }
165  }
166 
171  private void getToolkitData(DataTable sheet)
172  {
173  foreach (DataRow d in sheet.Rows)
174  {
175  int locationIndex = locationDictionary[d[5].ToString()];
176  LocationCB loc = locations[locationIndex];
177  Toolkit t = new Toolkit(d[0].ToString(), loc);
178  foreach (String s in d[2].ToString().Split(';'))
179  {
180  t.addProduct(s);
181  }
182  foreach (String s in d[4].ToString().Split(';'))
183  {
184  if (!s.Equals(""))
185  {
186  //only if s is not empty
187  t.addInfluencedToolkits(s);
188  }
189  }
190  loc.addToolkit(t);
191  }
192  }
193 
198  private void getContainerData(DataTable sheet)
199  {
200  FuellgradBehaelter = new double[sheet.Rows.Count];
201  FuellgradTransportmittel = new double[sheet.Rows.Count];
202  productNames = new String[sheet.Rows.Count];
203  int counter = 0;
204  foreach (DataRow d in sheet.Rows)
205  {
206  productNames[counter] = d[0].ToString();
207  productDictionary.Add(productNames[counter], counter);
208  FuellgradBehaelter[counter] = Convert.ToDouble(d[1]);
209  FuellgradTransportmittel[counter] = Convert.ToDouble(d[2]);
210  counter++;
211  }
212  }
213 
218  private void getStockData(DataTable sheet)
219  {
220  StockOfProdAtLocation = new double[sheet.Rows.Count][];
221  foreach (DataRow d in sheet.Rows)
222  {
223  StockOfProdAtLocation[productDictionary[d[0].ToString()]] = new double[sheet.Columns.Count - 1];
224  for (int i = 1; i < sheet.Columns.Count; i++)
225  {
226  StockOfProdAtLocation[productDictionary[d[0].ToString()]][locationDictionary[sheet.Columns[i].ToString()]] = Convert.ToDouble(d[i]);
227  }
228  }
229  }
230 
236  private void getMatrixData(DataTable sheet, String s)
237  {
238  foreach (DataRow d in sheet.Rows)
239  {
240  if (s.Equals("Dauer Bauteillogistik"))
241  {
242  DauerBauteillogistik[locationDictionary[d[0].ToString()]] = new double[locations.Length];
243  for (int i = 1; i < sheet.Columns.Count; i++)
244  {
245  DauerBauteillogistik[locationDictionary[d[0].ToString()]][locationDictionary[sheet.Columns[i].ToString()]] = Convert.ToDouble(d[i]);
246  }
247  }
248  if (s.Equals("Kosten Bauteillogistik"))
249  {
250  KostenBauteillogistik[locationDictionary[d[0].ToString()]] = new double[locations.Length];
251  for (int i = 1; i < sheet.Columns.Count; i++)
252  {
253  KostenBauteillogistik[locationDictionary[d[0].ToString()]][locationDictionary[sheet.Columns[i].ToString()]] = Convert.ToDouble(d[i]);
254  }
255  }
256  if (s.Equals("Dauer Werkzeuglogistik"))
257  {
258  DauerWerkzeuglogistik[locationDictionary[d[0].ToString()]] = new double[locations.Length];
259  for (int i = 1; i < sheet.Columns.Count; i++)
260  {
261  DauerWerkzeuglogistik[locationDictionary[d[0].ToString()]][locationDictionary[sheet.Columns[i].ToString()]] = Convert.ToDouble(d[i]);
262  }
263  }
264  if (s.Equals("Kosten Werkzeuglogistik"))
265  {
266  KostenWerkzeuglogistik[locationDictionary[d[0].ToString()]] = new double[locations.Length];
267  for (int i = 1; i < sheet.Columns.Count; i++)
268  {
269  KostenWerkzeuglogistik[locationDictionary[d[0].ToString()]][locationDictionary[sheet.Columns[i].ToString()]] = Convert.ToDouble(d[i]);
270  }
271  }
272  }
273  }
274 
275  private void createOrderData(DataTable sheet1, string sheetName)
276  {
277  // initialization of Matrix of lists:
278  int locationIndex = locationDictionary[sheetName];
279  orders[locationIndex] = new List<Order>[productNames.Length];
280  foreach (int i in productDictionary.Values)
281  {
282  orders[locationIndex][i] = new List<Order>();
283  }
284 
285  foreach (DataRow dr in sheet1.Rows)
286  {
287  String day = dr[0].ToString();
288  if (day.Equals("")) break;
289  for (int i = 1; i < sheet1.Columns.Count; i++)
290  {
291  int amount = Convert.ToInt32(dr[i]);
292  if (amount != 0)
293  {
294  orders[locationIndex][productDictionary[sheet1.Columns[i].ToString()]].Add(new Order(day, amount));
295  }
296  }
297  }
298  }
299 
308  public String toDatString(double d, DateTime start, DateTime end)
309  {
310  StringBuilder sb = new StringBuilder(5000);
311  sb.Append(getLocations());
312  sb.Append(getProducts());
313  sb.Append(getToolkits());
314  sb.Append(getMachines());
315  sb.Append(getT(d, start, end));
316  sb.Append(getTau(d));
317  sb.Append(getYInit());
318  sb.Append(getPsi());
319  sb.Append(getDelta());
320  sb.Append(getKhi());
321  sb.Append(getBeta());
322  sb.Append(getV(d));
323  sb.Append(getKappa());
324  sb.Append(getSigma());
325  sb.Append(getWdep());
326  sb.Append(getNAndMaxN(start, end));
327  sb.Append(getEpsilon());
328  sb.Append(getGamma(start, d));
329  sb.Append(getNu());
330  sb.Append(getRho());
331  sb.Append(getEta(d));
332  sb.Append(getAlpha(d));
333  sb.Append(getLambda());
334  sb.Append(getLocOfMachine());
335  sb.Append(getMachinesOfLocation());
336  sb.Append(getWProducer());
337 
338 
339  return sb.ToString();
340  }
341 
347  private String getLocations()
348  {
349  StringBuilder sb = new StringBuilder(200);
350  sb.Append("S:[");
351  usableLocationDictionary = new Dictionary<string, int>();
352  foreach (LocationCB l in locations)
353  {
354  if (l.CheckState != CheckState.Unchecked)
355  {
356  sb.Append("\"" + l.Name + "\", ");
357  usableLocationDictionary.Add(l.Name, locationDictionary[l.Name]);
358  }
359  }
360  String s = sb.ToString();
361  s = s.TrimEnd(new char[] { ',', ' ' });
362  return s + "]\n";
363  }
364 
370  private String getProducts()
371  {
372  StringBuilder sb = new StringBuilder(300);
373  sb.Append("P:[");
374  List<String> ProducedProducts = new List<String>();
375 
376  foreach (LocationCB l in locations)
377  {
378  if (l.CheckState != CheckState.Unchecked)
379  {
380  l.extendProducableProducts(ProducedProducts);
381  }
382  }
383 
384  producableProductDictionary = new Dictionary<string, int>();
385  foreach (String p in ProducedProducts)
386  {
387  producableProductDictionary.Add(p, productDictionary[p]);
388  }
389 
390  foreach (String p in productNames)
391  {
392  sb.Append("\"" + p + "\", ");
393  }
394  String s = sb.ToString();
395  s = s.TrimEnd(new char[] { ',', ' ' });
396  return s + "]\n";
397  }
398 
404  private String getToolkits()
405  {
406  StringBuilder sb = new StringBuilder(200);
407  sb.Append("W:[");
408 
409  usableToolkits = new List<Toolkit>();
410  foreach (LocationCB l in locations)
411  {
412  if (l.CheckState != CheckState.Unchecked)
413  {
414  foreach (Toolkit t in l.getToolkits())
415  {
416  usableToolkits.Add(t);
417  sb.Append("\"" + t.Name + "\", ");
418  }
419  }
420  }
421  String s = sb.ToString();
422  s = s.TrimEnd(new char[] { ',', ' ' });
423  return s + "]\n";
424  }
425 
431  private String getMachines()
432  {
433  StringBuilder sb = new StringBuilder(200);
434  sb.Append("M:[");
435  foreach (LocationCB l in locations)
436  {
437  if (l.CheckState != CheckState.Unchecked)
438  {
439  foreach (MachineCB m in l.getMachines())
440  {
441  if (m.CheckState != CheckState.Unchecked)
442  {
443 
444  sb.Append("\"" + m.Name + "\", ");
445  }
446  }
447  }
448  }
449  String s = sb.ToString();
450  s = s.TrimEnd(new char[] { ',', ' ' });
451  return s + "]\n";
452  }
453 
461  private String getT(double d, DateTime start, DateTime end)
462  {
463  StringBuilder sb = new StringBuilder(200);
464  sb.Append("T:[");
465 
466  double hours = end.Subtract(start).TotalHours;
467  int timeslotNumber = (int)(hours / d);
468  for (int i = 1; i <= timeslotNumber; i++)
469  {
470  sb.Append(i + ", ");
471  }
472  String s = sb.ToString();
473  s = s.TrimEnd(new char[] { ',', ' ' });
474  return s + "]\n";
475  }
476 
482  private String getTau(double d)
483  {
484  return "tau: " + 60 * d + "\n";
485  }
486 
493  private String getYInit()
494  {
495  StringBuilder sb = new StringBuilder(300);
496  sb.Append("yInit:[");
497  foreach (LocationCB l in locations)
498  {
499  if (l.CheckState != CheckState.Unchecked)
500  {
501  foreach (Toolkit t in l.getToolkits())
502  {
503  sb.Append("(\"" + l.Name + "\" \"" + t.Name + "\") " + 1 + " ");
504  }
505  }
506  }
507  String s = sb.ToString();
508  s = s.TrimEnd(new char[] { ',', ' ' });
509  return s + "]\n";
510  }
511 
518  private String getPsi()
519  {
520  StringBuilder sb = new StringBuilder(300);
521  sb.Append("psi:[");
522  foreach (LocationCB l in locations)
523  {
524  if (l.CheckState != CheckState.Unchecked)
525  {
526  foreach (String p in productNames)
527  {
528  sb.Append("(\"" + l.Name + "\" \"" + p + "\") " + l.Penalty + " ");
529  }
530  }
531  }
532  String s = sb.ToString();
533  s = s.TrimEnd(new char[] { ',', ' ' });
534  return s + "]\n";
535  }
536 
543  private String getDelta()
544  {
545  StringBuilder sb = new StringBuilder(2000);
546  sb.Append("delta:[");
547  foreach (KeyValuePair<String, int> S1 in usableLocationDictionary)
548  {
549  foreach (KeyValuePair<String, int> S2 in usableLocationDictionary)
550  {
551  foreach (Toolkit t in usableToolkits)
552  {
553  sb.Append("(\"" + S1.Key + "\" \"" + S2.Key + "\" \"" + t.Name + "\") " + KostenWerkzeuglogistik[S1.Value][S2.Value] + " ");
554  }
555  }
556  }
557  String s = sb.ToString();
558  s = s.TrimEnd(new char[] { ',', ' ' });
559  return s + "]\n";
560  }
561 
568  private String getKhi()
569  {
570  StringBuilder sb = new StringBuilder(300);
571  sb.Append("khi:[");
572  foreach (KeyValuePair<String, int> S1 in usableLocationDictionary)
573  {
574  foreach (KeyValuePair<String, int> S2 in usableLocationDictionary)
575  {
576  sb.Append("(\"" + S1.Key + "\" \"" + S2.Key + "\") " + KostenBauteillogistik[S1.Value][S2.Value] + " ");
577  }
578  }
579  String s = sb.ToString();
580  s = s.TrimEnd(new char[] { ',', ' ' });
581  return s + "]\n";
582  }
583 
591  private String getBeta()
592  {
593  StringBuilder sb = new StringBuilder(300);
594  sb.Append("beta:[");
595  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
596  {
597  foreach (KeyValuePair<String, int> P in productDictionary)
598  {
599  sb.Append("(\"" + S.Key + "\" \"" + P.Key + "\") " + StockOfProdAtLocation[P.Value][S.Value] + " ");
600  }
601  }
602  String s = sb.ToString();
603  s = s.TrimEnd(new char[] { ',', ' ' });
604  return s + "]\n";
605  }
606 
614  private String getV(double d)
615  {
616  StringBuilder sb = new StringBuilder(300);
617  sb.Append("v:[");
618  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
619  {
620  foreach (MachineCB m in locations[S.Value].getMachines())
621  {
622  if (m.CheckState != CheckState.Unchecked)
623  {
624  foreach (Toolkit t in usableToolkits)
625  {
626  sb.Append("(\"" + m.Name + "\" \"" + t.Name + "\") " + Math.Ceiling(m.Bauteilwechselphase / (60 * d)) + " ");
627  }
628  }
629  }
630  }
631  String s = sb.ToString();
632  s = s.TrimEnd(new char[] { ',', ' ' });
633  return s + "]\n";
634  }
635 
642  private String getKappa()
643  {
644  StringBuilder sb = new StringBuilder(300);
645  sb.Append("kappa:[");
646  foreach (KeyValuePair<String, int> P in productDictionary)
647  {
648  sb.Append("(\"" + P.Key + "\") " + FuellgradBehaelter[P.Value] + " ");
649  }
650  String s = sb.ToString();
651  s = s.TrimEnd(new char[] { ',', ' ' });
652  return s + "]\n";
653  }
654 
661  private String getSigma()
662  {
663  StringBuilder sb = new StringBuilder(300);
664  sb.Append("sigma:[");
665  foreach (KeyValuePair<String, int> P in productDictionary)
666  {
667  sb.Append("(\"" + P.Key + "\") " + FuellgradTransportmittel[P.Value] + " ");
668  }
669  String s = sb.ToString();
670  s = s.TrimEnd(new char[] { ',', ' ' });
671  return s + "]\n";
672  }
673 
680  private String getWdep()
681  {
682  StringBuilder sb = new StringBuilder(300);
683  sb.Append("Wdep:[");
684  foreach (KeyValuePair<String, int> L in usableLocationDictionary)
685  {
686  foreach (Toolkit t in locations[L.Value].getToolkits())
687  {
688  // Mosel cannot have empty lists in the initializations block, therefore don't write them down
689  if (t.getInfluencedToolkits().Count != 0)
690  {
691  sb.Append("(\"" + t.Name + "\") [");
692  foreach (String ww in t.getInfluencedToolkits())
693  {
694  sb.Append("\"" + ww + "\" ");
695  }
696  sb.Append("] ");
697  }
698  }
699  }
700  String s = sb.ToString();
701  s = s.TrimEnd(new char[] { ',', ' ' });
702  return s + "]\n";
703  }
704 
716  private String getNAndMaxN(DateTime start, DateTime end)
717  {
718  StringBuilder sb = new StringBuilder(300);
719  sb.Append("N:[");
720  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
721  {
722  relevantOrders[S.Value] = new List<Order>[productNames.Length];
723  foreach (KeyValuePair<String, int> P in productDictionary)
724  {
725  relevantOrders[S.Value][P.Value] = new List<Order>();
726  foreach (Order o in orders[S.Value][P.Value])
727  {
728  // list all the orders one should take into account
729  if (o.IsDueBetween(start, end))
730  {
731  relevantOrders[S.Value][P.Value].Add(o);
732  }
733  }
734  sb.Append("(\"" + S.Key + "\" \"" + P.Key + "\") " + relevantOrders[S.Value][P.Value].Count + " ");
735  if (maxN < relevantOrders[S.Value][P.Value].Count) maxN = relevantOrders[S.Value][P.Value].Count;
736  }
737  }
738  String s = sb.ToString();
739  s = s.TrimEnd(new char[] { ',', ' ' });
740  return s + "]\n" + "maxN: " + maxN + "\n";
741  }
742 
749  private String getEpsilon()
750  {
751  StringBuilder sb = new StringBuilder(300);
752  sb.Append("epsilon:[");
753  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
754  {
755  foreach (KeyValuePair<String, int> P in productDictionary)
756  {
757  int count = 1;
758  foreach (Order o in relevantOrders[S.Value][P.Value])
759  {
760  sb.Append("(\"" + S.Key + "\" \"" + P.Key + "\" " + count++ + ") " + o.Amount + " ");
761  }
762  }
763  }
764  String s = sb.ToString();
765  s = s.TrimEnd(new char[] { ',', ' ' });
766  return s + "]\n";
767  }
768 
777  private String getGamma(DateTime start, double d)
778  {
779  StringBuilder sb = new StringBuilder(300);
780  sb.Append("gamma:[");
781  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
782  {
783  foreach (KeyValuePair<String, int> P in productDictionary)
784  {
785  int count = 1;
786  foreach (Order o in relevantOrders[S.Value][P.Value])
787  {
788  sb.Append("(\"" + S.Key + "\" \"" + P.Key + "\" " + count++ + ") " + o.getDueTimeslot(start, d) + " ");
789  }
790  }
791  }
792  String s = sb.ToString();
793  s = s.TrimEnd(new char[] { ',', ' ' });
794  return s + "]\n";
795  }
796 
803  private String getNu()
804  {
805  StringBuilder sb = new StringBuilder(300);
806  sb.Append("nu:[");
807  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
808  {
809  foreach (KeyValuePair<String, int> P in productDictionary)
810  {
811  int count = 1;
812  foreach (Order o in relevantOrders[S.Value][P.Value])
813  {
814  // at this time we have no data, so it is set to 0.
815  sb.Append("(\"" + S.Key + "\" \"" + P.Key + "\" " + count++ + ") " + 0 + " ");
816  }
817  }
818  }
819  String s = sb.ToString();
820  s = s.TrimEnd(new char[] { ',', ' ' });
821  return s + "]\n";
822  }
823 
830  private String getRho()
831  {
832  StringBuilder sb = new StringBuilder(300);
833  sb.Append("rho:[");
834  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
835  {
836  foreach (MachineCB m in locations[S.Value].getMachines())
837  {
838  if (m.CheckState != CheckState.Unchecked)
839  {
840  foreach (Toolkit t in usableToolkits)
841  {
842  // number of products produced per minute = Huebe ohne Stoerung * Qualitaetsrate
843  double rho = m.getProducts().First<ProductCB>().hoS * m.getProducts().First<ProductCB>().qualitaetsrate;
844  sb.Append("(\"" + m.Name + "\" \"" + t.Name + "\") " + rho.ToString().Replace(',','.') + " ");
845  }
846  }
847  }
848  }
849  String s = sb.ToString();
850  s = s.TrimEnd(new char[] { ',', ' ' });
851  return s + "]\n";
852  }
853 
861  private String getEta(double d)
862  {
863  StringBuilder sb = new StringBuilder(2000);
864  sb.Append("eta:[");
865  foreach (KeyValuePair<String, int> S1 in usableLocationDictionary)
866  {
867  foreach (KeyValuePair<String, int> S2 in usableLocationDictionary)
868  {
869  foreach (Toolkit t in usableToolkits)
870  {
871  sb.Append("(\"" + S1.Key + "\" \"" + S2.Key + "\" \"" + t.Name + "\") " + Math.Ceiling(DauerWerkzeuglogistik[S1.Value][S2.Value] / (60 * d)) + " ");
872  }
873  }
874  }
875  String s = sb.ToString();
876  s = s.TrimEnd(new char[] { ',', ' ' });
877  return s + "]\n";
878  }
879 
887  private String getAlpha(double d)
888  {
889  StringBuilder sb = new StringBuilder(300);
890  sb.Append("alpha:[");
891  foreach (KeyValuePair<String, int> S1 in usableLocationDictionary)
892  {
893  foreach (KeyValuePair<String, int> S2 in usableLocationDictionary)
894  {
895  sb.Append("(\"" + S1.Key + "\" \"" + S2.Key + "\") " + Math.Ceiling(DauerBauteillogistik[S1.Value][S2.Value] / (60 * d)) + " ");
896  }
897  }
898  String s = sb.ToString();
899  s = s.TrimEnd(new char[] { ',', ' ' });
900  return s + "]\n";
901  }
902 
909  private String getLambda()
910  {
911  // until we get any other data, lambda is set to 0
912  return "lambda:" + 0 + "\n";
913  }
914 
921  private String getLocOfMachine()
922  {
923  StringBuilder sb = new StringBuilder(300);
924  sb.Append("LocOfMachine:[");
925  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
926  {
927  foreach (MachineCB m in locations[S.Value].getMachines())
928  {
929  if (m.CheckState != CheckState.Unchecked)
930  {
931  sb.Append("(\"" + m.Name + "\") \"" + S.Key + "\"" + " ");
932  }
933  }
934  }
935  String s = sb.ToString();
936  s = s.TrimEnd(new char[] { ',', ' ' });
937  return s + "]\n";
938  }
939 
946  private String getMachinesOfLocation()
947  {
948  StringBuilder sb = new StringBuilder(300);
949  sb.Append("MachinesOfLocation:[");
950  foreach (KeyValuePair<String, int> S in usableLocationDictionary)
951  {
952  if (locations[S.Value].getMachines().Count > 0)
953  {
954  sb.Append("(\"" + S.Key + "\") [");
955  foreach (MachineCB m in locations[S.Value].getMachines())
956  {
957  if (m.CheckState != CheckState.Unchecked)
958  {
959  sb.Append("\"" + m.Name + "\" ");
960  }
961  }
962  sb.Append("] ");
963  }
964  }
965  String s = sb.ToString();
966  s = s.TrimEnd(new char[] { ',', ' ' });
967  return s + "]\n";
968  }
969 
976  private String getWProducer()
977  {
978  StringBuilder sb = new StringBuilder(300);
979  sb.Append("WProducer:[");
980  foreach (String p in productNames)
981  {
982  //first list all the elements of one list. To check if it is empty.
983  //Mosel cannot read in empty lists.
984  List<String> temp = new List<string>();
985  foreach (Toolkit t in usableToolkits)
986  {
987  if (t.isAbleToProduce(p)) temp.Add(t.Name);
988  }
989  if (temp.Count > 0)
990  {
991  sb.Append("(\"" + p + "\") [");
992  foreach (String t in temp)
993  {
994  sb.Append("\"" + t + "\" ");
995  }
996  sb.Append("] ");
997  }
998  }
999  String s = sb.ToString();
1000  s = s.TrimEnd(new char[] { ',', ' ' });
1001  return s + "]\n";
1002  }
1003  }
1004 }
Dictionary< String, int > locationDictionary
Dictionary that maps a location&#39;s name to its position in the locations array.
Definition: ModelData.cs:25
double[][] KostenWerkzeuglogistik
Matrix that contains KostenWerkzeuglogistik data for the model. Index is: [S][S]. ...
Definition: ModelData.cs:50
List< Order >[][] relevantOrders
List of orders for a product p at location S, that fall into our time horizon. Index is: [S][P]...
Definition: ModelData.cs:54
String getProducts()
Writes data to set "P". Initializes producableProductDictionary.
Definition: ModelData.cs:370
List< String > getInfluencedToolkits()
Grants access to the list of toolkits that cannot be used while this one is in use.
Definition: Toolkit.cs:74
String[] locationNames
Array that contains all of the locations&#39; names.
Definition: ModelData.cs:21
String getMachines()
Writes data to set "M".
Definition: ModelData.cs:431
LocationCB[] locations
Array that contains all of the locations.
Definition: ModelData.cs:23
ModelData(String dir, String[] locNames, LocationCB[] loc, Dictionary< String, int > locDic)
Constructor.
Definition: ModelData.cs:65
String getYInit()
Writes data to array "yInit".
Definition: ModelData.cs:493
String getMachinesOfLocation()
Writes data to array "MachinesOfLocation".
Definition: ModelData.cs:946
Dictionary< String, int > producableProductDictionary
Subdictionary that maps a product&#39;s name to its position in the product array. Only conatains checked...
Definition: ModelData.cs:33
bool isAbleToProduce(String p)
Checks if Toolkit can produce a certain product.
Definition: Toolkit.cs:84
String getEpsilon()
Writes data to array "epsilon".
Definition: ModelData.cs:749
Dictionary< String, int > productDictionary
Dictionary that maps a product&#39;s name to its position in the product array.
Definition: ModelData.cs:31
Dictionary< String, int > usableLocationDictionary
Subdictionary that maps a location&#39;s name to its position in the locations array. Only conatains chec...
Definition: ModelData.cs:27
String getLambda()
Writes data to array "lambda".
Definition: ModelData.cs:909
String getNAndMaxN(DateTime start, DateTime end)
Writes data to array "N" and field "nMax". Initializes relevantOrders by given time horizon...
Definition: ModelData.cs:716
String getKhi()
Writes data to array "khi".
Definition: ModelData.cs:568
A wrapper class for toolkits.
Definition: Toolkit.cs:16
String getEta(double d)
Writes data to array "eta".
Definition: ModelData.cs:861
List< String > extendProducableProducts(List< String > l)
Extends the List of products that can be produced.
Definition: LocationCB.cs:229
List< ProductCB > getProducts()
Grants access to the list of products that belong to the machine.
Definition: MachineCB.cs:69
double[][] KostenBauteillogistik
Matrix that contains KostenBauteillogistik data for the model. Index is: [S][S].
Definition: ModelData.cs:46
List< Order >[][] orders
List of orders for a product p at location S. Index is: [S][P].
Definition: ModelData.cs:52
String getLocOfMachine()
Writes data to array "LocOfMachine".
Definition: ModelData.cs:921
A wrapper class for products.
Definition: ProductCB.cs:18
String getPsi()
Writes data to array "psi".
Definition: ModelData.cs:518
double[] FuellgradBehaelter
Array that contains FuellgradBehaelter data for the model. Index is P.
Definition: ModelData.cs:38
String getV(double d)
Writes data to array "v".
Definition: ModelData.cs:614
A wrapper class for locations.
Definition: LocationCB.cs:19
bool IsDueBetween(DateTime start, DateTime end)
Determins if order is due in a given time interval.
Definition: Order.cs:44
int Amount
How many items are requested.
Definition: Order.cs:21
String Dir
Directory CheckboxCreator reads from.
Definition: ModelData.cs:19
void getToolkitData(DataTable sheet)
Extract Toolkit data from sheet.
Definition: ModelData.cs:171
String getAlpha(double d)
Writes data to array "alpha".
Definition: ModelData.cs:887
double[][] DauerWerkzeuglogistik
Matrix that contains DauerWerkzeuglogistik data for the model. Index is: [S][S].
Definition: ModelData.cs:48
String toDatString(double d, DateTime start, DateTime end)
Concatenates the array and set strings, suitable for Xpress. Considers only the needed data...
Definition: ModelData.cs:308
double Bauteilwechselphase
A number that describes the time needed to change toolkits on this machine (in minutes).
Definition: MachineCB.cs:27
String getT(double d, DateTime start, DateTime end)
Writes data to set "T".
Definition: ModelData.cs:461
String getWdep()
Writes data to array "Wdep".
Definition: ModelData.cs:680
String Name
The toolkit&#39;s name.
Definition: Toolkit.cs:19
double[] FuellgradTransportmittel
Array that contains FuellgradTransportmittel data for the model. Index is P.
Definition: ModelData.cs:40
void getModelData()
Reads all the excel sheets and writes data to respective arrays.
Definition: ModelData.cs:85
String getTau(double d)
Writes data to set "tau".
Definition: ModelData.cs:482
String getLocations()
Writes data to set "S". Initilizes usableLocationDictionary.
Definition: ModelData.cs:347
List< Toolkit > usableToolkits
List that contains all Toolkits.
Definition: ModelData.cs:35
void getMatrixData(DataTable sheet, String s)
Extract matrix data from sheet.
Definition: ModelData.cs:236
int getDueTimeslot(DateTime start, double d)
Computes the timeslot when the order is due.
Definition: Order.cs:62
String getRho()
Writes data to array "rho".
Definition: ModelData.cs:830
void getStockData(DataTable sheet)
Extract stock data from sheet.
Definition: ModelData.cs:218
double[][] StockOfProdAtLocation
Matrix that contains StockOfProdAtLocation data for the model. Index is: [P][S].
Definition: ModelData.cs:42
String getToolkits()
Writes data to set "W".
Definition: ModelData.cs:404
double[][] DauerBauteillogistik
Matrix that contains DauerBauteillogistik data for the model. Index is: [S][S].
Definition: ModelData.cs:44
String getGamma(DateTime start, double d)
Writes data to array "gamma".
Definition: ModelData.cs:777
String getWProducer()
Writes data to array "WProducer".
Definition: ModelData.cs:976
String getNu()
Writes data to array "nu".
Definition: ModelData.cs:803
A wrapper class for machines.
Definition: MachineCB.cs:18
String getSigma()
Writes data to array "sigma".
Definition: ModelData.cs:661
String[] productNames
Array that contains all of the products&#39; names.
Definition: ModelData.cs:29
This class reads all the important data out of an Excel file related to the model.
Definition: ModelData.cs:16
void getContainerData(DataTable sheet)
Extract container data from sheet.
Definition: ModelData.cs:198
String getBeta()
Writes data to array "beta".
Definition: ModelData.cs:591
String getKappa()
Writes data to array "kappa".
Definition: ModelData.cs:642
double Penalty
A number that describes the estimated penalty for the dalayed production of one product (in Euro)...
Definition: LocationCB.cs:32
List< MachineCB > getMachines()
Grants access to the list of machines that belong to the location.
Definition: LocationCB.cs:190
List< Toolkit > getToolkits()
Grants access to the list of toolkits that belong to the location.
Definition: LocationCB.cs:215
A wrapper class for orders.
Definition: Order.cs:12
String getDelta()
Writes data to array "delta".
Definition: ModelData.cs:543