public void Report_results(ref SolutionArray solArray) { pallet.Variant = best_variant; double packed_box_percentage = (double)best_solution_volume * 100 / (double)total_box_volume; pallet_volume_used_percentage = (double)best_solution_volume * 100 / (double)pallet.Vol; double elapsed_time = (TimeStop - TimeStart).TotalMilliseconds * 0.001; List_candidate_layers(false); packedvolume = 0; packedy = 0; packing = true; layerThickness = layers[best_iteration].LayerDim; remainpy = pallet.Pallet_y; remainpz = pallet.Pallet_z; foreach (BoxInfo bi in boxList) { bi.Is_packed = false; } bool hundredpercent = false; do { layerinlayer = 0; layerdone = false; Pack_layer(true, ref hundredpercent); packedy += layerThickness; remainpy = pallet.Pallet_y - packedy; if (0 != layerinlayer) { prepackedy = packedy; preremainpy = remainpy; remainpy = layerThickness - prelayer; packedy = packedy - layerThickness + prelayer; remainpz = lilz; layerThickness = layerinlayer; layerdone = false; Pack_layer(true, ref hundredpercent); packedy = prepackedy; remainpy = preremainpy; remainpz = pallet.Pallet_z; } System.Diagnostics.Debug.Assert(remainpy >= 0); Find_layer(remainpy, pallet); }while (packing); Solution sol = new Solution() { Variant = best_variant, Iteration = best_iteration }; foreach (BoxInfo bi in boxList) { if (bi.Is_packed) { sol.ItemsPacked.Add(bi.ToSolItem(best_variant)); } else { sol.ItemsUnpacked.Add(bi.ToSolItem(best_variant)); } } solArray.Solutions.Add(sol); /* * foreach (BoxInfo bi in boxList) * { * if (bi.Is_packed) * bi.WriteToFile(fso, best_variant, best_iteration); * } */ Console.WriteLine("ELAPSED TIME : Almost {0:0.000} s", elapsed_time); Console.WriteLine("TOTAL NUMBER OF ITERATIONS DONE : {0}", number_of_iterations); Console.WriteLine("BEST SOLUTION FOUND AT : ITERATION: {0} OF VARIANT: {1}", best_iteration, best_variant); Console.WriteLine("TOTAL NUMBER OF BOXES : {0}", boxList.Count); Console.WriteLine("PACKED NUMBER OF BOXES : {0}", number_packed_boxes); Console.WriteLine("TOTAL VOLUME OF ALL BOXES : {0}", total_box_volume); Console.WriteLine("PALLET VOLUME : {0}", pallet.Vol); Console.WriteLine("BEST SOLUTION'S VOLUME UTILIZATION : {0} OUT OF {1}", best_solution_volume, pallet.Vol); Console.WriteLine("PERCENTAGE OF PALLET VOLUME USED : {0:0.000}", pallet_volume_used_percentage); Console.WriteLine("PERCENTAGE OF PACKEDBOXES (VOLUME) : {0:0.000}", packed_box_percentage); Console.WriteLine("WHILE PALLET ORIENTATION : X={0}; Y={1}; Z= {2}", pallet.Pallet_x, pallet.Pallet_y, pallet.Pallet_z); Console.WriteLine(); foreach (var variant in best_iterations.Keys) { Console.WriteLine("{0} {1} -> {2}", variant, best_iterations[variant].Key, best_iterations[variant].Value); } }
public void Run(BoxItem[] listBoxItem, decimal palletLength, decimal palletWidth, decimal palletHeight, ref SolutionArray solArray) { packing = true; // boxes foreach (BoxItem bi in listBoxItem) { for (int i = 0; i < bi.N; ++i) { boxList.Add(new BoxInfo() { ID = bi.ID, Dim1 = bi.Boxx, Dim2 = bi.Boxy, Dim3 = bi.Boxz, N = bi.N }); } } // pallet pallet = new PalletInfo(palletLength, palletWidth, palletHeight); // output file if (string.IsNullOrEmpty(OutputFilePath)) { fso = null; } else { fso = new StreamWriter(OutputFilePath, true); } TimeStart = DateTime.Now; Initialize(); Execute_iterations(); TimeStop = DateTime.Now; Report_results2(ref solArray); }