Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9473 was 9440, checked in by jhelm, 12 years ago

#1966: Implemented new encoding (MultiComponentVector/MCV); Implemented move-operators for MCV and GV encodings; Implemented new decoding-methods for PS, GV and MCV encodings (ExtremePoint-based packing);

File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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 System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using HeuristicLab.Problems.BinPacking.Interfaces;
28using HeuristicLab.Operators;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Common;
31using HeuristicLab.Parameters;
32using HeuristicLab.Data;
33using HeuristicLab.Encodings.PackingEncoding.PackingPlan;
34using HeuristicLab.Problems.BinPacking.Shapes;
35using HeuristicLab.Collections;
36
37namespace HeuristicLab.Problems.BinPacking.Evaluators {
38  [Item("Regular Simple-Rotation Identical-Bin Packingplan Evaluator", "Represents a evaluator class for bin-packing problems using regular shapes and only simple rotations.")]
39  [StorableClass]
40  public abstract class RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I> : PackingPlanEvaluator<D, B, I>
41    where D : class, IPackingDimensions
42    where B : PackingShape<D>, IPackingBin, IRegularPackingShape
43    where I : PackingShape<D>, IPackingItem, IRegularPackingShape {
44
45    #region Parameter Properties
46    public ILookupParameter<ItemList<I>> PackingItemMeasuresParameter {
47      get { return (ILookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; }
48    }
49    public ILookupParameter<B> PackingBinMeasuresParameter {
50      get { return (ILookupParameter<B>)Parameters["PackingBinMeasures"]; }
51    }
52    #endregion
53
54    [StorableConstructor]
55    protected RegularSimpleRotationIdenticalBinPackingPlanEvaluator(bool deserializing) : base(deserializing) { }
56    protected RegularSimpleRotationIdenticalBinPackingPlanEvaluator(RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D,B,I> original, Cloner cloner)
57      : base(original, cloner) {
58    }
59    public RegularSimpleRotationIdenticalBinPackingPlanEvaluator()
60      : base() {
61      Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance."));
62      Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
63    }
64
65
66
67
68    protected bool HasOverlappingOrNotContainedItems(ObservableDictionary<int, D> positions, B binMeasure, ItemList<I> itemMeasures, int nrOfBins) {
69      //TODO: Optimize performance by removing unnecessary allocations..
70      for (int i = 0; i < itemMeasures.Count; i++ ) {
71        I packingItem = itemMeasures [i];
72        D currentPosition = positions[i];
73        if (!binMeasure.Encloses(currentPosition, packingItem))
74          return true;
75
76        for (int j = 0; j < itemMeasures.Count; j++) {
77            D checkedPosition = positions[j];
78          if (i != j && currentPosition.AssignedBin == checkedPosition.AssignedBin) {
79            I checkedItem = itemMeasures[j];
80            if (packingItem.Overlaps(currentPosition, checkedPosition, checkedItem))
81              return true;
82          }
83        }
84
85      }
86
87      return false;
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.