Changeset 13574 for branches/HeuristicLab.BinPacking
- Timestamp:
- 01/28/16 18:32:54 (9 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/HeuristicLab.Problems.BinPacking.Views-3.3.csproj
r13532 r13574 172 172 <Compile Include="Shapes\CuboidPackingShapeView.Designer.cs"> 173 173 <DependentUpon>CuboidPackingShapeView.cs</DependentUpon> 174 </Compile> 175 <Compile Include="Shapes\RectangularPackingItemView.cs"> 176 <SubType>UserControl</SubType> 177 </Compile> 178 <Compile Include="Shapes\RectangularPackingItemView.Designer.cs"> 179 <DependentUpon>RectangularPackingItemView.cs</DependentUpon> 180 </Compile> 181 <Compile Include="Shapes\RectangularPackingShapeView.cs"> 182 <SubType>UserControl</SubType> 183 </Compile> 184 <Compile Include="Shapes\RectangularPackingShapeView.Designer.cs"> 185 <DependentUpon>RectangularPackingShapeView.cs</DependentUpon> 174 186 </Compile> 175 187 <None Include="HeuristicLab.snk" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/RectangularPackingItemView.Designer.cs
r13466 r13574 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.packingPlan2D = new PackingPlanVisualizations.PackingPlan2D();48 47 this.SuspendLayout(); 49 //50 // packingPlan2D51 //52 this.packingPlan2D.Dock = System.Windows.Forms.DockStyle.Fill;53 this.packingPlan2D.Location = new System.Drawing.Point(0, 0);54 this.packingPlan2D.Name = "packingPlan2D";55 this.packingPlan2D.Size = new System.Drawing.Size(351, 299);56 this.packingPlan2D.TabIndex = 4;57 48 // 58 49 // RectangularPackingItemView 59 50 // 60 51 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 61 this.Controls.Add(this.packingPlan2D);62 52 this.Name = "RectangularPackingItemView"; 63 53 this.Size = new System.Drawing.Size(351, 299); … … 68 58 #endregion 69 59 70 private PackingPlanVisualizations.PackingPlan2D packingPlan2D;71 60 } 72 61 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/RectangularPackingItemView.cs
r13466 r13574 47 47 48 48 private void ClearState() { 49 packingPlan2D.InitializeContainer(0, 0);49 // packingPlan2D.InitializeContainer(0, 0); 50 50 } 51 51 52 52 private void UpdateState(RectangularPackingItem item) { 53 packingPlan2D.InitializeContainer(item.TargetBin.Width, item.TargetBin.Height);54 packingPlan2D.AddItemToContainer(item.Width, item.Height, 0, 0, "0");53 // packingPlan2D.InitializeContainer(item.TargetBin.Width, item.TargetBin.Height); 54 // packingPlan2D.AddItemToContainer(item.Width, item.Height, 0, 0, "0"); 55 55 } 56 56 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/RectangularPackingShapeView.Designer.cs
r13466 r13574 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.packingPlan2D = new PackingPlanVisualizations.PackingPlan2D();48 47 this.SuspendLayout(); 49 //50 // packingPlan2D51 //52 this.packingPlan2D.Dock = System.Windows.Forms.DockStyle.Fill;53 this.packingPlan2D.Location = new System.Drawing.Point(0, 0);54 this.packingPlan2D.Name = "packingPlan2D";55 this.packingPlan2D.Size = new System.Drawing.Size(351, 299);56 this.packingPlan2D.TabIndex = 4;57 48 // 58 49 // RectangularPackingShapeView 59 50 // 60 51 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 61 this.Controls.Add(this.packingPlan2D);62 52 this.Name = "RectangularPackingShapeView"; 63 53 this.Size = new System.Drawing.Size(351, 299); … … 68 58 #endregion 69 59 70 private PackingPlanVisualizations.PackingPlan2D packingPlan2D;71 60 } 72 61 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/RectangularPackingShapeView.cs
r13466 r13574 47 47 48 48 private void ClearState() { 49 packingPlan2D.InitializeContainer(0, 0);49 // packingPlan2D.InitializeContainer(0, 0); 50 50 } 51 51 52 52 private void UpdateState(RectangularPackingShape shape) { 53 packingPlan2D.InitializeContainer(shape.Width, shape.Height);53 // packingPlan2D.InitializeContainer(shape.Width, shape.Height); 54 54 } 55 55 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingBin/CuboidPackingBin.cs
r13461 r13574 31 31 [StorableClass] 32 32 public class CuboidPackingBin : CuboidPackingShape, IPackingBin { 33 34 33 public CuboidPackingBin(int width, int height, int depth) : base(width, height, depth) { } 35 34 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingBin/RectangularPackingBin.cs
r13497 r13574 30 30 [StorableClass] 31 31 public class RectangularPackingBin : RectangularPackingShape, IPackingBin { 32 33 32 public RectangularPackingBin(int width, int height) : base(width, height) { } 34 33 public RectangularPackingBin() : base() { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/CuboidPackingItem.cs
r13497 r13574 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 using HeuristicLab.Common; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 28 30 using HeuristicLab.Problems.BinPacking.PackingBin; 29 31 … … 32 34 [StorableClass] 33 35 public class CuboidPackingItem : CuboidPackingShape, IPackingItem { 34 [Storable] 35 public CuboidPackingBin TargetBin { get; set; } 36 public CuboidPackingBin TargetBin { 37 get { return ((IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]).Value; } 38 set { ((IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]).Value = value; } 39 } 36 40 37 [Storable] 38 public double Weight { get; set; } 41 public double Weight { 42 get { return ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value; } 43 set { ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value = value; } 44 } 39 45 40 [Storable] 41 public int Material { get; set; } 46 public int Material { 47 get { return ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value; } 48 set { ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value = value; } 49 } 42 50 43 51 public bool SupportsStacking(IPackingItem other) { … … 49 57 protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner) 50 58 : base(original, cloner) { 51 this.Weight = original.Weight;52 this.Material = original.Material;53 this.TargetBin = cloner.Clone(TargetBin);54 }55 public override IDeepCloneable Clone(Cloner cloner) {56 return new CuboidPackingItem(this, cloner);57 59 } 58 60 public CuboidPackingItem() 59 61 : base() { 62 Parameters.Add(new ValueParameter<CuboidPackingBin>("TargetBin")); 63 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 64 Parameters.Add(new FixedValueParameter<IntValue>("Material")); 60 65 } 61 66 62 67 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material) 63 : this(width, height, depth, targetBin) { 68 : this() { 69 this.Width = width; 70 this.Height = height; 71 this.Depth = depth; 64 72 this.Weight = weight; 65 73 this.Material = material; 74 this.TargetBin = (CuboidPackingBin)targetBin.Clone(); 66 75 } 67 76 68 77 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin) 69 : base(width, height, depth) { 78 : this() { 79 this.Width = width; 80 this.Height = height; 81 this.Depth = depth; 70 82 this.TargetBin = (CuboidPackingBin)targetBin.Clone(); 83 } 84 85 public override IDeepCloneable Clone(Cloner cloner) { 86 return new CuboidPackingItem(this, cloner); 71 87 } 72 88 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/RectangularPackingItem.cs
r13497 r13574 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 28 30 using HeuristicLab.Problems.BinPacking.PackingBin; 29 31 … … 33 35 public class RectangularPackingItem : RectangularPackingShape, IPackingItem { 34 36 35 [Storable] 36 public RectangularPackingBin TargetBin { get; set; } 37 public RectangularPackingBin TargetBin { 38 get { return ((IValueParameter<RectangularPackingBin>)Parameters["TargetBin"]).Value; } 39 set { ((IValueParameter<RectangularPackingBin>)Parameters["TargetBin"]).Value = value; } 40 } 37 41 38 [Storable] 39 public double Weight { get; set; } 42 public double Weight { 43 get { return ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value; } 44 set { ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value = value; } 45 } 40 46 41 [Storable] 42 public int Material { get; set; } 43 44 public bool SupportsStacking(IPackingItem other) { 45 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); 47 public int Material { 48 get { return ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value; } 49 set { ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value = value; } 46 50 } 47 51 … … 50 54 protected RectangularPackingItem(RectangularPackingItem original, Cloner cloner) 51 55 : base(original, cloner) { 52 this.Weight = original.Weight;53 this.Material = original.Material;54 this.TargetBin = cloner.Clone(TargetBin);55 56 } 57 56 58 public override IDeepCloneable Clone(Cloner cloner) { 57 59 return new RectangularPackingItem(this, cloner); 58 60 } 61 59 62 public RectangularPackingItem() 60 63 : base() { 64 Parameters.Add(new ValueParameter<RectangularPackingBin>("TargetBin")); 65 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 66 Parameters.Add(new FixedValueParameter<IntValue>("Material")); 61 67 } 62 68 63 69 public RectangularPackingItem(int width, int height, RectangularPackingBin targetBin) 64 : base(width, height) { 70 : this() { 71 this.Weight = width; 72 this.Height = height; 65 73 this.TargetBin = (RectangularPackingBin)targetBin.Clone(); 74 } 75 76 public bool SupportsStacking(IPackingItem other) { 77 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); 66 78 } 67 79 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r13497 r13574 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 using HeuristicLab.Common; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 28 30 using HeuristicLab.Problems.BinPacking.Dimensions; 29 31 … … 33 35 public abstract class CuboidPackingShape : PackingShape<ThreeDimensionalPacking>, IRegularPackingShape, IComparable<CuboidPackingShape> { 34 36 #region Properties 35 /// <summary>36 /// Describes the size on the X-axis37 /// </summary>38 [Storable]39 public int Width { get; set; } 40 /// <summary>41 /// Describes the size on the Y-axis42 /// </summary>43 [Storable]44 public int Height { get; set; } 45 /// <summary>46 /// Describes the size on the Z-axis47 /// </summary>48 [Storable]49 public int Depth { get; set; } 37 public int Height { 38 get { return ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value; } 39 set { ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value = value; } 40 } 41 42 public int Width { 43 get { return ((IFixedValueParameter<IntValue>)Parameters["Width"]).Value.Value; } 44 set { ((IFixedValueParameter<IntValue>)Parameters["Width"]).Value.Value = value; } 45 } 46 47 public int Depth { 48 get { return ((IFixedValueParameter<IntValue>)Parameters["Depth"]).Value.Value; } 49 set { ((IFixedValueParameter<IntValue>)Parameters["Depth"]).Value.Value = value; } 50 } 51 50 52 #endregion 51 53 … … 101 103 #endregion 102 104 103 protected CuboidPackingShape(int width, int height, int depth) 104 : base() { 105 this.Width = width; 106 this.Height = height; 107 this.Depth = depth; 108 } 105 109 106 110 107 public override void InitializeFromMeasures(int[] measures) { … … 119 116 } 120 117 118 119 protected CuboidPackingShape() 120 : base() { 121 Parameters.Add(new FixedValueParameter<IntValue>("Width")); 122 Parameters.Add(new FixedValueParameter<IntValue>("Height")); 123 Parameters.Add(new FixedValueParameter<IntValue>("Depth")); 124 } 125 126 protected CuboidPackingShape(int width, int height, int depth) 127 : this() { 128 this.Width = width; 129 this.Height = height; 130 this.Depth = depth; 131 } 132 121 133 [StorableConstructor] 122 134 protected CuboidPackingShape(bool deserializing) : base(deserializing) { } 123 135 protected CuboidPackingShape(CuboidPackingShape original, Cloner cloner) 124 136 : base(original, cloner) { 125 this.Width = original.Width;126 this.Height = original.Height;127 this.Depth = original.Depth;128 137 } 129 130 protected CuboidPackingShape() : base() { }131 138 132 139 public override string ToString() { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/PackingShape.cs
r13497 r13574 22 22 23 23 using System; 24 using System.Collections.Generic; 25 using System.Drawing; 26 using System.Linq; 24 27 using HeuristicLab.Problems.BinPacking.Interfaces; 25 28 using HeuristicLab.Core; … … 30 33 [Item("PackingShape", "Represents an abstract shape to describe the measures and the positioning of objects related to bin-packing problems.")] 31 34 [StorableClass] 32 public abstract class PackingShape<T> : Item, IPackingShape 35 public abstract class PackingShape<T> : Item, IPackingShape, IParameterizedItem 33 36 where T : class, IPackingDimensions { 34 37 public static Type PositionType { … … 44 47 public abstract T Origin { get; } 45 48 46 protected PackingShape(int[] measures) { 47 InitializeFromMeasures(measures); 49 protected PackingShape() 50 : base() { 51 Parameters = new ParameterCollection(); 48 52 } 49 50 protected PackingShape() { }51 53 52 54 53 55 [StorableConstructor] 54 protected PackingShape(bool deserializing) : base(deserializing){ }55 protected PackingShape(PackingShape<T> original, Cloner cloner) 56 : base(original, cloner) {56 protected PackingShape(bool deserializing) { } 57 protected PackingShape(PackingShape<T> original, Cloner cloner) { 58 this.Parameters = new ParameterCollection(original.Parameters.Select(p => cloner.Clone(p))); 57 59 } 60 61 public virtual void CollectParameterValues(IDictionary<string, IItem> values) { 62 foreach (IValueParameter param in Parameters.OfType<IValueParameter>()) { 63 var children = GetCollectedValues(param); 64 foreach (var c in children) { 65 if (String.IsNullOrEmpty(c.Key)) 66 values.Add(param.Name, c.Value); 67 else values.Add(param.Name + "." + c.Key, c.Value); 68 } 69 } 70 } 71 72 protected virtual IEnumerable<KeyValuePair<string, IItem>> GetCollectedValues(IValueParameter param) { 73 if (param.Value == null) yield break; 74 if (param.GetsCollected) yield return new KeyValuePair<string, IItem>(String.Empty, param.Value); 75 var parameterizedItem = param.Value as IParameterizedItem; 76 if (parameterizedItem != null) { 77 var children = new Dictionary<string, IItem>(); 78 parameterizedItem.CollectParameterValues(children); 79 foreach (var child in children) yield return child; 80 } 81 } 82 83 public IKeyedItemCollection<string, IParameter> Parameters { get; private set; } 58 84 } 59 85 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
r13497 r13574 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 using HeuristicLab.Common; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 28 30 using HeuristicLab.Problems.BinPacking.Dimensions; 29 31 … … 33 35 public abstract class RectangularPackingShape : PackingShape<TwoDimensionalPacking>, IRegularPackingShape, IComparable<RectangularPackingShape> { 34 36 #region Properties 35 [Storable] 36 public int Height { get; set; } 37 public int Height { 38 get { return ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value; } 39 set { ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value = value; } 40 } 37 41 38 [Storable] 39 public int Width { get; set; } 42 public int Width { 43 get { return ((IFixedValueParameter<IntValue>)Parameters["Width"]).Value.Value; } 44 set { ((IFixedValueParameter<IntValue>)Parameters["Width"]).Value.Value = value; } 45 } 46 40 47 #endregion 48 49 protected RectangularPackingShape() 50 : base() { 51 Parameters.Add(new FixedValueParameter<IntValue>("Width")); 52 Parameters.Add(new FixedValueParameter<IntValue>("Height")); 53 } 54 protected RectangularPackingShape(int width, int height) 55 : this() { 56 this.Height = height; 57 this.Width = width; 58 } 59 60 [StorableConstructor] 61 protected RectangularPackingShape(bool deserializing) : base(deserializing) { } 62 protected RectangularPackingShape(RectangularPackingShape original, Cloner cloner) 63 : base(original, cloner) { 64 } 65 66 public override void InitializeFromMeasures(int[] measures) { 67 if (measures.Length != 2) 68 throw new InvalidOperationException("Nr of measures does not fit shape-dimension."); 69 this.Width = measures[0]; 70 this.Height = measures[1]; 71 } 72 73 74 75 public override string ToString() { 76 return String.Format("RectangularPackingShape ({0}, {1})", this.Width, this.Height); 77 } 78 79 #region IComparable<RectangularPackingShape> Members 80 81 public int CompareTo(RectangularPackingShape other) { 82 int result = this.Width.CompareTo(other.Width); 83 if (result == 0) 84 result = this.Height.CompareTo(other.Height); 85 return result; 86 } 87 88 public int CompareTo(object obj) { 89 var other = obj as RectangularPackingShape; 90 if (other != null) return CompareTo(other); 91 else throw new ArgumentException(string.Format("Cannot compare to object {0}", obj), "obj"); 92 } 93 94 #endregion 95 96 public override int[] ToArray() { 97 return new int[] { Width, Height }; 98 } 99 100 41 101 42 102 #region Helpers … … 85 145 #endregion 86 146 87 protected RectangularPackingShape() : base() { }88 protected RectangularPackingShape(int width, int height)89 : base() {90 this.Height = height;91 this.Width = width;92 }93 94 public override void InitializeFromMeasures(int[] measures) {95 if (measures.Length != 2)96 throw new InvalidOperationException("Nr of measures does not fit shape-dimension.");97 this.Width = measures[0];98 this.Height = measures[1];99 }100 101 102 [StorableConstructor]103 protected RectangularPackingShape(bool deserializing) : base(deserializing) { }104 protected RectangularPackingShape(RectangularPackingShape original, Cloner cloner)105 : base(original, cloner) {106 this.Width = original.Width;107 this.Height = original.Height;108 }109 110 public override string ToString() {111 return String.Format("RectangularPackingShape ({0}, {1})", this.Width, this.Height);112 }113 114 #region IComparable<RectangularPackingShape> Members115 116 public int CompareTo(RectangularPackingShape other) {117 int result = 0;// this.MultipliedMeasures.CompareTo(other.MultipliedMeasures);118 if (result == 0) {119 result = this.Width.CompareTo(other.Width);120 if (result == 0)121 result = this.Height.CompareTo(other.Height);122 }123 return result;124 }125 126 public int CompareTo(object obj) {127 var other = obj as RectangularPackingShape;128 if (other != null) return CompareTo(other);129 else throw new ArgumentException(string.Format("Cannot compare to object {0}", obj), "obj");130 }131 132 #endregion133 134 public override int[] ToArray() {135 return new int[] { Width, Height };136 }137 147 138 148 private struct RectangleDiagonal {
Note: See TracChangeset
for help on using the changeset viewer.