skjolber / 3d-bin-container-packing

A variant of the Largest Area Fit First (LAFF) algorithm + brute force algorithm
Apache License 2.0
433 stars 119 forks source link

add StackableItem with different order lead to different result #873

Closed littlebox692 closed 7 months ago

littlebox692 commented 8 months ago

` @Test public void testPackager2(){ Container container = Container.newBuilder() .withDescription("anything") .withSize(90, 60, 120) .withEmptyWeight(1) .withMaxLoadWeight(100) .build();

    List<ContainerItem> containerItems = ContainerItem
            .newListBuilder()
            .withContainer(container,1)
            .build();

    LargestAreaFitFirstPackager packager = LargestAreaFitFirstPackager
            .newBuilder()
            .build();

    List<StackableItem> products = new ArrayList<>();

    // this will be failed
    products.add(new StackableItem(Box.newBuilder().withSize((int)Math.ceil(90), (int)Math.ceil(50), (int)Math.ceil(30)).withRotate3D().withWeight(1).withDescription("fff").build(), 1));
    products.add(new StackableItem(Box.newBuilder().withSize((int)Math.ceil(90), (int)Math.ceil(50), (int)Math.ceil(30)).withRotate3D().withWeight(1).withDescription("fff").build(), 1));
    products.add(new StackableItem(Box.newBuilder().withSize((int)Math.ceil(120), (int)Math.ceil(60), (int)Math.ceil(40)).withRotate3D().withWeight(1).withDescription("fff").build(), 1));

    // TODO this will be succeed

    // products.add(new StackableItem(Box.newBuilder().withSize((int)Math.ceil(120), (int)Math.ceil(60), (int)Math.ceil(40)).withRotate3D().withWeight(1).withDescription("fff").build(), 1));
    // products.add(new StackableItem(Box.newBuilder().withSize((int)Math.ceil(90), (int)Math.ceil(50), (int)Math.ceil(30)).withRotate3D().withWeight(1).withDescription("fff").build(), 1));
    // products.add(new StackableItem(Box.newBuilder().withSize((int)Math.ceil(90), (int)Math.ceil(50), (int)Math.ceil(30)).withRotate3D().withWeight(1).withDescription("fff").build(), 1));

    PackagerResult result = packager
            .newResultBuilder()
            .withContainers(containerItems)
            .withMaxContainerCount(1)
            .withStackables(products)
            .build();
    if(result.isSuccess()) {
        System.out.println("=======succeed=====");
    } else {
        System.out.println("=======failed=======");
    }

` why i need to deal with StackableItem added order with myself, not this lib? that's very ridiculous

skjolber commented 7 months ago

The LAFF packager is not intelligent, it is most like "happy go lucky".