280 likes | 368 Views
Generalized BPP. Guido Perboli (guido.perboli@polito.it) DAUIN - Politecnico di Torino. Problem. Set of items Volume v i Set of bins Maximum loadable volume V j Cost c j Use the mix of containers of minimum cost All the items are loaded
E N D
Generalized BPP Guido Perboli (guido.perboli@polito.it) DAUIN - Politecnico di Torino
Problem • Set of items • Volume vi • Set of bins • Maximum loadable volume Vj • Cost cj • Use the mix of containers of minimum cost • All the items are loaded • For each used bin, the volume of the items is at most the maximum loadable volume Generalized BPP
Formulation Generalized BPP
LB for GBPP • Consider to continuously load the items • Choose the bins such that the volume of the bins is at least the total volume of the items • We can write this problem as a minimization Knapsack (Min KP) • Consider the bins as the items in the Min KP • Consider as the size of the Knapsack the total volume of the GBPP items Generalized BPP
LB for GBPP Generalized BPP
LB for GBPP • We have a lot of specific codes to solve the Max KP • We can rewrite the Min KP as a Max KP • Substitute zj=1-yj • zj is 1 if the bin is not used Generalized BPP
LB for GBPP Generalized BPP
LB for GBPP Generalized BPP
UB for the GBPP: BFD heuristics • Order the bins by non-decreasing costs (and non-increasing volume if the costs are equal) • Order the items by non-increasing volumes • For each item i • Load i in the best partially loaded bin • If i cannot be loaded in any bin • Add a new bin and load i in it Generalized BPP
New Solution Local Search StoppingConditions Yes Exit Init Sol by Constructive Heur. Constructive Heur No Non ImprovingIter. Limit Yes No Init Scores Sort Attributesby Score Update Scores Reinit Scores Shopkeeper Algorithm Scheme Generalized BPP
What do you have to define? • Stopping criteria • Common: max 1 second of CPU per instance • Others: to be defined • Scoring initialization • As in the example (given by the loading of the initial solution) • Optional: redefine it • Short term update • Start with your assignments • Modify them in order to obtain the best results • Long term update (optional) Generalized BPP
Hypothesis • Item 1 first element in the item list • Number of items N • Number of Bins in the solution B Generalized BPP
Sliding Generalized BPP
Grasp- Like • Already implemented in the online code • Cycling on all the items: • i: current item, • Randomly choose an item k between i and i+d • If k in not i, swap the scores of i and k Generalized BPP
Substring Swap • Choose an item i between item 1 and M • M is a parameter, initially set to N/2 • Choose an item j between item M+1 and N • For k=0 to d • Swap the scores of item i+k and j+k • d is another parameter (initial value 3) Generalized BPP
Substring Swap 2 • Choose an item i between item 1 and M • M is a parameter, initially set to N/2 • Choose an item j between item M+1 and N • For k=0 to d • Swap the scores of item i+k and j+d-k • d is another parameter (initial value 3) Generalized BPP
Worst Bins First • Get the k worst bins (initial value 3) • Bins with largest residual space • Increase the scores of the items in these bins the best scoring by a parameter a (initial value 0.3) Generalized BPP
Best Bins Last • Get the k best bins (initial value 3) • Bins with smallest residual space • Decrease the scores of the items in these bins the best scoring by a parameter a (initial value 0.3) Generalized BPP
Work material & Laboratories • Code • Visual Studio 2005 solution file • Instance data • Batch to make the tests (prove_totali.bat) Generalized BPP
Executable parameters • -if instancefile • -lf logfile (log the main data in csv format compatible with Excel • Example • -if data\monaci\prob_1_A_0_4.txt -lf miolog.csv Generalized BPP
Core code • All the instance data are in mydata • All the method-based data are in kpGlobalData • computeLBKnapsack: compute the LB • computeBFD: compute the BFD solution • First parameter: mydata • Second parameter: list of items pointer • computeBFDFromLb • Compute an UB intializing the list of the bins with the bins given by the LB Generalized BPP
Additional code • copySolution: function that copies a solution on another (the two pointers must be already allocaed) • Common defines • File commonDefines.h • _MYDEBUG_ • If not commented, activate the debug code (you must recompile) • _MYDEBUG_SOL • If not commented, activate the usage of the isFeasible member of the solution class in order to check if a solution is formally correct • computeBFDGrasp • Function using a GRASP like BFD heuristic where the item list is randomly perturbed Generalized BPP
Warnings • When you move your files on another computer you can have problems due to subversions of the libraries Generalized BPP
How to compile in release mode Generalized BPP
How to debug Generalized BPP