dvdoug / BoxPacker

4D bin packing / knapsack problem solver
MIT License
612 stars 156 forks source link

Request for Information on Streamlining Product Packing #558

Open mumairdeveloper opened 1 year ago

mumairdeveloper commented 1 year ago

Hello,

Thank you for providing this source class. I am using it for packing large pallets and small boxes. Please let me know if there is a way to pack all the products into a single box. I understand that I may have multiple products and multiple boxes, but I would like to select a single box type and, if necessary, repeat the quantity for this box due to having multiple products.

Thank you

dvdoug commented 1 year ago

If you wish to only use a single type of box even if multiple of that box are required, then you'll need to make multiple invocations to the library with a single box type each time

mumairdeveloper commented 1 year ago

Hi,

I comprehend the method of making multiple calls to the library, each time using a single box type. I have one final question: Are there any options or flags available to pack items in multiple small boxes, or to efficiently pack small items into the fewest large boxes possible?

Thank you

mumairdeveloper commented 1 year ago

Hi,

I'd like to pack the products in the smallest box possible. It's not an issue if the packing is done in one large suitable box.

Thank you.

dvdoug commented 1 year ago

By default, BoxPacker will use the smallest number of boxes. You can change this however if you want

https://boxpacker.io/en/stable/sortation.html#choosing-between-permutations

mumairdeveloper commented 1 year ago

Hi,

Apologies for reiterating, but I need to clarify my request. I'm looking for a method to consolidate all items into a single box, even if multiple items or boxes are involved. I prefer that all items be packed into a best-fit single box. If this isn't feasible and there's no option for a best-fit single box, please provide an error or an empty response.

Thank You

mumairdeveloper commented 1 year ago

Hi dvdoug,

I appreciate your assistance with my previous inquiries. I'm seeking guidance on a method to pack all items into a single box, even if there are multiple items or boxes involved. Your help on this matter is highly valuable.

Thank you.

dvdoug commented 1 year ago

Something like this (untested)

$packedBoxes = $packer->pack();

if ($packedBoxes->count() === 1) {
  return $packedBoxes; // only 1 box, is best fit
} else {
  $possibleSingleBoxSolutions = [];
  foreach ($packedBoxes as $packedBox) {
    $singleBoxPacker = new Packer();
    $singleBoxPacker->addBox($packedBox->getBox());
    $singleBoxPacker->setItems($itemList);
    $possibleSingleBoxSolutions[] = $packer->pack();
  }

  // your logic here to decide which one to use
  $chosenSingleBoxSolution = $possibleSingleBoxSolutions[0];

  return $chosenSingleBoxSolution;
}
mumairdeveloper commented 1 year ago

Hi,

Thank you so much for your response. I already have this code. I was wondering if you have set any flag for this type of functionality in the API. Okay, if I am going to use the same code, do you agree that it will pack the smallest best-fit single box, even if there are larger boxes also listed? That is the last thing.

Thank you.

dvdoug commented 1 year ago

Yes, in the scenario where all items fit into a 1 box, ->pack() will return the smallest possible such box

mumairdeveloper commented 1 year ago

Hi,

You are correct; perhaps that solution won't work. I have another solution: if I sort the list of boxes in ascending order and then check each box one by one from smallest to largest. Could you provide me with an example of this?

Thank you

dvdoug commented 1 year ago

You are correct; perhaps that solution won't work I'm not sure what you mean, I agreed with you

mumairdeveloper commented 1 year ago

Hello,

Sorry for the confusion. I have multiple types of boxes in my array, including medium, random, large, etc. However, they are arranged randomly in the array. I want to sort them all from small to medium and then large. I want to sort them in ascending order based on their size. Thank you.

dvdoug commented 1 year ago

That will be automatic, see https://github.com/dvdoug/BoxPacker/blob/3.x/src/DefaultBoxSorter.php for the precise implementation

mumairdeveloper commented 11 months ago

Hi Doug,

I hope this message finds you well. I have been actively exploring solutions to address my current challenges. Unfortunately, the previously suggested solutions have not proven effective in resolving the issue.

I'd like to propose a new idea: the implementation of a virtual box feature. The concept involves passing multiple items, each with its respective quantity, weight, and dimensions. Unlike the previous approach, I would not include a list of boxes in the request. Instead, I'm wondering if your library could generate a single virtual box. This virtual box would consolidate all the specified items, allowing me to obtain shipping rates more efficiently. The ultimate goal is to identify the most cost-effective rates by consolidating all items into a single box.

I'm eager to hear your thoughts on this proposed virtual box solution and would greatly appreciate any insights or solutions you can provide.

Thank you for your continued assistance.

dvdoug commented 11 months ago

See https://github.com/dvdoug/BoxPacker/issues/189

mumairdeveloper commented 11 months ago

Doug,

So, there is no solution yet in your library related to this? Perhaps you have added a solution similar to lojadev5 in issue #211 in your library. Please confirm.

I am using those things for shipping rates.

Thank you

dvdoug commented 11 months ago

No, virtual boxes is complicated for all of the reasons listed in that ticket, there is no built-in support for that at this time