Changeset 15617 for branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/PackingItem.cs
- Timestamp:
- 01/16/18 15:40:43 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/PackingItem.cs
r14162 r15617 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6 Joseph Helm andHeuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 31 31 [StorableClass] 32 32 public class PackingItem : PackingShape, IPackingItem { 33 #region Properties 34 35 33 36 public IValueParameter<PackingShape> TargetBinParameter { 34 37 get { return (IValueParameter<PackingShape>)Parameters["TargetBin"]; } … … 40 43 get { return (IFixedValueParameter<IntValue>)Parameters["Material"]; } 41 44 } 42 45 43 46 public PackingShape TargetBin { 44 47 get { return TargetBinParameter.Value; } … … 56 59 } 57 60 61 62 public IValueParameter<BoolValue> RotateEnabledParameter { 63 get { return (IValueParameter<BoolValue>)Parameters["RotateEnabled"]; } 64 } 65 66 public IValueParameter<BoolValue> RotatedParameter { 67 get { return (IValueParameter<BoolValue>)Parameters["Rotated"]; } 68 } 69 70 public IValueParameter<BoolValue> TiltEnabledParameter { 71 get { return (IValueParameter<BoolValue>)Parameters["TiltEnabled"]; } 72 } 73 74 public IValueParameter<BoolValue> TiltedParameter { 75 get { return (IValueParameter<BoolValue>)Parameters["Tilted"]; } 76 } 77 78 /// <summary> 79 /// Enables that the current item can be rotated. 80 /// </summary> 81 public bool RotateEnabled { 82 get { return RotateEnabledParameter.Value.Value; } 83 set { RotateEnabledParameter.Value.Value = value; } 84 } 85 86 /// <summary> 87 /// Indicates that the current item is rotated. 88 /// If the item is also tilted it will be tilted first. 89 /// </summary> 90 public bool Rotated { 91 get { return RotatedParameter.Value.Value; } 92 set { RotatedParameter.Value.Value = value; } 93 } 94 95 /// <summary> 96 /// Enables that the current item can be tilted. 97 /// </summary> 98 public bool TiltEnabled { 99 get { return TiltEnabledParameter.Value.Value; } 100 set { TiltEnabledParameter.Value.Value = value; } 101 } 102 103 /// <summary> 104 /// Indicates that the current item is tilted. 105 /// Tilted means that the item is tilted sidewards. 106 /// If the item is also rotated it will be tilted first. 107 /// </summary> 108 public bool Tilted { 109 get { return TiltedParameter.Value.Value; } 110 set { TiltedParameter.Value.Value = value; } 111 } 112 113 public IFixedValueParameter<IntValue> LoadSecuringHeightParameter { 114 get { return (IFixedValueParameter<IntValue>)Parameters["LoadSecuringHeight"]; } 115 } 116 117 public IFixedValueParameter<IntValue> LoadSecuringWidthParameter { 118 get { return (IFixedValueParameter<IntValue>)Parameters["LoadSecuringWidth"]; } 119 } 120 121 public IFixedValueParameter<IntValue> LoadSecuringDepthParameter { 122 get { return (IFixedValueParameter<IntValue>)Parameters["LoadSecuringDepth"]; } 123 } 124 125 public int LoadSecuringHeight { 126 get { return LoadSecuringHeightParameter.Value.Value; } 127 set { LoadSecuringHeightParameter.Value.Value = value; } 128 } 129 130 public int LoadSecuringWidth { 131 get { return LoadSecuringWidthParameter.Value.Value; } 132 set { LoadSecuringWidthParameter.Value.Value = value; } 133 } 134 135 public int LoadSecuringDepth { 136 get { return LoadSecuringDepthParameter.Value.Value; } 137 set { LoadSecuringDepthParameter.Value.Value = value; } 138 } 139 140 /// <summary> 141 /// This property represents the height as needed in the bin packing. 142 /// </summary> 143 public new int Height { 144 get { 145 if (!Tilted) { 146 return HeightParameter.Value.Value + LoadSecuringHeightParameter.Value.Value; 147 } else { 148 return WidthParameter.Value.Value + LoadSecuringHeightParameter.Value.Value; 149 } 150 } 151 } 152 153 /// <summary> 154 /// This property represents the width as needed in the bin packing. 155 /// </summary> 156 public new int Width { 157 get { 158 if (Rotated) { 159 return DepthParameter.Value.Value + LoadSecuringWidthParameter.Value.Value; 160 } else { 161 if (!Tilted) { 162 return WidthParameter.Value.Value + LoadSecuringWidthParameter.Value.Value; 163 } else { 164 return HeightParameter.Value.Value + LoadSecuringWidthParameter.Value.Value; 165 } 166 } 167 } 168 } 169 170 /// <summary> 171 /// This property represents the depth as needed in the bin packing. 172 /// </summary> 173 public new int Depth { 174 get { 175 if (!Rotated) { 176 return DepthParameter.Value.Value + LoadSecuringDepthParameter.Value.Value; 177 } else { 178 if (!Tilted) { 179 return WidthParameter.Value.Value + LoadSecuringDepthParameter.Value.Value; 180 } else { 181 return HeightParameter.Value.Value + LoadSecuringDepthParameter.Value.Value; 182 } 183 } 184 } 185 } 186 187 /// <summary> 188 /// This property represents the height as it is seen in the view of the bin packing. 189 /// </summary> 190 public int HeightInView { 191 get { 192 if (!Tilted) { 193 return HeightParameter.Value.Value; 194 } else { 195 return WidthParameter.Value.Value; 196 } 197 } 198 } 199 200 /// <summary> 201 /// This property represents the width as it is seen in the view of the bin packing. 202 /// </summary> 203 public int WidthInView { 204 get { 205 if (Rotated) { 206 return DepthParameter.Value.Value; 207 } else { 208 if (!Tilted) { 209 return WidthParameter.Value.Value; 210 } else { 211 return HeightParameter.Value.Value; 212 } 213 } 214 } 215 } 216 217 /// <summary> 218 /// This property represents the depth as it is seen in the view of the bin packing. 219 /// </summary> 220 public int DepthInView { 221 get { 222 if (!Rotated) { 223 return DepthParameter.Value.Value; 224 } else { 225 if (!Tilted) { 226 return WidthParameter.Value.Value; 227 } else { 228 return HeightParameter.Value.Value; 229 } 230 } 231 } 232 } 233 234 /// <summary> 235 /// This property represents the original height. 236 /// </summary> 237 public int OriginalHeight { 238 get { return HeightParameter.Value.Value; } 239 set { HeightParameter.Value.Value = value; } 240 } 241 242 /// <summary> 243 /// This property represents the original width. 244 /// </summary> 245 public int OriginalWidth { 246 get { return WidthParameter.Value.Value; } 247 set { WidthParameter.Value.Value = value; } 248 } 249 250 /// <summary> 251 /// This property represents the original depth. 252 /// </summary> 253 public int OriginalDepth { 254 get { return DepthParameter.Value.Value; } 255 set { DepthParameter.Value.Value = value; } 256 } 257 58 258 public bool SupportsStacking(IPackingItem other) { 59 259 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); 60 260 } 261 #endregion 262 61 263 62 264 [StorableConstructor] … … 71 273 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 72 274 Parameters.Add(new FixedValueParameter<IntValue>("Material")); 275 Parameters.Add(new FixedValueParameter<BoolValue>("RotateEnabled")); 276 Parameters.Add(new FixedValueParameter<BoolValue>("Rotated")); 277 Parameters.Add(new FixedValueParameter<BoolValue>("TiltEnabled")); 278 Parameters.Add(new FixedValueParameter<BoolValue>("Tilted")); 279 280 Parameters.Add(new FixedValueParameter<IntValue>("LoadSecuringHeight")); 281 Parameters.Add(new FixedValueParameter<IntValue>("LoadSecuringWidth")); 282 Parameters.Add(new FixedValueParameter<IntValue>("LoadSecuringDepth")); 73 283 74 284 RegisterEvents(); 75 285 } 76 286 287 public PackingItem(int width, int height, int depth, PackingShape targetBin) 288 : this() { 289 this.OriginalWidth = width; 290 this.OriginalHeight = height; 291 this.OriginalDepth = depth; 292 this.TargetBin = (PackingShape)targetBin.Clone(); 293 } 294 77 295 public PackingItem(int width, int height, int depth, PackingShape targetBin, double weight, int material) 78 : this() { 79 this.Width = width; 80 this.Height = height; 81 this.Depth = depth; 296 : this(width, height, depth, targetBin) { 82 297 this.Weight = weight; 83 298 this.Material = material; 84 this.TargetBin = (PackingShape)targetBin.Clone(); 85 } 86 87 public PackingItem(int width, int height, int depth, PackingShape targetBin) 299 } 300 301 302 303 public PackingItem(PackingItem packingItem) 88 304 : this() { 89 this.Width = width; 90 this.Height = height; 91 this.Depth = depth; 92 this.TargetBin = (PackingShape)targetBin.Clone(); 305 OriginalWidth = packingItem.OriginalWidth; 306 OriginalHeight = packingItem.OriginalHeight; 307 OriginalDepth = packingItem.OriginalDepth; 308 TargetBin = (PackingShape)packingItem.TargetBin.Clone(); 309 Weight = packingItem.Weight; 310 Material = packingItem.Material; 311 Rotated = packingItem.Rotated; 312 Tilted = packingItem.Tilted; 313 314 LoadSecuringDepth = packingItem.LoadSecuringDepth; 315 LoadSecuringHeight = packingItem.LoadSecuringHeight; 316 LoadSecuringWidth = packingItem.LoadSecuringWidth; 93 317 } 94 318 … … 110 334 } 111 335 112 113 336 public override string ToString() { 114 337 return string.Format("CuboidPackingItem ({0}, {1}, {2}; weight={3}, mat={4})", this.Width, this.Height, this.Depth, this.Weight, this.Material); 115 338 } 339 116 340 } 117 341 }
Note: See TracChangeset
for help on using the changeset viewer.