public static void WriteFullItemListWithID(List <Item> items) { StopwatchTimer.Start("write"); using (var writer = new StreamWriter("./fullListId.csv")) { String header = "ID, shipmentCode, priority, unloading priority, taxability, length, width, height" + "\n"; writer.Write(header); foreach (Item i in items) { String collect = i.toCSVFullListWithID(); // System.out.println(collect); writer.Write(collect); } } StopwatchTimer.Stop("write"); }
public static void WritePareto(List <Solution> solutions) { StopwatchTimer.Start("write"); using (var writer = new StreamWriter("./paretoSol.csv")) { String header = "Taxability, Obstacles" + "\n"; writer.Write(header); foreach (Solution s in solutions) { String collect = s.toCSVParetoSol(s); // System.out.println(collect); writer.Write(collect); } } StopwatchTimer.Stop("write"); }
public static void WriteOutpoutDescription(List <Item> items) { StopwatchTimer.Start("write"); using (var writer = new StreamWriter("./outputDescr.csv")) { string header = "ID, priority, unloading priority, taxability, positionX, positionY, positionZ, length, width, height" + "\n"; writer.Write(header); foreach (Item i in items) { String collect = i.toCSVOutputDescription(); // System.out.println(collect); writer.Write(collect); } } StopwatchTimer.Stop("write"); }
public static void WriteList(List <Item> items) { StopwatchTimer.Start("write"); using (var writer = new StreamWriter("./orderedList.csv")) { String header = "ID, shipmentCode, priority, unloading priority, taxability, maxHeightPosition" + "\n"; writer.Write(header); foreach (Item i in items) { String collect = i.toCSVOrderedList(); // System.out.println(collect); writer.Write(collect); } } StopwatchTimer.Stop("write"); }
public static void WriteItemPositionForVisualization(List <Item> items) { StopwatchTimer.Start("write"); using (var writer = new StreamWriter(Configuration.OUTPUT_FILE)) { string header = "PresentId, Width (x),height (y),Depth (z),tlr,,,trr,,,brr,,,blr,,,brf,,,blf,,,tlf,,,trf,," + "\n"; writer.Write(header); foreach (Item i in items) { string collect = i.toCSV(); // System.out.println(collect); writer.Write(collect); } } StopwatchTimer.Stop("write"); }
public static List <Item> readFromCSV() { StopwatchTimer.Start("read"); List <Item> ItemList; try { using (var stream = new StreamReader(Configuration.INPUT_FILE)) using (var csv = new CsvReader(stream, CultureInfo.InvariantCulture)) { ItemList = new List <Item>(); csv.Configuration.HeaderValidated = (isValid, header, arg3, arg4) => Console.Write($""); csv.Configuration.MissingFieldFound = (strings, i, arg3) => Console.Write(""); var records = csv.GetRecords <ParsedItem>(); foreach (ParsedItem parsedItem in records) { // Accessing Values by Column Index int id, customer, priority, num_items, stackable_v, unloadingOrder, shipmentCode; double width, height, depth, weight, taxability, vol; bool stackable; num_items = parsedItem.NumberOfItems; for (int i = 0; i < num_items; i++) { depth = parsedItem.Length; width = parsedItem.Width; height = parsedItem.Height; vol = parsedItem.Volume * Math.Pow(10, 6); // TODO: Change this --> Done to avoid null items, I give them by default 50x50x50cm dimensions if (depth == 0 && width == 0 && height == 0) { depth += 50; width += 50; height += 50; } weight = parsedItem.Weight / num_items; if (weight == 0) { weight += 100; } stackable_v = parsedItem.Stackable; if (stackable_v == 1) { stackable = true; } else { stackable = false; } unloadingOrder = parsedItem.UnloadingOrder; priority = parsedItem.Priority; taxability = parsedItem.Taxability / num_items; shipmentCode = parsedItem.Shipment; Item item = new Item(ItemList.Count, width, height, depth, weight, stackable, priority, unloadingOrder, taxability, shipmentCode); if (parsedItem.Loaded == 1) { companyItemsPacked++; companyBound += taxability; companyTotVol += vol; companyTotWeight += weight; } // Randomization rotation if (StaticRandom.NextDouble() >= 0.5) { item.rotate90(); // System.err.println("ROTATED"); ItemList.Add(item); } else { ItemList.Add(item); } } } } } catch (Exception ex) { throw; } StopwatchTimer.Stop("read"); return(ItemList); }
public static List <Item> readFromCSVNoMultipleItems() { StopwatchTimer.Start("read"); List <Item> ItemList; try { ItemList = new List <Item>(); using (var reader = new StreamReader(Configuration.INPUT_FILE)) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { var records = csv.GetRecords <ParsedItem>(); foreach (ParsedItem parsedItem in records) { // Accessing Values by Column Index int id, customer, priority, num_items, stackable_v, unloadingOrder, shipmentCode; double width, height, depth, weight, taxability; bool stackable; num_items = parsedItem.NumberOfItems; if (num_items > 1) { if (num_items % 2 == 0) { if (num_items % 4 == 0) { depth = parsedItem.Length * (num_items / 4); width = parsedItem.Weight * 4; height = parsedItem.Height; } else { depth = parsedItem.Length * (num_items / 2); width = parsedItem.Width * 2; height = parsedItem.Height; } } else { depth = parsedItem.Length * num_items; width = parsedItem.Width; height = parsedItem.Height; } if (depth == 0 && width == 0 && height == 0) { depth += 50; width += 50; height += 50; } weight = parsedItem.Weight; if (weight == 0) { weight += 100; } stackable_v = parsedItem.Stackable; if (stackable_v == 1) { stackable = true; } else { stackable = false; } unloadingOrder = parsedItem.UnloadingOrder; priority = parsedItem.Priority; taxability = parsedItem.Taxability; shipmentCode = parsedItem.Shipment; // To calculate company bound and then compare it with my bound if (parsedItem.Loaded == 1) { companyBound += taxability; } Item item = new Item(ItemList.Count, width, height, depth, weight, stackable, priority, unloadingOrder, taxability, shipmentCode); // Randomization rotation if (StaticRandom.NextDouble() >= 0.5) { item.rotate90(); ItemList.Add(item); } else { ItemList.Add(item); } } else { depth = parsedItem.Length; width = parsedItem.Width; height = parsedItem.Height; // TODO: Change this --> Done to avoid null items, I give them by default 50x50x50 dimensions if (depth == 0 && width == 0 && height == 0) { depth += 50; width += 50; height += 50; } weight = parsedItem.Weight; if (weight == 0) { weight += 100; } stackable_v = parsedItem.Stackable; if (stackable_v == 1) { stackable = true; } else { stackable = false; } unloadingOrder = parsedItem.UnloadingOrder; priority = parsedItem.Priority; taxability = parsedItem.Taxability; shipmentCode = parsedItem.Shipment; // To calculate company bound and then compare it with my bound if (parsedItem.Loaded == 1) { companyBound += taxability; } Item item = new Item(ItemList.Count, width, height, depth, weight, stackable, priority, unloadingOrder, taxability, shipmentCode); // Randomization rotation if (StaticRandom.NextDouble() >= 0.5) { item.rotate90(); ItemList.Add(item); } else { ItemList.Add(item); } } } } } catch (Exception ex) { throw; } StopwatchTimer.Stop("read"); return(ItemList); }