Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placement according to the most suitable length and width? #240

Open
fonteyazilim opened this issue May 13, 2021 · 4 comments
Open

Placement according to the most suitable length and width? #240

fonteyazilim opened this issue May 13, 2021 · 4 comments

Comments

@fonteyazilim
Copy link

Hi Sir,

First of all, thank you very much for the application, it is very successful.

However, I need a slight change in the insertion algorithm.
For parts, how can we always fill in the width and length in the most appropriate way?
How can you support this issue?
I have samples.

`

$packer = new Packer();

$packer->addBox(new TestBox('Le petite box', 220, 540, 1, 0, 220, 540, 1, 0));

$packer->addItem(new TestItem('1-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('2-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('3-60x100', 100,60, 1, 0, true), 1);
$packer->addItem(new TestItem('4-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('5-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('6-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('7-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('8-60x120', 120,60, 1, 0, true), 1);
$packer->addItem(new TestItem('9-60x160', 160,60, 1, 0, true), 1);
$packer->addItem(new TestItem('10-80x50', 50,80, 1, 0, true), 1);
$packer->addItem(new TestItem('11-80x60', 60,80, 1, 0, true), 1);
$packer->addItem(new TestItem('12-80x110', 110,80, 1, 0, true), 1);
$packer->addItem(new TestItem('13-90x160', 160,90, 1, 0, true), 1);
$packer->addItem(new TestItem('14-60x120', 120,60, 1, 0, true), 1);
$packer->addItem(new TestItem('15-60x80', 80,60, 1, 0, true), 1);
$packer->addItem(new TestItem('16-60x100', 100,60, 1, 0, true), 1);
$packer->addItem(new TestItem('17-60x120', 120,60, 1, 0, true), 1);
$packer->addItem(new TestItem('18-60x120', 120,60, 1, 0, true), 1);



$packedBoxes = $packer->pack();

echo "These items fitted into " . count($packedBoxes) . " box(es)<br>" . PHP_EOL;
foreach ($packedBoxes as $packedBox) {
    $boxType = $packedBox->getBox(); // your own box object, in this case TestBox
    echo "This box is a {$boxType->getReference()}, it is {$boxType->getOuterWidth()}mm wide, {$boxType->getOuterLength()}mm long and {$boxType->getOuterDepth()}mm high<br>" . PHP_EOL;
    echo "The combined weight of this box and the items inside it is {$packedBox->getWeight()}g<br>" . PHP_EOL;

    echo "The items in this box are:<br>" . PHP_EOL;
    $packedItems = $packedBox->getItems();
    foreach ($packedItems as $packedItem) { // $packedItem->getItem() is your own item object, in this case TestItem
        echo $packedItem->getItem()->getDescription()."<br>" . PHP_EOL;
    }
}

`

Result:

These items fitted into 2 box(es)
This box is a Le petite box, it is 220mm wide, 540mm long and 1mm high
The combined weight of this box and the items inside it is 0g
The items in this box are:
13-90x160
9-60x160
12-80x110
14-60x120
17-60x120
18-60x120
8-60x120
16-60x100
3-60x100
1-60x80
11-80x60
15-60x80
2-60x80
4-60x80
10-80x50
This box is a Le petite box, it is 220mm wide, 540mm long and 1mm high
The combined weight of this box and the items inside it is 0g
The items in this box are:
5-60x80
6-60x80
7-60x80

Placement possible sample image:
örnek görsel

Thanks.

@fonteyazilim
Copy link
Author

hi, i can pay to change the algorithm as i want.

@dvdoug
Copy link
Owner

dvdoug commented May 16, 2021

Hi @fonteyazilim

There is no perfect box-packing algorithm in existence, so like all such algorithms BoxPacker is essentially a set of heuristics which due to their very nature will sometimes pick the non-optimal result. I'll take a look at this specific example when I next have time.

@fonteyazilim
Copy link
Author

Hi @dvdoug
Thanks for your answer. I can pay for this development. The logic here always comes by filling the most suitable width according to the dimensions.

@fonteyazilim
Copy link
Author

Hi sir, Have you had a review on this?

dvdoug added a commit that referenced this issue Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants