Coder Social home page Coder Social logo

3d-bin-packing-problem's People

Contributors

janet-19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

3d-bin-packing-problem's Issues

Some items reset to 0,0,0 during placement

def can_hold_item_with_rotation(self, item, pivot): 
        """Evaluate whether one item can be placed into bin with all optional orientations.
        Args:
            item: any item in item list.
            pivot: an (x, y, z) coordinate, the back-lower-left corner of the item will be placed at the pivot.
        Returns:
            a list containing all optional orientations. If not, return an empty list.
        """
        
        fit = False 
        valid_item_position = [0, 0, 0]
        item.position = pivot 
        rotation_type_list = [] 
        
        
        for i in range(0, len(RotationType.ALL)): 
            item.rotation_type = i 
            dimension = item.get_dimension() 
            if (
                pivot[0] + dimension[0] <= self.length and  # x-axis
                pivot[1] + dimension[1] <= self.width and  # y-axis
                pivot[2] + dimension[2] <= self.height     # z-axis
            ):
            
                fit = True
                
                for current_item_in_bin in self.items: 
                    if intersect(current_item_in_bin, item): 
                        fit = False
                        item.position = [0, 0, 0]
                        break 
                
                if fit: 
                    if self.get_total_weight() + item.weight > self.capacity: # estimate whether bin reaches its capacity
                        fit = False
                        item.position = [0, 0, 0]
                        continue 
                    
                    else: 
                        rotation_type_list.append(item.rotation_type) 
            
            else:
                continue 
        
        return rotation_type_list 

There is an error in the above function while it is looping through rotations checking for fitment. If a later rotation is found to not fit, either do to intersection or weight, the items position is 0'ed. This resets the item to the origin instead of it's pivot despite previous rotations that do work for the given pivot location. Simply not setting the position to 0,0,0 preserves the pivot location and the algorithm works correctly. There was some thought given to this given the unused valid_item_position variable I suspect.

Putting items in same place.

Hi, I'm surprised how you improved enzoruiz`s package. It's great work! But I find out some issue.. I trying to put 9 items in one box:

packer.add_bin(Bin('small-envelope', 35, 50, 40, 1))
packer.add_item(Item('item_1', 10, 7, 18, 0))
packer.add_item(Item('item_2', 10, 7, 18, 0))
packer.add_item(Item('item_3', 5, 6, 10, 0))
packer.add_item(Item('item_4', 5, 6, 10, 0))
packer.add_item(Item('item_5', 5, 6, 10, 0))
packer.add_item(Item('item_6', 20, 50, 12, 0))
packer.add_item(Item('item_7', 20, 50, 12, 0))
packer.add_item(Item('item_8', 20, 50, 12, 0))
packer.add_item(Item('item_9', 20, 50, 12, 0))

but items 'item_3', 'item_4', 'item_5' always putting at one place [0,0,0] :

::::::::::: small-envelope(35x50x40, max_weight:1) vol(70000) item_number(9) filling_ratio(1)
FITTED ITEMS:
====> item_6(20x50x12, weight: 0) pos([0, 0, 0]) rt(0) vol(12000)
====> item_7(20x50x12, weight: 0) pos([0, 0, Decimal('12')]) rt(2) vol(12000)
====> item_8(20x50x12, weight: 0) pos([Decimal('20'), 0, 0]) rt(2) vol(12000)
====> item_9(20x50x12, weight: 0) pos([Decimal('20'), 0, Decimal('20')]) rt(2) vol(12000)
====> item_1(10x7x18, weight: 0) pos([0, 0, Decimal('32')]) rt(1) vol(1260)
====> item_2(10x7x18, weight: 0) pos([0, Decimal('10'), Decimal('32')]) rt(1) vol(1260)
====> item_3(5x6x10, weight: 0) pos([0, 0, 0]) rt(0) vol(300)
====> item_4(5x6x10, weight: 0) pos([0, 0, 0]) rt(0) vol(300)
====> item_5(5x6x10, weight: 0) pos([0, 0, 0]) rt(0) vol(300)

I hope you resolve that issue:)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.