Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/PackingDimensions.cs @ 13599

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

#1966:

  • removed unused using
  • added/updated license headers
File size: 2.7 KB
RevLine 
[9348]1#region License Information
2/* HeuristicLab
[13032]3 * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[9348]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
[13032]22
[9348]23using System;
24using System.Text;
25using HeuristicLab.Problems.BinPacking.Interfaces;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Core;
28using HeuristicLab.Common;
29
30namespace HeuristicLab.Problems.BinPacking.Dimensions {
31  [Item("Packing Dimensions", "Represents an abstract packing-position associated with a packing-problem.")]
32  [StorableClass]
33  public abstract class PackingDimensions : Item, IPackingDimensions {
34    /// <summary>
35    /// The number of the bin to which the current item is assigned is stored in this variable. Counting starts at 0 !!!
36    /// </summary>
37    public Int32 AssignedBin { get; set; }
[9440]38    /// <summary>
39    /// Determins if the positioned item is to be rotate by 90 degrees or not.
40    /// </summary>
41    public Boolean Rotated { get; set; }
[9348]42
43    [StorableConstructor]
44    protected PackingDimensions(bool deserializing) : base(deserializing) { }
45    protected PackingDimensions(PackingDimensions original, Cloner cloner)
46      : base(original, cloner) {
47        AssignedBin = original.AssignedBin;
[9440]48        Rotated = original.Rotated;
[9348]49    }
50
[9440]51    public PackingDimensions(Int32 assignedBin, Boolean rotated) {
[9348]52      this.AssignedBin = assignedBin;
[9440]53      this.Rotated = rotated;
[9348]54    }
55
56    public override string ToString() {
57      StringBuilder sb = new StringBuilder();
58      sb.Append("[");
[9440]59      sb.Append(AssignedBin + "-");
60      sb.Append(Rotated);
[9348]61      sb.Append("]");
62      return sb.ToString();
63    }
[9440]64
65    public override bool Equals(object obj) {
66      var pd = obj as PackingDimensions;
67      if (pd != null)
68        return (pd.AssignedBin == this.AssignedBin && pd.Rotated == this.Rotated);
69      else return false;
70    }
71
72    public override int GetHashCode() {
73      return 31 * AssignedBin * (Rotated ? 3 : 7);
74    }
[9348]75  }
76}
Note: See TracBrowser for help on using the repository browser.