Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************
- for generating trucks and boxes
- **************/
- public static ArrayList<Box> generateBoxes(int size)
- {
- ArrayList<Box> boxes = new ArrayList<Box>();
- for (int i = 0; i < size; i ++)
- {
- boxes.add(new Box(generateWidth(), generateHeight(),
- generateColour()));
- }
- return boxes;
- }
- public static ArrayList<Truck> generateTrucks(int size)
- {
- ArrayList<Truck> trucks = new ArrayList<Truck>();
- for (int i = 0; i < size; i ++)
- {
- trucks.add(new Truck(LaunchPlatform.getTruckWidth(), LaunchPlatform
- .getTruckHeight()));
- }
- return trucks;
- }
- /*************
- end for generating trucks and boxes
- **************/
- /*************
- for running algorithms
- **************/
- // Generate trucks
- onlineTrucks = TheGenerator.generateTrucks(numberOfBoxes);
- offlineTrucks = new ArrayList<Truck>(onlineTrucks);
- Collections.copy(offlineTrucks, onlineTrucks);
- // Generate boxes
- onlineBoxes = TheGenerator.generateBoxes(numberOfBoxes);
- offlineBoxes = new ArrayList<Box>(onlineBoxes);
- Collections.copy(offlineBoxes, onlineBoxes);
- // Run online algorithm and save the "solution"
- Solution onlineSolution = FirstFitAlgorithms.online(onlineTrucks, onlineBoxes);
- // Run offline algorithm and save the "solution"
- Solution offlineSolution = FirstFitAlgorithms.offline(offlineTrucks, offlineBoxes);
- // Clear all arraylists (in case user clicks 'run' button more than once)
- offlineTrucks.clear();
- onlineTrucks.clear();
- onlineBoxes.clear();
- offlineBoxes.clear();
- /*************
- end for running algorithms
- **************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement