Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/16 17:12:15 (6 years ago)
Author:
gkronber
Message:

#1966 restored functionality after splitting into 2d and 3d problems

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

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/RectangularIdenticalBinPackingProblem.cs

    r13611 r14039  
    3434using HeuristicLab.Problems.Instances;
    3535using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
     36using HeuristicLab.Data;
     37using System;
    3638
    3739namespace HeuristicLab.Problems.BinPacking.Problem {
     
    101103    }
    102104
     105    #region Problem instance handling
     106    public override void Load(BPPData data) {
     107      var realData = data as RealBPPData;
     108      var binData = new RectangularPackingBin(data.BinMeasures[0], data.BinMeasures[1]);
     109
     110      var itemData = new ItemList<RectangularPackingItem>(data.Items);
     111      for (int j = 0; j < data.Items; j++) {
     112        var bin = new RectangularPackingBin(data.BinMeasures[0], data.BinMeasures[1]);
     113        var item = new RectangularPackingItem(data.ItemMeasures[j][0], data.ItemMeasures[j][1], bin);
     114        if (realData != null) {
     115          item.Weight = realData.ItemWeights[j];
     116          item.Material = realData.ItemMaterials[j];
     117        }
     118        itemData.Add(item);
     119      }
     120
     121      BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
     122
     123      PackingBinMeasures = binData;
     124      PackingItemMeasures = itemData;
     125
     126      ApplyHorizontalOrientation();
     127      SortItems();
     128      PackingItemsParameter.Value.Value = PackingItemMeasures.Count;
     129      LowerBoundParameter.Value.Value = CalculateLowerBound();
     130    }
     131
     132
     133    public override BPPData Export() {
     134      var result = new BPPData {
     135        Name = Name,
     136        Description = Description,
     137        Items = PackingItemsParameter.Value.Value,
     138        BinMeasures = new int[] { PackingBinMeasures.Width, PackingBinMeasures.Height }
     139      };
     140
     141      var itemMeasures = new int[result.Items][];
     142      int i = 0;
     143      foreach (var item in PackingItemMeasures) {
     144        itemMeasures[i] = new int[] { item.Width, item.Height };
     145        i++;
     146      }
     147      result.ItemMeasures = itemMeasures;
     148      return result;
     149    }
     150    #endregion
    103151
    104152    #region Helpers
     
    107155
    108156      PackingSolutionDecoderParameter.ValidValues.Clear();
    109       if (SolutionCreator is PackingSequenceRandomCreator) {       
     157      if (SolutionCreator is PackingSequenceRandomCreator) {
    110158        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DPSDecoder>());
    111       } else if (SolutionCreator is GroupingVectorRandomCreator) { 
     159      } else if (SolutionCreator is GroupingVectorRandomCreator) {
    112160        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DGVDecoder>());
    113       } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 
     161      } else if (SolutionCreator is MultiComponentVectorRandomCreator) {
    114162        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DMCVDecoder>());
    115163      } else {
     
    120168
    121169    protected override IPackingPlanEvaluator CreateDefaultEvaluator() {
    122       return new PackingRatioRectangularIdenticalBinEvaluator ();
     170      return new PackingRatioRectangularIdenticalBinEvaluator();
    123171    }
    124172
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/RectangularPackingItem.cs

    r13606 r14039  
    6969    public RectangularPackingItem(int width, int height, RectangularPackingBin targetBin)
    7070      : this() {
    71       this.Weight = width;
     71      this.Width = width;
    7272      this.Height = height;
    7373      this.TargetBin = (RectangularPackingBin)targetBin.Clone();
Note: See TracChangeset for help on using the changeset viewer.