Ignore:
Timestamp:
07/13/16 09:30:01 (5 years ago)
Author:
gkronber
Message:

#1966: simplified parsers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Problem.cs

    r14054 r14055  
    3737  [StorableClass]
    3838  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 310)]
    39   // TODO don't support generic BPPData but only 3d BPPData
    4039  public class Problem : Problem<PackingPosition, PackingShape, PackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> {
    41 
    42 
    4340    #region Default Instance
    4441    private static readonly BPPData DefaultInstance = new BPPData() {
    4542      Name = "3D BPP Default Instance",
    4643      Description = "The default instance for 3D Bin Packing.",
    47       BinMeasures = new int[] { 25, 25, 35 },
    48       ItemMeasures = new int[][] {
    49         new int[] {12,5,10},
    50         new int[] {10,18,20},
    51         new int[] {9,7,7},
    52         new int[] {21,12,4},
    53         new int[] {8,8,12},
    54         new int[] {3,6,14},
    55         new int[] {20,4,9},
    56         new int[] {5,9,8},
    57         new int[] {7,17,3},
    58         new int[] {13,20,15},
    59         new int[] {9,11,9},
    60         new int[] {10,18,20},
    61         new int[] {9,7,7},
    62         new int[] {21,12,4},
    63         new int[] {8,8,12},
    64         new int[] {3,6,14},
    65         new int[] {20,4,9},
    66         new int[] {5,9,8},
    67         new int[] {7,17,3},
    68         new int[] {13,20,15},
    69         new int[] {9,11,9},
    70         new int[] {10,18,20},
    71         new int[] {9,7,7},
    72         new int[] {21,12,4},
    73         new int[] {8,8,12},
    74         new int[] {3,6,14},
    75         new int[] {20,4,9},
    76         new int[] {5,9,8},
    77         new int[] {7,17,3},
    78         new int[] {13,20,15},
    79         new int[] {9,11,9},
    80         new int[] {10,18,20},
    81         new int[] {9,7,7},
    82         new int[] {21,12,4},
    83         new int[] {8,8,12},
    84         new int[] {3,6,14},
    85         new int[] {20,4,9},
    86         new int[] {5,9,8},
    87         new int[] {7,17,3},
    88         new int[] {13,20,15},
    89         new int[] {9,11,9}
     44      BinShape = new PackingShape(25, 25, 35),
     45      Items = new PackingItem[] {
     46        new PackingItem(12,5,10, new PackingShape(25,25,35)),
     47        new PackingItem(10,18,20, new PackingShape(25,25,35)),
     48        new PackingItem(9,7,7, new PackingShape(25,25,35)),
     49        new PackingItem(21,12,4, new PackingShape(25,25,35)),
     50        new PackingItem(8,8,12, new PackingShape(25,25,35)),
     51        new PackingItem(3,6,14, new PackingShape(25,25,35)),
     52        new PackingItem(20,4,9, new PackingShape(25,25,35)),
     53        new PackingItem(5,9,8, new PackingShape(25,25,35)),
     54        new PackingItem(7,17,3, new PackingShape(25,25,35)),
     55        new PackingItem(13,20,15, new PackingShape(25,25,35)),
     56        new PackingItem(9,11,9, new PackingShape(25,25,35)),
     57        new PackingItem(10,18,20, new PackingShape(25,25,35)),
     58        new PackingItem(9,7,7, new PackingShape(25,25,35)),
     59        new PackingItem(21,12,4, new PackingShape(25,25,35)),
     60        new PackingItem(8,8,12, new PackingShape(25,25,35)),
     61        new PackingItem(3,6,14, new PackingShape(25,25,35)),
     62        new PackingItem(20,4,9, new PackingShape(25,25,35)),
     63        new PackingItem(5,9,8, new PackingShape(25,25,35)),
     64        new PackingItem(7,17,3, new PackingShape(25,25,35)),
     65        new PackingItem(13,20,15, new PackingShape(25,25,35)),
     66        new PackingItem(9,11,9, new PackingShape(25,25,35)),
     67        new PackingItem(10,18,20, new PackingShape(25,25,35)),
     68        new PackingItem(9,7,7, new PackingShape(25,25,35)),
     69        new PackingItem(21,12,4, new PackingShape(25,25,35)),
     70        new PackingItem(8,8,12, new PackingShape(25,25,35)),
     71        new PackingItem(3,6,14, new PackingShape(25,25,35)),
     72        new PackingItem(20,4,9, new PackingShape(25,25,35)),
     73        new PackingItem(5,9,8, new PackingShape(25,25,35)),
     74        new PackingItem(7,17,3, new PackingShape(25,25,35)),
     75        new PackingItem(13,20,15, new PackingShape(25,25,35)),
     76        new PackingItem(9,11, 9,new PackingShape(25,25,35)),
     77        new PackingItem(10,18,20, new PackingShape(25,25,35)),
     78        new PackingItem(9,7,7, new PackingShape(25,25,35)),
     79        new PackingItem(21,12,4, new PackingShape(25,25,35)),
     80        new PackingItem(8,8,12, new PackingShape(25,25,35)),
     81        new PackingItem(3,6,14, new PackingShape(25,25,35)),
     82        new PackingItem(20,4,9, new PackingShape(25,25,35)),
     83        new PackingItem(5,9,8, new PackingShape(25,25,35)),
     84        new PackingItem(7,17,3, new PackingShape(25,25,35)),
     85        new PackingItem(13,20,15, new PackingShape(25,25,35)),
     86        new PackingItem(9,11,9, new PackingShape(25,25,35))
    9087      },
    91       Items = 30
    9288    };
    9389    #endregion
     
    105101    }
    106102
     103    public void Load(BPPData data) {
    107104
    108 
    109     public void Load(BPPData data) {
    110       var realData = data as RealBPPData;
    111       var binData = new PackingShape(data.BinMeasures[0], data.BinMeasures[1], data.BinMeasures[2]);
    112 
    113       var itemData = new ItemList<PackingItem>(data.Items);
    114       for (int j = 0; j < data.Items; j++) {
    115         var bin = new PackingShape(data.BinMeasures[0], data.BinMeasures[1], data.BinMeasures[2]);
    116         var item = new PackingItem(data.ItemMeasures[j][0], data.ItemMeasures[j][1], data.ItemMeasures[j][2], bin);
    117         if (realData != null) {
    118           item.Weight = realData.ItemWeights[j];
    119           item.Material = realData.ItemMaterials[j];
    120         }
    121         itemData.Add(item);
    122       }
    123105
    124106      BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
    125107
    126       PackingBinMeasures = binData;
    127       PackingItemMeasures = itemData;
     108      PackingBinMeasures = data.BinShape;
     109      PackingItemMeasures = new ItemList<PackingItem>(data.Items);
    128110
    129111      ApplyHorizontalOrientation();
     
    134116
    135117    public BPPData Export() {
    136       var result = new BPPData {
     118      return new BPPData {
    137119        Name = Name,
    138120        Description = Description,
    139         Items = PackingItemsParameter.Value.Value,
    140         BinMeasures = new int[] { PackingBinMeasures.Width, PackingBinMeasures.Height, PackingBinMeasures.Depth }
     121        BinShape = PackingBinMeasures,
     122        Items = PackingItemMeasures.ToArray()
    141123      };
    142 
    143       var itemMeasures = new int[result.Items][];
    144       int i = 0;
    145       foreach (var item in PackingItemMeasures) {
    146         itemMeasures[i] = new int[] { item.Width, item.Height, item.Depth };
    147         i++;
    148       }
    149       result.ItemMeasures = itemMeasures;
    150       return result;
    151124    }
    152125
Note: See TracChangeset for help on using the changeset viewer.