Skip to content

Commit

Permalink
ACN:Add new Packing Algorithm. Bins are sorted to optimize bin choos…
Browse files Browse the repository at this point in the history
…ing.'
  • Loading branch information
Slashgear committed Apr 26, 2015
1 parent 602564a commit 7ae3603
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
*
* * Project to resolve 2D cutting stock problem for Discreet Optimizations course at Polytech Lyon
* * Copyright (C) 2015. CARON Antoine and CHAUSSENDE Adrien
* *
* * This program is free software: you can redistribute it and/or modify
* * it under the terms of the GNU Affero General Public License as
* * published by the Free Software Foundation, either version 3 of the
* * License, or (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* *
* * You should have received a copy of the GNU Affero General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package com.polytech4A.cuttingstock.core.packing;

import com.polytech4A.cuttingstock.core.model.Box;
import com.polytech4A.cuttingstock.core.model.PlacedBox;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

/**
* Created by Antoine CARON on 26/04/2015.
*
* @author Antoine CARON
* @version 1.0
*/
public class GuillotineSortBFFSortBin extends GuillotineSortBFF {

public GuillotineSortBFFSortBin(ArrayList<Comparator<Box>> boxComparators) {
super(boxComparators);
}

/**
* Place the box on the pattern.
*
* @param bins List of bins that will be generated.
* @param box Box to be placed.
* @return The box that is now placed. Return null if it can't be placed.
*/
@Override
public PlacedBox generatePlacedBox(ArrayList<Bin> bins, Box box) {
Collections.sort(bins);
return super.generatePlacedBox(bins, box);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.polytech4A.cuttingstock.core.model.Box;
import com.polytech4A.cuttingstock.core.model.Pattern;
import com.polytech4A.cuttingstock.core.model.Solution;
import com.polytech4A.cuttingstock.core.packing.GuillotineSortBFF;
import com.polytech4A.cuttingstock.core.packing.GuillotineSortBFFSortBin;
import com.polytech4A.cuttingstock.core.resolution.util.context.Context;
import com.polytech4A.cuttingstock.core.resolution.util.context.ContextLoaderUtils;
import com.polytech4A.cuttingstock.core.resolution.util.context.IllogicalContextException;
Expand Down Expand Up @@ -144,7 +144,7 @@ public void solve(Integer nbofIterations) {
}
generators.add(new RemovePatternNeighbour());
solver = new SimulatedAnnealing(
new GuillotineSortBFF(boxComparators),
new GuillotineSortBFFSortBin(boxComparators),
new LinearResolutionMethod(context),
generators,
nbofIterations
Expand All @@ -167,7 +167,7 @@ private Solution getStartingSolution() {
generators.add(new MoveNeighbour());
generators.add(new RemovePatternNeighbour());
SimulatedAnnealing realSolutionGenerator = new SimulatedAnnealing(
new GuillotineSortBFF(boxComparators),
new GuillotineSortBFFSortBin(boxComparators),
new LinearResolutionMethod(context),
generators,
10000);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
*
* * Project to resolve 2D cutting stock problem for Discreet Optimizations course at Polytech Lyon
* * Copyright (C) 2015. CARON Antoine and CHAUSSENDE Adrien
* *
* * This program is free software: you can redistribute it and/or modify
* * it under the terms of the GNU Affero General Public License as
* * published by the Free Software Foundation, either version 3 of the
* * License, or (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* *
* * You should have received a copy of the GNU Affero General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package com.polytech4A.cuttingstock.core.packing;

/**
* Created by Antoine CARON on 26/04/2015.
*
* @author Antoine CARON
* @version 1.0
*/
public class GuillotineSortBFFSortBinTest extends GuillotineSortBFFTest {
}

0 comments on commit 7ae3603

Please sign in to comment.