Changeset 15989 for branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms
- Timestamp:
- 07/09/18 12:59:38 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs
r15959 r15989 83 83 84 84 [Storable] 85 private readonly IValueParameter<BoolValue> sortBy MaterialParameter;86 87 public IValueParameter<BoolValue> SortBy MaterialParameter {88 get { return sortBy MaterialParameter; }85 private readonly IValueParameter<BoolValue> sortBySequenceGroupParameter; 86 87 public IValueParameter<BoolValue> SortBySequenceGroupParameter { 88 get { return sortBySequenceGroupParameter; } 89 89 } 90 90 … … 116 116 "Delta", "[1;100]% Clustered sorting methods use a delta parameter to determine the clusters.", new PercentValue(.1))); 117 117 118 Parameters.Add(sortBy MaterialParameter = new ValueParameter<BoolValue>(119 "SortBy Material", "If this parameter is set, the items will be sorted by their materialfirst", new BoolValue(true)));118 Parameters.Add(sortBySequenceGroupParameter = new ValueParameter<BoolValue>( 119 "SortBySequenceGroup", "If this parameter is set, the items will be sorted by their sequence group first", new BoolValue(true))); 120 120 121 121 Problem = new PermutationProblem(); … … 209 209 ExtremePointCreationMethod[] epCreationMethods, 210 210 CancellationToken token) { 211 211 212 SortingMethod? bestSorting = null; 212 213 FittingMethod? bestFitting = null; … … 223 224 Permutation sortedItems; 224 225 225 if (SortByMaterialParameter.Value.Value) { 226 sortedItems = SortItemsByMaterialAndSortingMethod(bin, items, sort, DeltaParameter.Value.Value); 227 } else { 228 sortedItems = SortItemsBySortingMethod(bin, items, sort, DeltaParameter.Value.Value); 229 } 230 226 sortedItems = SortItems(bin, items, sort, DeltaParameter.Value.Value, SortBySequenceGroupParameter.Value.Value); 227 231 228 var solution = Optimize(new OptimaizationParamters() { 232 229 SortedItems = sortedItems, … … 265 262 /// <returns></returns> 266 263 private static Solution Optimize(OptimaizationParamters parameters) { 267 268 264 var sol = parameters.Decoder.Decode(parameters.SortedItems, parameters.Bin, parameters.Items, parameters.StackingConstraints); 269 265 … … 281 277 } 282 278 283 /// <summary> 284 /// Returns a new permutation of the given items depending on the sorting method 285 /// </summary> 286 /// <param name="bin"></param> 287 /// <param name="items"></param> 288 /// <param name="sortingMethod"></param> 289 /// <param name="delta"></param> 290 /// <returns></returns> 291 private Permutation SortItemsByMaterialAndSortingMethod(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta) { 292 Permutation sorted = null; 293 294 switch (sortingMethod) { 295 case SortingMethod.Given: 296 sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray()); 297 break; 298 case SortingMethod.VolumeHeight: 299 sorted = items.SortByVolumeHeight(); 300 break; 301 case SortingMethod.HeightVolume: 302 sorted = items.SortByMaterialHeightVolume(); 303 break; 304 case SortingMethod.AreaHeight: 305 sorted = items.SortByMaterialAreaHeight(); 306 break; 307 case SortingMethod.HeightArea: 308 sorted = items.SortByMaterialHeightArea(); 309 break; 310 case SortingMethod.ClusteredAreaHeight: 311 sorted = items.SortByMaterialClusteredAreaHeight(bin, delta); 312 break; 313 case SortingMethod.ClusteredHeightArea: 314 sorted = items.SortByMaterialClusteredHeightArea(bin, delta); 315 break; 316 default: 317 throw new ArgumentException("Unknown sorting method: " + sortingMethod); 318 } 319 return sorted; 320 } 321 322 /// <summary> 323 /// Returns a new permutation of the given items depending on the material and sorting method 324 /// </summary> 325 /// <param name="bin"></param> 326 /// <param name="items"></param> 327 /// <param name="sortingMethod"></param> 328 /// <param name="delta"></param> 329 /// <returns></returns> 330 private Permutation SortItemsBySortingMethod(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta) { 331 Permutation sorted = null; 332 333 switch (sortingMethod) { 334 case SortingMethod.Given: 335 sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray()); 336 break; 337 case SortingMethod.VolumeHeight: 338 sorted = items.SortByVolumeHeight(); 339 break; 340 case SortingMethod.HeightVolume: 341 sorted = items.SortByHeightVolume(); 342 break; 343 case SortingMethod.AreaHeight: 344 sorted = items.SortByAreaHeight(); 345 break; 346 case SortingMethod.HeightArea: 347 sorted = items.SortByHeightArea(); 348 break; 349 case SortingMethod.ClusteredAreaHeight: 350 sorted = items.SortByClusteredAreaHeight(bin, delta); 351 break; 352 case SortingMethod.ClusteredHeightArea: 353 sorted = items.SortByClusteredHeightArea(bin, delta); 354 break; 355 default: 356 throw new ArgumentException("Unknown sorting method: " + sortingMethod); 357 } 358 return sorted; 359 } 279 280 private Permutation SortItems(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta, bool sortBySequenceGroup) { 281 Permutation sortedItems; 282 283 var sorter = PackingItemSorterFactory.CreatePackingItemSorter(sortingMethod); 284 if (sorter is IPackingItemClusteredSorter) { 285 if (sortBySequenceGroup) { 286 sortedItems = (sorter as IPackingItemClusteredSorter).SortPackingItemsBySequenceGroup(items, bin, delta); 287 } else { 288 sortedItems = (sorter as IPackingItemClusteredSorter).SortPackingItems(items, bin, delta); 289 } 290 } else { 291 if (sortBySequenceGroup) { 292 sortedItems = sorter.SortPackingItemsBySequenceGroup(items, bin); 293 } else { 294 sortedItems = sorter.SortPackingItems(items, bin); 295 } 296 } 297 return sortedItems; 298 } 360 299 } 361 300 }
Note: See TracChangeset
for help on using the changeset viewer.