Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract/RegularSimpleRotationIdenticalBinPackingPlanEvaluator.cs @ 13365

Last change on this file since 13365 was 13032, checked in by gkronber, 9 years ago

#1966:

  • removed unused using
  • added/updated license headers
File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Core;
23using HeuristicLab.Problems.BinPacking.Interfaces;
24using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
25using HeuristicLab.Common;
26using HeuristicLab.Parameters;
27using HeuristicLab.Problems.BinPacking.Shapes;
28using HeuristicLab.Collections;
29
30namespace HeuristicLab.Problems.BinPacking.Evaluators {
31  [Item("Regular Simple-Rotation Identical-Bin Packingplan Evaluator", "Represents a evaluator class for bin-packing problems using regular shapes and only simple rotations.")]
32  [StorableClass]
33  public abstract class RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I> : PackingPlanEvaluator<D, B, I>
34    where D : class, IPackingDimensions
35    where B : PackingShape<D>, IPackingBin, IRegularPackingShape
36    where I : PackingShape<D>, IPackingItem, IRegularPackingShape {
37
38    #region Parameter Properties
39    public ILookupParameter<ItemList<I>> PackingItemMeasuresParameter {
40      get { return (ILookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; }
41    }
42    public ILookupParameter<B> PackingBinMeasuresParameter {
43      get { return (ILookupParameter<B>)Parameters["PackingBinMeasures"]; }
44    }
45    #endregion
46
47    [StorableConstructor]
48    protected RegularSimpleRotationIdenticalBinPackingPlanEvaluator(bool deserializing) : base(deserializing) { }
49    protected RegularSimpleRotationIdenticalBinPackingPlanEvaluator(RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D,B,I> original, Cloner cloner)
50      : base(original, cloner) {
51    }
52    public RegularSimpleRotationIdenticalBinPackingPlanEvaluator()
53      : base() {
54      Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance."));
55      Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
56    }
57
58
59
60
61    protected bool HasOverlappingOrNotContainedItems(ObservableDictionary<int, D> positions, B binMeasure, ItemList<I> itemMeasures, int nrOfBins) {
62      //TODO: Optimize performance by removing unnecessary allocations..
63      for (int i = 0; i < itemMeasures.Count; i++ ) {
64        I packingItem = itemMeasures [i];
65        D currentPosition = positions[i];
66        if (!binMeasure.Encloses(currentPosition, packingItem))
67          return true;
68
69        for (int j = 0; j < itemMeasures.Count; j++) {
70            D checkedPosition = positions[j];
71          if (i != j && currentPosition.AssignedBin == checkedPosition.AssignedBin) {
72            I checkedItem = itemMeasures[j];
73            if (packingItem.Overlaps(currentPosition, checkedPosition, checkedItem))
74              return true;
75          }
76        }
77
78      }
79
80      return false;
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.