Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PackingItem.cs @ 14778

Last change on this file since 14778 was 14049, checked in by gkronber, 8 years ago

#1966: simplified class names

File size: 2.9 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 HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
[13574]26using HeuristicLab.Data;
27using HeuristicLab.Parameters;
[14046]28using HeuristicLab.Problems.BinPacking;
[9348]29
[14046]30namespace HeuristicLab.Problems.BinPacking2D {
[14049]31  [Item("PackingItem (2d)", "Represents a rectangular packing-item for bin-packing problems.")]
[9348]32  [StorableClass]
[14049]33  public class PackingItem : PackingShape, IPackingItem {
[9348]34
[14049]35    public PackingShape TargetBin {
36      get { return ((IValueParameter<PackingShape>)Parameters["TargetBin"]).Value; }
37      set { ((IValueParameter<PackingShape>)Parameters["TargetBin"]).Value = value; }
[13574]38    }
[13497]39
[13574]40    public double Weight {
41      get { return ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value; }
42      set { ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value = value; }
43    }
[13497]44
[13574]45    public int Material {
46      get { return ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value; }
47      set { ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value = value; }
[9563]48    }
[9348]49
50    [StorableConstructor]
[14049]51    protected PackingItem(bool deserializing) : base(deserializing) { }
52    protected PackingItem(PackingItem original, Cloner cloner)
[9348]53      : base(original, cloner) {
54    }
[13574]55
[9348]56    public override IDeepCloneable Clone(Cloner cloner) {
[14049]57      return new PackingItem(this, cloner);
[9348]58    }
[13574]59
[14049]60    public PackingItem()
[13461]61      : base() {
[14049]62      Parameters.Add(new ValueParameter<PackingShape>("TargetBin"));
[13574]63      Parameters.Add(new FixedValueParameter<DoubleValue>("Weight"));
64      Parameters.Add(new FixedValueParameter<IntValue>("Material"));
[9348]65    }
66
[14049]67    public PackingItem(int width, int height, PackingShape targetBin)
[13574]68      : this() {
[14039]69      this.Width = width;
[13574]70      this.Height = height;
[14049]71      this.TargetBin = (PackingShape)targetBin.Clone();
[13497]72    }
[13461]73
[13574]74    public bool SupportsStacking(IPackingItem other) {
75      return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight));
76    }
[9348]77  }
78}
Note: See TracBrowser for help on using the repository browser.