Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

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

    r13608 r14039  
    4141  [Item("RegularIdenticalBinPackingProblem", "Represents a bin-packing problem-instance using only bins with identical measures and bins/items with regular shapes (e.g. rectangle, cuboid).")]
    4242  [StorableClass]
    43   public abstract class RegularIdenticalBinPackingProblem<D, B, I> : BinPackingProblem<D, B, I>, IProblemInstanceConsumer<BPPData>,  IProblemInstanceExporter<BPPData>
     43  public abstract class RegularIdenticalBinPackingProblem<D, B, I> : BinPackingProblem<D, B, I>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData>
    4444    where D : class, IPackingDimensions
    4545    where B : PackingShape<D>, IPackingBin, IRegularPackingShape, new()
    46     where I : PackingShape<D>, IPackingItem, IRegularPackingShape, new() {       
     46    where I : PackingShape<D>, IPackingItem, IRegularPackingShape, new() {
    4747
    4848    #region Parameter Properties
     
    5858    public B PackingBinMeasures {
    5959      get { return PackingBinMeasuresParameter.Value; }
    60       set { PackingBinMeasuresParameter.Value = value; } 
    61     }
    62     public PackingSolutionDecoder<D,B,I> PackingSolutionDecoder {
     60      set { PackingBinMeasuresParameter.Value = value; }
     61    }
     62    public PackingSolutionDecoder<D, B, I> PackingSolutionDecoder {
    6363      get { return PackingSolutionDecoderParameter.Value as PackingSolutionDecoder<D, B, I>; }
    6464      set { PackingSolutionDecoderParameter.Value = value; }
     
    6969    [StorableConstructor]
    7070    protected RegularIdenticalBinPackingProblem(bool deserializing) : base(deserializing) { }
    71     protected RegularIdenticalBinPackingProblem(RegularIdenticalBinPackingProblem<D,B,I> original, Cloner cloner)
     71    protected RegularIdenticalBinPackingProblem(RegularIdenticalBinPackingProblem<D, B, I> original, Cloner cloner)
    7272      : base(original, cloner) {
    7373      InitializeEventHandlers();
     
    8686    }
    8787
    88    
     88
    8989
    9090
     
    101101    protected abstract void InitializeProblemData();
    102102    protected abstract IPackingPlanEvaluator CreateDefaultEvaluator();
    103     private void ApplyHorizontalOrientation() {
     103    protected void ApplyHorizontalOrientation() {
    104104      PackingBinMeasures.ApplyHorizontalOrientation();
    105105      foreach (IRegularPackingShape shape in PackingItemMeasures) {
     
    107107      }
    108108    }
    109     private void SortItems() {
     109    protected void SortItems() {
    110110      PackingItemMeasures.Sort((x, y) => y.CompareTo(x));
    111111    }
    112     private int CalculateLowerBound() {
     112    protected int CalculateLowerBound() {
    113113      //This is the obvious continuous lower bound calculation; Martello and Vigo proposed a better way but it has not been implemented yet;
    114114      int items = PackingItemMeasures.Select(x => x.Volume).Sum();
    115115      int bin = PackingBinMeasures.Volume;
    116       return (items + bin - 1)/(bin);
     116      return (items + bin - 1) / (bin);
    117117    }
    118118
    119119    protected override void InitializeOperators() {
    120       Operators.Clear(); 
     120      Operators.Clear();
    121121      Operators.Add(new BestBinPackingSolutionAnalyzer<D, B, I>());
    122122
     
    134134        Operators.AddRange(ApplicationManager.Manager.GetInstances<IMultiComponentVectorOperator>());
    135135        InitializeDecoder();
    136       } 
    137     }
    138     private void ParameterizeOperators() {   
     136      }
     137    }
     138    private void ParameterizeOperators() {
    139139      foreach (var op in Operators.OfType<BestBinPackingSolutionAnalyzer<D, B, I>>()) {
    140140        op.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName;
     
    224224      ParameterizeOperators();
    225225    }
    226     #endregion
    227 
    228 
    229     #region Problem instance handling
    230     public virtual void Load(BPPData data) {
    231       // var realData = data as RealBPPData;
    232       // var binData = new B();
    233       // binData.InitializeFromMeasures (data.BinMeasures);
    234       //
    235       // var itemData = new ItemList<I>(data.Items);
    236       // for (int j = 0; j < data.Items; j++) {
    237       //   var item = new I();
    238       //   item.InitializeFromMeasures(data.ItemMeasures[j]);
    239       //   item.AddTargetBinMeasures(data.BinMeasures);
    240       //   if (realData != null) {
    241       //     item.Weight = realData.ItemWeights[j];
    242       //     item.Material = realData.ItemMaterials[j];
    243       //   }
    244       //   itemData.Add(item);
    245       // }
    246       //
    247       // BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
    248       //
    249       // PackingBinMeasures = binData;   
    250       // PackingItemMeasures = itemData;
    251       //
    252       // ApplyHorizontalOrientation();
    253       // SortItems();
    254       // PackingItemsParameter.Value.Value = PackingItemMeasures.Count;
    255       // LowerBoundParameter.Value.Value = CalculateLowerBound();
    256 
    257       throw new NotImplementedException();
    258     }
    259 
    260     public BPPData Export() {
    261       // var result = new BPPData{
    262       //   Name = Name,
    263       //   Description = Description,
    264       //   Items = PackingItemsParameter.Value.Value,
    265       //   BinMeasures = PackingBinMeasures.ToArray() // TODO: split functionality of class in 2d and 3d code
    266       // };
    267       //
    268       // var itemMeasures = new int[result.Items][];
    269       // int i = 0;
    270       // foreach (var item in PackingItemMeasures) {
    271       //   itemMeasures[i] = item.ToArray();
    272       //   i++;
    273       // }
    274       // result.ItemMeasures = itemMeasures;
    275       // return result;
    276 
    277       throw new NotImplementedException();
    278     }
    279     #endregion
     226
     227    public abstract void Load(BPPData data);
     228
     229    public abstract BPPData Export();
     230    #endregion
     231
    280232  }
    281233}
Note: See TracChangeset for help on using the changeset viewer.