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

example.py output not reasonable #25

Open
RoyCLR opened this issue Jul 15, 2021 · 3 comments
Open

example.py output not reasonable #25

RoyCLR opened this issue Jul 15, 2021 · 3 comments

Comments

@RoyCLR
Copy link

RoyCLR commented Jul 15, 2021

Running the provide example.py gives:

***************************************************
::::::::::: large-box(12.000x12.000x5.500, max_weight:70.000) vol(792.000)
FITTED ITEMS:
====>  50g [powder 1](3.937x1.968x1.968, weight: 1.000) pos([0, 0, 0]) rt(0) vol(15.248)
====>  50g [powder 2](3.937x1.968x1.968, weight: 2.000) pos([Decimal('3.937'), 0, 0]) rt(0) vol(15.248)
====>  50g [powder 3](3.937x1.968x1.968, weight: 3.000) pos([Decimal('7.874'), 0, 0]) rt(0) vol(15.248)
====>  250g [powder 4](7.874x3.937x1.968, weight: 4.000) pos([Decimal('11.811'), 0, 0]) rt(0) vol(61.008)
====>  250g [powder 5](7.874x3.937x1.968, weight: 5.000) pos([Decimal('19.685'), 0, 0]) rt(1) vol(61.008)
====>  250g [powder 6](7.874x3.937x1.968, weight: 6.000) pos([0, Decimal('1.968'), 0]) rt(0) vol(61.008)
====>  250g [powder 7](7.874x3.937x1.968, weight: 7.000) pos([Decimal('11.811'), Decimal('3.937'), 0]) rt(0) vol(61.008)
====>  250g [powder 8](7.874x3.937x1.968, weight: 8.000) pos([0, Decimal('5.905'), 0]) rt(0) vol(61.008)
====>  250g [powder 9](7.874x3.937x1.968, weight: 9.000) pos([Decimal('7.874'), 0, Decimal('1.968')]) rt(5) vol(61.008)
UNFITTED ITEMS:
***************************************************

The position of the 5th item pos([Decimal('19.685'), 0, 0]) seems to be outside the box, which is set as 12.000x12.000x5.500

Is this a bug, or my understanding of the notation is wrong?

Run condition:
git checkout latest master
python 3.8.10

@datakira
Copy link

datakira commented Aug 5, 2021

Hi, I just visualized the code with python and Yes, I guess the Decimal data is wrong.
In the picture that I visualized, the boxes that should have been stacked on top are stacked sideways.
It's supposed to be stacked up, however in this code, it's stacked sideways.
That's why the result seems like it would sticking out of the box.

I mean, the calculations aren't wrong - item5 can be fitted in the large-box,
but I think the result is showing wrong data.
Thank you!

@XareniGalindo
Copy link

I have a similar problem with my data when I extract the information, the position locates the package outside the bin but the unfit items list is empty. Were any of you able to fix this issue?

@lairdrt
Copy link

lairdrt commented Apr 5, 2022

When the bins and items are created in the example.py file, only one copy of each item exists in the packer object. As the bins are packed, items are appended to the list of fitted/unfitted data structures (Bin.items[] and Bin.unfitted_items[]). The positions and rotations of the items are modified through each pass of the packer.pack() "for bin in self.bins:" loop. So by the end of packing all bins, the positions and rotations of the items are set to whatever was last assigned to each item. The fitted/unfitted lists are correct, but the positions and rotations are scrambled. If you want the lists to stay intact and keep the positions, you can copy the items before they are appended to the fitted lists inside the put_item() method:

import copy

# See if we cleared all other items
if fit:
    item_copy = copy.deepcopy(item)
    self.items.append(item_copy)
    return True

Now when I output the binned items, I get (after removing the decimal formatting methods):

::::::::::: large-box(12.0 x 12.0 x 5.5, max_weight:70.0) vol(792.0)
FITTED ITEMS:
====> 50g [powder 1](3.937 x 1.9685 x 1.9685, weight: 1) pos(0.0000, 0.0000, 0.0000) rt(0) vol(15.2558)
====> 50g [powder 2](3.937 x 1.9685 x 1.9685, weight: 2) pos(3.9370, 0.0000, 0.0000) rt(0) vol(15.2558)
====> 50g [powder 3](3.937 x 1.9685 x 1.9685, weight: 3) pos(7.8740, 0.0000, 0.0000) rt(1) vol(15.2558)
====> 250g [powder 4](7.874 x 3.937 x 1.9685, weight: 4) pos(0.0000, 1.9685, 0.0000) rt(0) vol(61.0234)
====> 250g [powder 5](7.874 x 3.937 x 1.9685, weight: 5) pos(7.8740, 3.9370, 0.0000) rt(1) vol(61.0234)
====> 250g [powder 6](7.874 x 3.937 x 1.9685, weight: 6) pos(0.0000, 5.9055, 0.0000) rt(0) vol(61.0234)
====> 250g [powder 7](7.874 x 3.937 x 1.9685, weight: 7) pos(0.0000, 0.0000, 1.9685) rt(0) vol(61.0234)
====> 250g [powder 8](7.874 x 3.937 x 1.9685, weight: 8) pos(7.8740, 0.0000, 1.9685) rt(1) vol(61.0234)
====> 250g [powder 9](7.874 x 3.937 x 1.9685, weight: 9) pos(0.0000, 3.9370, 1.9685) rt(0) vol(61.0234)
UNFITTED ITEMS:
***************************************************
***************************************************

You get similar output if you only have one bin as the item position/rotation data is still in tact.

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

4 participants