- Timestamp:
- 07/12/16 17:12:15 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/RegularIdenticalBinPackingProblem.cs
r13608 r14039 41 41 [Item("RegularIdenticalBinPackingProblem", "Represents a bin-packing problem-instance using only bins with identical measures and bins/items with regular shapes (e.g. rectangle, cuboid).")] 42 42 [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> 44 44 where D : class, IPackingDimensions 45 45 where B : PackingShape<D>, IPackingBin, IRegularPackingShape, new() 46 where I : PackingShape<D>, IPackingItem, IRegularPackingShape, new() { 46 where I : PackingShape<D>, IPackingItem, IRegularPackingShape, new() { 47 47 48 48 #region Parameter Properties … … 58 58 public B PackingBinMeasures { 59 59 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 { 63 63 get { return PackingSolutionDecoderParameter.Value as PackingSolutionDecoder<D, B, I>; } 64 64 set { PackingSolutionDecoderParameter.Value = value; } … … 69 69 [StorableConstructor] 70 70 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) 72 72 : base(original, cloner) { 73 73 InitializeEventHandlers(); … … 86 86 } 87 87 88 88 89 89 90 90 … … 101 101 protected abstract void InitializeProblemData(); 102 102 protected abstract IPackingPlanEvaluator CreateDefaultEvaluator(); 103 pr ivatevoid ApplyHorizontalOrientation() {103 protected void ApplyHorizontalOrientation() { 104 104 PackingBinMeasures.ApplyHorizontalOrientation(); 105 105 foreach (IRegularPackingShape shape in PackingItemMeasures) { … … 107 107 } 108 108 } 109 pr ivatevoid SortItems() {109 protected void SortItems() { 110 110 PackingItemMeasures.Sort((x, y) => y.CompareTo(x)); 111 111 } 112 pr ivateint CalculateLowerBound() {112 protected int CalculateLowerBound() { 113 113 //This is the obvious continuous lower bound calculation; Martello and Vigo proposed a better way but it has not been implemented yet; 114 114 int items = PackingItemMeasures.Select(x => x.Volume).Sum(); 115 115 int bin = PackingBinMeasures.Volume; 116 return (items + bin - 1) /(bin);116 return (items + bin - 1) / (bin); 117 117 } 118 118 119 119 protected override void InitializeOperators() { 120 Operators.Clear(); 120 Operators.Clear(); 121 121 Operators.Add(new BestBinPackingSolutionAnalyzer<D, B, I>()); 122 122 … … 134 134 Operators.AddRange(ApplicationManager.Manager.GetInstances<IMultiComponentVectorOperator>()); 135 135 InitializeDecoder(); 136 } 137 } 138 private void ParameterizeOperators() { 136 } 137 } 138 private void ParameterizeOperators() { 139 139 foreach (var op in Operators.OfType<BestBinPackingSolutionAnalyzer<D, B, I>>()) { 140 140 op.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName; … … 224 224 ParameterizeOperators(); 225 225 } 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 280 232 } 281 233 }
Note: See TracChangeset
for help on using the changeset viewer.