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.2D/3.3/Problem.cs

    r14054 r14055  
    4444      Name = "2D BPP Default Instance",
    4545      Description = "The default instance for 2D Bin Packing.",
    46       BinMeasures = new int[] { 20, 16 },
    47       ItemMeasures = new int[][] {
    48         new int[] {3,8},
    49         new int[] {5,3},
    50         new int[] {9,3},
    51         new int[] {2,7},
    52         new int[] {5,3},
    53         new int[] {9,3},
    54         new int[] {2,7},
    55         new int[] {5,3},
    56         new int[] {9,3},
    57         new int[] {2,7},
    58         new int[] {5,3},
    59         new int[] {9,3},
    60         new int[] {2,7},
    61         new int[] {5,3},
    62         new int[] {9,3},
    63         new int[] {2,7},
    64         new int[] {5,3},
    65         new int[] {9,3},
    66         new int[] {2,7},
    67         new int[] {5,3},
    68         new int[] {9,3},
    69         new int[] {2,7},
    70         new int[] {5,3},
    71         new int[] {9,3},
    72         new int[] {2,7},
    73         new int[] {5,3},
    74         new int[] {9,3},
    75         new int[] {2,7},
    76         new int[] {5,3},
    77         new int[] {9,3},
    78         new int[] {2,7},
    79         new int[] {5,3},
    80         new int[] {9,3},
    81         new int[] {2,7},
    82         new int[] {5,3},
    83         new int[] {9,3},
    84         new int[] {2,7}
     46      BinShape = new PackingShape(20, 16),
     47      Items = new PackingItem[] {
     48        new PackingItem(3,  8, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     49        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     50        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     51        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     52        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     53        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     54        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     55        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     56        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     57        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     58        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     59        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     60        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     61        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     62        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     63        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     64        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     65        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     66        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     67        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     68        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     69        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     70        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     71        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     72        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     73        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     74        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     75        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     76        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     77        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     78        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     79        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     80        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     81        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     82        new PackingItem(5,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     83        new PackingItem(9,  3, new PackingShape(20, 16)) { Material = 1, Weight = 1.0},
     84        new PackingItem(2,  7, new PackingShape(20, 16)) { Material = 1, Weight = 1.0}
    8585      },
    86       Items = 30
    8786    };
    8887    #endregion
     
    9190    protected Problem(bool deserializing) : base(deserializing) { }
    9291    protected Problem(Problem original, Cloner cloner)
    93       : base(original, cloner) {
     92          : base(original, cloner) {
    9493    }
    9594    public override IDeepCloneable Clone(Cloner cloner) {
     
    9796    }
    9897    public Problem() : base(
    99       new DecodingEvaluator<Permutation, PackingPosition, PackingShape, PackingItem>()) {
     98          new DecodingEvaluator<Permutation, PackingPosition, PackingShape, PackingItem>()) {
    10099    }
    101100
    102101    #region Problem instance handling
    103102    public void Load(BPPData data) {
    104       var realData = data as RealBPPData;
    105       var binData = new PackingShape(data.BinMeasures[0], data.BinMeasures[1]);
    106 
    107       var itemData = new ItemList<PackingItem>(data.Items);
    108       for (int j = 0; j < data.Items; j++) {
    109         var bin = new PackingShape(data.BinMeasures[0], data.BinMeasures[1]);
    110         var item = new PackingItem(data.ItemMeasures[j][0], data.ItemMeasures[j][1], bin);
    111         if (realData != null) {
    112           item.Weight = realData.ItemWeights[j];
    113           item.Material = realData.ItemMaterials[j];
    114         }
    115         itemData.Add(item);
    116       }
    117103
    118104      BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
    119105
    120       PackingBinMeasures = binData;
    121       PackingItemMeasures = itemData;
     106      PackingBinMeasures = data.BinShape;
     107      PackingItemMeasures = new ItemList<PackingItem>(data.Items);
    122108
    123109      ApplyHorizontalOrientation();
     
    129115
    130116    public BPPData Export() {
    131       var result = new BPPData {
     117      return new BPPData {
    132118        Name = Name,
    133119        Description = Description,
    134         Items = PackingItemsParameter.Value.Value,
    135         BinMeasures = new int[] { PackingBinMeasures.Width, PackingBinMeasures.Height }
     120        BinShape = PackingBinMeasures,
     121        Items = PackingItemMeasures.ToArray()
    136122      };
    137 
    138       var itemMeasures = new int[result.Items][];
    139       int i = 0;
    140       foreach (var item in PackingItemMeasures) {
    141         itemMeasures[i] = new int[] { item.Width, item.Height };
    142         i++;
    143       }
    144       result.ItemMeasures = itemMeasures;
    145       return result;
    146123    }
    147124    #endregion
Note: See TracChangeset for help on using the changeset viewer.