Skip to content

Could've placed items in bin but 3 of them are in unfitted #9

@MohamedSaid99-Dev

Description

@MohamedSaid99-Dev

I have gone through this case, and it's obvious that the Items could be just over each other but the algorithm is putting 3 of them in UnfittedItems, here is the case:

This is the bin and the items:

new Bin('medium-bin-identifier', 26.5, 19.5, 20, 25)

new Item('item-id-10', 24, 17, 4, 1.5),
new Item('item-id-11', 24, 17, 2, 1.1),
new Item('item-id-12', 24, 17, 2.6, 0.8),
new Item('item-id-13', 24, 17, 2.6, 0.8),
new Item('item-id-14', 24, 17, 2.6, 0.8),
new Item('item-id-15', 24, 17, 2.6, 0.8)

And when I try to pack them inside the bin either with looping through the items and using the
$packager->packItemToBin($item,$bin)

or directly using
$packager->withFirstFit()->pack()

Only the items 10, 11, 12 fit. The 13 14 15 don't fit

When it's obvious that all the items have the same length and height which are less than the bin length and height, and the total breadth is less than the bin breadth. And the total weight is less than the bin max weight.
So the algorithm start stacking the books successfully until it reaches the 13th item, it fails to add it, but this is false.

This is the result:

{
  "medium-bin-identifier": {
    "id": "medium-bin-identifier",
    "length": 26.5,
    "breadth": 20,
    "height": 19.5,
    "volume": 10335,
    "weight": 25,
    "fittedItems": [
      {
        "id": "item-id-11",
        "length": 24,
        "breadth": 2,
        "height": 17,
        "volume": 816,
        "weight": 1.1,
        "rotationType": 0,
        "position": {
          "x-axis": 0,
          "y-axis": 0,
          "z-axis": 0
        }
      },
      {
        "id": "item-id-12",
        "length": 24,
        "breadth": 2.6,
        "height": 17,
        "volume": 1060.8,
        "weight": 0.8,
        "rotationType": 0,
        "position": {
          "x-axis": 0,
          "y-axis": 0,
          "z-axis": 2
        }
      },
      {
        "id": "item-id-10",
        "length": 24,
        "breadth": 4,
        "height": 17,
        "volume": 1632,
        "weight": 1.5,
        "rotationType": 0,
        "position": {
          "x-axis": 0,
          "y-axis": 0,
          "z-axis": 4.6
        }
      }
    ],
    "totalFittedVolume": 3508.8,
    "totalFittedWeight": 3.4000000000000004,
    "unfittedItems": [
      {
        "id": "item-id-13",
        "length": 24,
        "breadth": 2.6,
        "height": 17,
        "volume": 1060.8,
        "weight": 0.8,
        "rotationType": 0,
        "position": {
          "x-axis": 0,
          "y-axis": 0,
          "z-axis": 0
        }
      },
      {
        "id": "item-id-14",
        "length": 24,
        "breadth": 2.6,
        "height": 17,
        "volume": 1060.8,
        "weight": 0.8,
        "rotationType": 0,
        "position": {
          "x-axis": 0,
          "y-axis": 0,
          "z-axis": 0
        }
      },
      {
        "id": "item-id-15",
        "length": 24,
        "breadth": 2.6,
        "height": 17,
        "volume": 1060.8,
        "weight": 0.8,
        "rotationType": 0,
        "position": {
          "x-axis": 0,
          "y-axis": 0,
          "z-axis": 0
        }
      }
    ],
    "totalUnfittedVolume": 3182.3999999999996,
    "totalUnfittedWeight": 2.4000000000000004
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions