src/main/java/dev/rsoliveira/tools/binpacking/simulation/PalletPackingSimulation.java
/**
     * Given a container, for each container orientation iterate all possible layers to fill it and find the best iteration.
     * The execution finishes when, on a given iteration, all items are packed.
     *
     * @param state the packing state.
     */
Given a container, for each container orientation iterate all possible layers to fill it and find the best iteration.
The execution finishes when, on a given iteration, all items are packed.

@param state the packing state.
Given a container for each container orientation iterate all possible layers to fill it and find the best iteration . The execution finishes when on a given iteration all items are packed . @param state the packing state .
private void iterate(PalletPackingState state) {
        int maxContainerOrientation;
        switch (state.getContainer().getRotation()) {
            case FULL:
                maxContainerOrientation = 6;
                break;
            case HORIZONTAL:
                maxContainerOrientation = 2;
                break;
            case NONE:
            default:
                maxContainerOrientation = 1;
                break;
        }
        int packedy;
        state.setBestVolume(0.0);
        for (int containerOrientation = 1; containerOrientation <= maxContainerOrientation; containerOrientation++) {
            Volume orientation = state.getContainer().atOrientation(containerOrientation);
            List<Layer> layers = listCandidateLayers(state, orientation);
            for (int layersindex = 1; layersindex < layers.size(); layersindex++) {
                packedy = 0;
                state.restartPacking();
                state.resetThickness(layers.get(layersindex).getDimension(), orientation.getDimension2(), orientation.getDimension3());
                iterationCore(state, packedy, orientation);
                state.validateBestState(containerOrientation, layersindex);
                if (state.isHundredPercentPacked()) {
                    break;
                }
            }
            if (state.isHundredPercentPacked()) {
                break;
            }
            if (state.getContainer().isCubic()) {
                containerOrientation = 6;
            }
        }
    }
private void iterate ( PalletPackingState state ) { int maxContainerOrientation ; switch ( state . getContainer ( ) . getRotation ( ) ) { case FULL : maxContainerOrientation = 6 ; break ; case HORIZONTAL : maxContainerOrientation = 2 ; break ; case NONE : default : maxContainerOrientation = 1 ; break ; } int packedy ; state . setBestVolume ( 0.0 ) ; for ( int containerOrientation = 1 ; containerOrientation <= maxContainerOrientation ; containerOrientation ++ ) { Volume orientation = state . getContainer ( ) . atOrientation ( containerOrientation ) ; List < Layer > layers = listCandidateLayers ( state , orientation ) ; for ( int layersindex = 1 ; layersindex < layers . size ( ) ; layersindex ++ ) { packedy = 0 ; state . restartPacking ( ) ; state . resetThickness ( layers . get ( layersindex ) . getDimension ( ) , orientation . getDimension2 ( ) , orientation . getDimension3 ( ) ) ; iterationCore ( state , packedy , orientation ) ; state . validateBestState ( containerOrientation , layersindex ) ; if ( state . isHundredPercentPacked ( ) ) { break ; } } if ( state . isHundredPercentPacked ( ) ) { break ; } if ( state . getContainer ( ) . isCubic ( ) ) { containerOrientation = 6 ; } } }
Given a container, for each container orientation iterate all possible layers to fill it and find the best iteration.
Given a container for each container orientation iterate all possible layers to fill it and find the best iteration .