/** * * @param items * @param container * @param potentialPointsSx * @param potentialPointsDx * @return * @throws IOException * @throws ParseException */ public static Solution[] multiRunSolution(List <Item> items, Container container, List <PotentialPoint> potentialPointsSx, List <PotentialPoint> potentialPointsDx) { List <Solution> solutions = new List <Solution>(); Solution[] results = new Solution[4]; int times = Configuration.TIMES_MULTIRUN; int reading_method = Configuration.READING_MULTIITEM_METHOD; for (int i = 0; i < times; i++) { if (reading_method == 0) { items = ReadCSV.readFromCSV(); } else { items = ReadCSV.readFromCSVNoMultipleItems(); } potentialPointsSx = new List <PotentialPoint>(); potentialPointsDx = new List <PotentialPoint>(); container = new Container(Configuration.CONTAINER_WIDTH, Configuration.CONTAINER_HEIGHT, Configuration.CONTAINER_DEPTH, Configuration.CONTAINER_MAX_WEIGHT, Configuration.CONTAINER_UNLOADABLE_FROM_SIDE); if (packingMethod == 1) { solutions.Add(divideEtPack(items, container, potentialPointsSx)); } else if (packingMethod == 2) { solutions.Add(divideEtPackAlternate(items, container, potentialPointsSx, potentialPointsDx)); } else if (packingMethod == 3) { solutions.Add(newPackAlternate(items, container, potentialPointsSx, potentialPointsDx)); } } WriteCSV.WriteAllSol(solutions); solutions.Sort((x, y) => { if (y.getTotalTaxability() > x.getTotalTaxability()) { return(1); } else if (y.getTotalTaxability() == x.getTotalTaxability()) { return(0); } return(-1); }); List <Solution> paretSolTax = Functions.paretoFrontTaxabilityObstacles(solutions); // WriteCSV.writePareto(paretSolTax); bestTaxability = solutions[0]; results[0] = bestTaxability; foreach (Solution s in paretSolTax) { container.unloadEverything(); container.loadedItemsInZone(s.getItemsPacked()); // System.err.println(s.getItemsPacked().size()); if ((s.getTotalTaxability() >= bestTaxability.getTotalTaxability()) && s.zoneWeightFeasibility(container)) { bestTaxability = new Solution(s.getItemsPacked(), container, s.getPotentialPoints()); results[0] = bestTaxability; } } res = solutions[0]; lessObstacles = solutions[0]; return(results); }
public void Ported() { int reading_method = Configuration.READING_MULTIITEM_METHOD; List <Item> items; if (reading_method == 0) { items = ReadCSV.readFromCSV(); } else { items = ReadCSV.readFromCSVNoMultipleItems(); } List <Item> comparison; List <PotentialPoint> potentialpointsSx = new List <PotentialPoint>(); List <PotentialPoint> potentialpointsDx = new List <PotentialPoint>(); WriteCSV.WriteFullItemListWithID(items); /*TO CREATE NEW INSTANCES*/ // InstanceCreator.writeInstance(); double upper_bound; upper_bound = Functions.objFunction(items); //Console.WriteLine(upper_bound); //WriteCSV.writeList(items); // furgonato Container c = new Container(Configuration.CONTAINER_WIDTH, Configuration.CONTAINER_HEIGHT, Configuration.CONTAINER_DEPTH, Configuration.CONTAINER_MAX_WEIGHT, Configuration.CONTAINER_UNLOADABLE_FROM_SIDE); List <Item> items1; Solution[] solution = Solver.multiRunSolution(items, c, potentialpointsSx, potentialpointsDx); //Console.WriteLine(solution.Length); Solution sol = solution[0]; items1 = sol.getItemsPacked(); WriteCSV.WriteItemPositionForVisualization(items1); WriteCSV.WriteOutpoutDescription(items1); double myResult; myResult = Functions.objFunction(items1); double x, y, z; x = Functions.dev_x(items1, c); y = Functions.dev_y(items1, c); // z = Util.Functions.dev_z(items1, c); c.loadedItemsInZone(items1); double weightMax; weightMax = Functions.totalWeightOfItems(items); List <Item> unpackedItems = Functions.getUnpackedItems(items, items1); int priority1leftUnpacked = Functions.itemsPriorityOneUnpacked(unpackedItems); int priority0leftUnpacked = Functions.itemsPriorityZeroUnpacked(unpackedItems); bool feasible = sol.zoneWeightFeasibility(c); double companyBound = ReadCSV.getCompanyBound(); double companyTotVol = ReadCSV.getCompanyTotVol(); double companyTotWeight = ReadCSV.getCompanyTotWeight(); int companyItemsPacked = ReadCSV.getCompanyItemsPacked(); /* System.err.println("Company bound: " + companyBound); * System.err.println("My_bound: " + myResult); * System.err.println("---------------------------------");*/ Console.WriteLine("Performance : " + Functions.round((myResult / companyBound * (100)), 2) + " %"); //Console.WriteLine("Read: " + StopwatchTimer.GetElapsedMillisecondsAndReset("read")); //Console.WriteLine("Write: " + StopwatchTimer.GetElapsedMillisecondsAndReset("write")); //Console.WriteLine("Sort: " + StopwatchTimer.GetElapsedMillisecondsAndReset("sort")); //Console.WriteLine("Add: " + StopwatchTimer.GetElapsedMillisecondsAndReset("add")); //Console.WriteLine("Pack: " + StopwatchTimer.GetElapsedMillisecondsAndReset("pack")); }