Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/21/16 13:03:42 (8 years ago)
Author:
gkronber
Message:

#1966: added abstract problem and move evaluator classes and implemented 2d bin packing problem based on integer vector encoding

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs

    r14146 r14151  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Collections;
    28 using HeuristicLab.Problems.BinPacking;
    2928
    30 namespace HeuristicLab.Encodings.PackingEncoding {
     29namespace HeuristicLab.Problems.BinPacking {
    3130  [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")]
    3231  [StorableClass]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs

    r14146 r14151  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Collections;
    29 using HeuristicLab.Problems.BinPacking;
    3029
    31 namespace HeuristicLab.Encodings.PackingEncoding {
     30namespace HeuristicLab.Problems.BinPacking {
    3231  [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")]
    3332  [StorableClass]
     
    145144    }
    146145    public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) {
    147       var sequenceMatrix = solution.GenerateSequenceMatrix();
    148 
    149       //Fill bins according to grouping vector
    150       List<int> remainingIDs = new List<int>();
    151       foreach (var sequence in sequenceMatrix) {
    152         remainingIDs = remainingIDs.Concat(sequence).ToList();
    153         var bp = NewBinPacking();
    154         if (!UseExtremePoints)
    155           bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
    156         else
    157           bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
    158         BinPackings.Add(bp);
    159       }
    160       UpdateBinPackings();
    161 
    162       //Try to put remaining items in existing bins
    163       var temp = new List<int>(remainingIDs);
    164       foreach (int id in temp) {
    165         foreach (var bp in BinPackings) {
    166           var position = UseExtremePoints ? bp.FindExtremePointForItem(itemMeasures[id], false, StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], false);
    167           if (position != null) {
    168             bp.PackItem(id, itemMeasures[id], position);
    169             remainingIDs.Remove(id);
    170             break;
    171           }
    172         }
    173       }
    174 
    175       //Put still remaining items in new bins
    176       while (remainingIDs.Count > 0) {
    177         var bp = NewBinPacking();
    178         if (!UseExtremePoints)
    179           bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
    180         else
    181           bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
    182         BinPackings.Add(bp);
    183       }
    184       UpdateBinPackings();
    185 
    186       var newSolution = new int[solution.GroupingVector.Length];
    187       int binIndex = 0;
    188       foreach (var bp in BinPackings) {
    189         foreach (var entry in bp.ItemPositions)
    190           newSolution[entry.Key] = binIndex;
    191         binIndex++;
    192       }
    193       solution.GroupingVector = new IntegerVector(newSolution);
    194146    }
    195147     *
    196148     
    197     public void Pack(Permutation solution, ItemList<I> itemMeasures) {
    198       List<int> remainingIDs = new List<int>(solution);
    199       while (remainingIDs.Count > 0) {
    200         var bp = NewBinPacking();
    201         if (!UseExtremePoints)
    202           bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
    203         else
    204           bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
    205         BinPackings.Add(bp);
    206       }
    207       UpdateBinPackings();
    208     }
    209149
    210150    */
Note: See TracChangeset for help on using the changeset viewer.