Changeset 13605 for branches/HeuristicLab.BinPacking
- Timestamp:
- 02/08/16 20:42:24 (9 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 9 added
- 1 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.BinPacking.sln
r13028 r13605 13 13 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.BinPacking.Views-3.3", "HeuristicLab.Problems.BinPacking.Views\3.3\HeuristicLab.Problems.BinPacking.Views-3.3.csproj", "{78763A4E-E163-48C2-98EB-709760D06F25}" 14 14 EndProject 15 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = " PackingPlanVisualizations", "PackingPlanVisualizations\PackingPlanVisualizations.csproj", "{0FD5EA67-A284-4166-9F45-9C6BC07D5B83}"15 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.BinPacking2D-3.3", "HeuristicLab.Problems.BinPacking.2D\3.3\HeuristicLab.Problems.BinPacking2D-3.3.csproj", "{56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}" 16 16 EndProject 17 17 Global … … 59 59 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x86.ActiveCfg = Release|x86 60 60 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x86.Build.0 = Release|x86 61 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 62 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Debug|Any CPU.Build.0 = Debug|Any CPU 63 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 64 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 65 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Debug|x64.ActiveCfg = Debug|Any CPU 66 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Debug|x86.ActiveCfg = Debug|Any CPU 67 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Release|Any CPU.ActiveCfg = Release|Any CPU 68 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Release|Any CPU.Build.0 = Release|Any CPU 69 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 70 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Release|Mixed Platforms.Build.0 = Release|Any CPU 71 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Release|x64.ActiveCfg = Release|Any CPU 72 {0FD5EA67-A284-4166-9F45-9C6BC07D5B83}.Release|x86.ActiveCfg = Release|Any CPU 61 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 62 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|Any CPU.Build.0 = Debug|Any CPU 63 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 64 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|Mixed Platforms.Build.0 = Debug|x86 65 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|x64.ActiveCfg = Debug|x64 66 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|x64.Build.0 = Debug|x64 67 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|x86.ActiveCfg = Debug|x86 68 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Debug|x86.Build.0 = Debug|x86 69 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|Any CPU.ActiveCfg = Release|Any CPU 70 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|Any CPU.Build.0 = Release|Any CPU 71 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|Mixed Platforms.ActiveCfg = Release|x86 72 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|Mixed Platforms.Build.0 = Release|x86 73 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|x64.ActiveCfg = Release|x64 74 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|x64.Build.0 = Release|x64 75 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|x86.ActiveCfg = Release|x86 76 {56DD7F51-3164-4C26-A97A-ADD6FE4B4E86}.Release|x86.Build.0 = Release|x86 73 77 EndGlobalSection 74 78 GlobalSection(SolutionProperties) = preSolution -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container2DView.xaml
r13578 r13605 1 <UserControl x:Class="HeuristicLab.Problems.BinPacking.Views.Container2DView" 1 <!-- 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Joseph Helm and 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 --> 21 22 <UserControl x:Class="HeuristicLab.Problems.BinPacking.Views.Container2DView" 2 23 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 24 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container2DView.xaml.cs
r13578 r13605 1 using System; 2 using System.Linq; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Joseph Helm and 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 22 using System; 3 23 using System.Windows; 4 using System.Windows.Forms;5 using System.Windows.Input;6 24 using System.Windows.Media; 7 using System.Windows.Media.Media3D;8 25 using HeuristicLab.Encodings.PackingEncoding.PackingPlan; 9 26 using HeuristicLab.Problems.BinPacking.Dimensions; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml
r13576 r13605 1 <UserControl x:Class="HeuristicLab.Problems.BinPacking.Views.Container3DView" 1 <!-- 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Joseph Helm and 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 --> 21 22 <UserControl x:Class="HeuristicLab.Problems.BinPacking.Views.Container3DView" 2 23 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 24 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml.cs
r13576 r13605 1 using System; 1 /* HeuristicLab 2 * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL) 3 * 4 * This file is part of HeuristicLab. 5 * 6 * HeuristicLab is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * HeuristicLab is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with HeuristicLab. If not, see<http://www.gnu.org/licenses/> . 18 */ 19 20 using System; 2 21 using System.Linq; 3 22 using System.Windows; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/HeuristicLab.Problems.BinPacking.Views-3.3.csproj
r13578 r13605 158 158 <DependentUpon>Container2DView.xaml</DependentUpon> 159 159 </Compile> 160 <Compile Include="PackingPlan2DView.cs"> 161 <SubType>UserControl</SubType> 162 </Compile> 160 <Compile Include="PackingPlan2DView.cs" /> 163 161 <Compile Include="PackingPlan2DView.Designer.cs"> 164 162 <DependentUpon>PackingPlan2DView.cs</DependentUpon> 165 163 </Compile> 166 <Compile Include="PackingPlan3DView.cs"> 167 <SubType>UserControl</SubType> 168 </Compile> 164 <Compile Include="PackingPlan3DView.cs" /> 169 165 <Compile Include="PackingPlan3DView.Designer.cs"> 170 166 <DependentUpon>PackingPlan3DView.cs</DependentUpon> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs
r13032 r13605 33 33 using HeuristicLab.Problems.BinPacking.Evaluators; 34 34 35 namespace HeuristicLab.Problems.BinPacking.Analyzers { 35 namespace HeuristicLab.Problems.BinPacking.Analyzers { 36 36 [Item("BestBinPackingSolutionAnalyzer", "An operator for analyzing the best solution of BinPacking Problems given in packingPlan-representation.")] 37 37 [StorableClass] … … 40 40 where B : PackingShape<D>, IPackingBin, IRegularPackingShape 41 41 where I : PackingShape<D>, IPackingItem, IRegularPackingShape { 42 43 protected BestBinPackingSolutionAnalyzer(BestBinPackingSolutionAnalyzer<D,B,I> original, Cloner cloner)44 : base(original, cloner) {45 }46 public override IDeepCloneable Clone(Cloner cloner) {47 return new BestBinPackingSolutionAnalyzer<D,B,I>(this, cloner);48 }49 50 42 51 43 public ILookupParameter<IRandom> RandomParameter { … … 56 48 } 57 49 50 [StorableConstructor] 51 protected BestBinPackingSolutionAnalyzer(bool deserializing) : base(deserializing) { } 52 protected BestBinPackingSolutionAnalyzer(BestBinPackingSolutionAnalyzer<D, B, I> original, Cloner cloner) 53 : base(original, cloner) { 54 } 58 55 public BestBinPackingSolutionAnalyzer() 59 56 : base() { 60 57 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator.")); 58 } 59 public override IDeepCloneable Clone(Cloner cloner) { 60 return new BestBinPackingSolutionAnalyzer<D, B, I>(this, cloner); 61 61 } 62 62 … … 105 105 string nocKey = "Nr Of Containers"; 106 106 if (!results.ContainsKey(nocKey)) 107 results.Add(new Result(nocKey, new IntValue 107 results.Add(new Result(nocKey, new IntValue(bestSolution.NrOfBins))); 108 108 else 109 results[nocKey].Value = new IntValue 109 results[nocKey].Value = new IntValue(bestSolution.NrOfBins); 110 110 111 111 return base.Apply(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BinPackingAnalyzer.cs
r13032 r13605 42 42 } 43 43 44 protected BinPackingAnalyzer(BinPackingAnalyzer<D,B,I> original, Cloner cloner)45 : base(original, cloner) {46 }47 48 44 #region Parameter Properties 49 45 public LookupParameter<BoolValue> MaximizationParameter { … … 70 66 #endregion 71 67 72 public BinPackingAnalyzer() 68 [StorableConstructor] 69 protected BinPackingAnalyzer(bool deserializing) : base(deserializing) { } 70 protected BinPackingAnalyzer(BinPackingAnalyzer<D, B, I> original, Cloner cloner) 71 : base(original, cloner) { 72 } 73 protected BinPackingAnalyzer() 73 74 : base() { 74 75 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem.")); 75 76 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the packing solutions which should be analyzed.")); 76 Parameters.Add(new ScopeTreeLookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The solutions from which the best solution has to be chosen from."));77 77 Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("BestSolution", "The best performing packing plan.")); 78 78 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best packing solution should be stored.")); 79 79 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this packing-problem instance.")); 80 80 Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("BestKnownSolution", "The best known solution of this packing-problem instance.")); 81 Parameters.Add(new ScopeTreeLookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The solutions from which the best solution has to be chosen from.")); 81 82 } 82 83 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/PackingDimensions.cs
r13032 r13605 21 21 22 22 23 using System;24 using System.Text;25 23 using HeuristicLab.Problems.BinPacking.Interfaces; 26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 31 29 [Item("Packing Dimensions", "Represents an abstract packing-position associated with a packing-problem.")] 32 30 [StorableClass] 31 // PackingDimensions is immutable (and handled as value types concerning Equals and GetHashCode) 33 32 public abstract class PackingDimensions : Item, IPackingDimensions { 34 33 /// <summary> 35 34 /// The number of the bin to which the current item is assigned is stored in this variable. Counting starts at 0 !!! 35 /// </summary> 36 [Storable] 37 private readonly int assignedBin; 38 public int AssignedBin { 39 get { return assignedBin; } 40 } 41 42 [Storable] 43 private readonly bool rotated; 44 /// <summary> 45 /// Determines if the positioned item is to be rotate by 90 degrees or not. (TODO: which axis?) 36 46 /// </summary> 37 public Int32 AssignedBin { get; set; } 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; } 47 public bool Rotated { 48 get { return rotated; } 49 } 42 50 43 51 [StorableConstructor] … … 45 53 protected PackingDimensions(PackingDimensions original, Cloner cloner) 46 54 : base(original, cloner) { 47 AssignedBin = original.AssignedBin;48 Rotated = original.Rotated;55 assignedBin = original.AssignedBin; 56 rotated = original.Rotated; 49 57 } 50 58 51 p ublic PackingDimensions(Int32 assignedBin, Booleanrotated) {52 this. AssignedBin = assignedBin;53 this. Rotated = rotated;59 protected PackingDimensions(int assignedBin, bool rotated) { 60 this.assignedBin = assignedBin; 61 this.rotated = rotated; 54 62 } 55 63 56 64 public override string ToString() { 57 StringBuilder sb = new StringBuilder(); 58 sb.Append("["); 59 sb.Append(AssignedBin + "-"); 60 sb.Append(Rotated); 61 sb.Append("]"); 62 return sb.ToString(); 65 return string.Format("[{0}-{1}]", AssignedBin, Rotated); 63 66 } 64 67 65 68 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 var other = obj as PackingDimensions; 70 if (other != null) 71 return (other.AssignedBin == this.AssignedBin && other.Rotated == this.Rotated); 69 72 else return false; 70 73 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/ThreeDimensionalPacking.cs
r13032 r13605 28 28 [Item("Three Dimensional Packing", "Represents a packing-position associated with a three dimensional packing-problem.")] 29 29 [StorableClass] 30 public class ThreeDimensionalPacking: PackingDimensions { 31 public int X { get; set; } 32 public int Y { get; set; } 33 public int Z { get; set; } 30 // ThreeDimensionalPacking is immutable (and handled as value type concerning Equals and GetHashCode) 31 public class ThreeDimensionalPacking : PackingDimensions { 32 [Storable] 33 private readonly int x; 34 [Storable] 35 private readonly int y; 36 [Storable] 37 private readonly int z; 38 39 public int X { get { return x; } } 40 public int Y { get { return y; } } 41 public int Z { get { return z; } } 34 42 35 43 [StorableConstructor] … … 37 45 protected ThreeDimensionalPacking(ThreeDimensionalPacking original, Cloner cloner) 38 46 : base(original, cloner) { 39 X= original.X;40 Y= original.Y;41 Z= original.Z;47 x = original.X; 48 y = original.Y; 49 z = original.Z; 42 50 } 43 51 public override IDeepCloneable Clone(Cloner cloner) { … … 45 53 } 46 54 47 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z) : this(assignedBin, x, y, z, false) {} 48 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z, bool rotated) 55 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z, bool rotated = false) 49 56 : base(assignedBin, rotated) { 50 this. X= x;51 this. Y= y;52 this. Z= z;57 this.x = x; 58 this.y = y; 59 this.z = z; 53 60 } 61 54 62 public override string ToString() { 55 StringBuilder sb = new StringBuilder(); 56 sb.Append("["); 57 sb.Append("AssignedBin: "); 58 sb.Append(AssignedBin); 59 sb.Append("; ("); 60 sb.Append(X + ","); 61 sb.Append(Y + ","); 62 sb.Append(Z); 63 sb.Append(")"); 64 sb.Append("]"); 65 return sb.ToString(); 63 return string.Format("[AssignedBin: {0}; ({1},{2},{3})]", AssignedBin, X, Y, Z); 66 64 } 67 65 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/TwoDimensionalPacking.cs
r13032 r13605 28 28 [Item("Two Dimensional Packing", "Represents a packing-position associated with a two dimensional packing-problem.")] 29 29 [StorableClass] 30 // TwoDimensionalPacking is an immutable class (and handled as value type concerning Equals and GetHashCode()) 30 31 public class TwoDimensionalPacking : PackingDimensions { 31 public int X { get; set; } 32 public int Y { get; set; } 32 [Storable] 33 private readonly int x; 34 public int X { get { return x; } } 35 36 [Storable] 37 private readonly int y; 38 public int Y { get { return y; } } 33 39 34 40 [StorableConstructor] … … 36 42 protected TwoDimensionalPacking(TwoDimensionalPacking original, Cloner cloner) 37 43 : base(original, cloner) { 38 X= original.X;39 Y= original.Y;44 x = original.X; 45 y = original.Y; 40 46 } 47 48 public TwoDimensionalPacking(int assignedBin, int x, int y, bool rotated = false) 49 : base(assignedBin, rotated) { 50 this.x = x; 51 this.y = y; 52 } 53 41 54 public override IDeepCloneable Clone(Cloner cloner) { 42 55 return new TwoDimensionalPacking(this, cloner); 43 56 } 44 45 public TwoDimensionalPacking(int assignedBin, int x, int y) : this(assignedBin, x, y, false) { } 46 public TwoDimensionalPacking(int assignedBin, int x, int y, bool rotated) 47 : base(assignedBin, rotated) { 48 this.X = x; 49 this.Y = y; 50 } 57 51 58 public override string ToString() { 52 StringBuilder sb = new StringBuilder(); 53 sb.Append("["); 54 sb.Append("AssignedBin: "); 55 sb.Append(AssignedBin); 56 sb.Append("; ("); 57 sb.Append(X + ","); 58 sb.Append(Y); 59 sb.Append(")"); 60 sb.Append("]"); 61 return sb.ToString(); 59 return string.Format("[AssignedBin: {0}; ({1},{2})]", AssignedBin, x, y); 62 60 } 63 61 64 65 62 public override bool Equals(object obj) { 66 var tdp= obj as TwoDimensionalPacking;67 if ( tdp!= null)68 return ( tdp.X == this.X && tdp.Y == this.Y);63 var other = obj as TwoDimensionalPacking; 64 if (other != null) 65 return (other.X == this.X && other.Y == this.Y && base.Equals(other)); 69 66 else return false; 70 67 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r13578 r13605 101 101 double result = 0; 102 102 foreach (var entry in ItemMeasures) 103 result += entry.Value. MultipliedMeasures;104 result /= BinMeasures. MultipliedMeasures;103 result += entry.Value.Volume; 104 result /= BinMeasures.Volume; 105 105 return result; 106 106 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract/BinUtilizationRegularIdenticalBinEvaluator.cs
r13032 r13605 87 87 88 88 for (int i = 0; i < nrOfBins; i++) { 89 double usableSpace = plan.BinPackings[i].BinMeasures. MultipliedMeasures;89 double usableSpace = plan.BinPackings[i].BinMeasures.Volume; 90 90 //var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index); 91 91 //var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index)); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r13461 r13605 287 287 <Compile Include="Interfaces\I2DOperator.cs" /> 288 288 <Compile Include="Interfaces\IPackingMove.cs" /> 289 <Compile Include="Interfaces\IPotvinOperator.cs" />290 289 <Compile Include="Interfaces\IMultiComponentVectorMoveOperator.cs" /> 291 290 <Compile Include="Interfaces\IGroupingVectorMoveOperator.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/I2DOperator.cs
r13032 r13605 20 20 #endregion 21 21 22 23 22 namespace HeuristicLab.Problems.BinPacking.Interfaces { 24 23 public interface I2DOperator { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/I3DOperator.cs
r13032 r13605 20 20 #endregion 21 21 22 23 22 namespace HeuristicLab.Problems.BinPacking.Interfaces { 24 23 public interface I3DOperator { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingBin.cs
r13032 r13605 22 22 23 23 namespace HeuristicLab.Problems.BinPacking.Interfaces { 24 public interface IPackingBin : IPackingShape {25 }24 // a packing bin represents the container for a packing solution 25 public interface IPackingBin : IPackingShape { } 26 26 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingDimensions.cs
r13032 r13605 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Core; 24 23 25 24 namespace HeuristicLab.Problems.BinPacking.Interfaces { 25 // TODO: this interface should contain positions 26 26 public interface IPackingDimensions : IItem { 27 Int32AssignedBin { get; }27 int AssignedBin { get; } 28 28 bool Rotated { get; } 29 29 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingItem.cs
r13032 r13605 20 20 #endregion 21 21 22 23 22 namespace HeuristicLab.Problems.BinPacking.Interfaces { 23 // a packing item is one of the items that needs to be located in one of the packing bins (containers) 24 24 public interface IPackingItem : IPackingShape { 25 void AddTargetBinMeasures(int[] targetBinMeasures);26 25 double Weight { get; set; } 27 26 int Material { get; set; } 28 27 /// <summary> 29 /// Returns if the "other" item can be stacked on this item.28 /// Returns true if the "other" item can be stacked on this item. 30 29 /// </summary> 31 30 /// <param name="other"></param> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingPlan.cs
r13462 r13605 23 23 24 24 namespace HeuristicLab.Problems.BinPacking.Interfaces { 25 // represents a packing solution (either 2d or 3d) 25 26 public interface IPackingPlan : IItem { 26 27 int NrOfBins { get; } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingShape.cs
r13461 r13605 23 23 24 24 namespace HeuristicLab.Problems.BinPacking.Interfaces { 25 public interface IPackingShape : IItem { 26 } 25 // a packing shape represents a physical object of correct dimension (2d or 3d) 26 // packing bins (containers) and packing items are both packing shapes 27 public interface IPackingShape : IItem { } 27 28 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IRegularPackingShape.cs
r13032 r13605 25 25 ///A regularPackingShape has special geometric properties that allow special handling = Rectangle, Cuboid 26 26 public interface IRegularPackingShape : IPackingShape, IComparable { 27 int MultipliedMeasures{ get; }27 int Volume { get; } 28 28 void ApplyHorizontalOrientation(); 29 29 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/CuboidPackingItem.cs
r13574 r13605 34 34 [StorableClass] 35 35 public class CuboidPackingItem : CuboidPackingShape, IPackingItem { 36 public IValueParameter<CuboidPackingBin> TargetBinParameter { 37 get { return (IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]; } 38 } 39 public IFixedValueParameter<DoubleValue> WeightParameter { 40 get { return (IFixedValueParameter<DoubleValue>)Parameters["Weight"]; } 41 } 42 public IFixedValueParameter<IntValue> MaterialParameter { 43 get { return (IFixedValueParameter<IntValue>)Parameters["Material"]; } 44 } 45 36 46 public CuboidPackingBin TargetBin { 37 get { return ((IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]).Value; }38 set { ((IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]).Value = value; }47 get { return TargetBinParameter.Value; } 48 set { TargetBinParameter.Value = value; } 39 49 } 40 50 41 51 public double Weight { 42 get { return ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value; }43 set { ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value = value; }52 get { return WeightParameter.Value.Value; } 53 set { WeightParameter.Value.Value = value; } 44 54 } 45 55 46 56 public int Material { 47 get { return ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value; }48 set { ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value = value; }57 get { return MaterialParameter.Value.Value; } 58 set { MaterialParameter.Value.Value = value; } 49 59 } 50 60 … … 57 67 protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner) 58 68 : base(original, cloner) { 69 RegisterEvents(); 59 70 } 60 71 public CuboidPackingItem() … … 63 74 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 64 75 Parameters.Add(new FixedValueParameter<IntValue>("Material")); 76 77 RegisterEvents(); 65 78 } 66 79 … … 83 96 } 84 97 98 [StorableHook(HookType.AfterDeserialization)] 99 private void AfterDeserialization() { 100 RegisterEvents(); 101 } 102 85 103 public override IDeepCloneable Clone(Cloner cloner) { 86 104 return new CuboidPackingItem(this, cloner); 87 105 } 88 106 89 public void AddTargetBinMeasures(int[] targetBinMeasures) { 90 TargetBin = new CuboidPackingBin(targetBinMeasures[0], targetBinMeasures[1], targetBinMeasures[2]); 107 private void RegisterEvents() { 108 // only because of ToString override 109 WeightParameter.Value.ValueChanged += (sender, args) => OnToStringChanged(); 110 MaterialParameter.Value.ValueChanged += (sender, args) => OnToStringChanged(); 111 112 // target bin does not occur in ToString() 91 113 } 92 114 115 93 116 public override string ToString() { 94 return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight, this.Material);117 return string.Format("CuboidPackingItem ({0}, {1}, {2}; weight={3}, mat={4})", this.Width, this.Height, this.Depth, this.Weight, this.Material); 95 118 } 96 119 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/RectangularPackingItem.cs
r13574 r13605 77 77 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); 78 78 } 79 80 public void AddTargetBinMeasures(int[] targetBinMeasures) {81 TargetBin = new RectangularPackingBin(targetBinMeasures[0], targetBinMeasures[1]);82 }83 79 } 84 80 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/BinPackingProblem.cs
r13032 r13605 86 86 } 87 87 88 89 90 91 #region Helpers92 88 protected abstract void InitializeDecoder(); 93 89 protected abstract void InitializeProblemInstance(); 94 90 protected abstract void InitializeOperators(); 95 91 protected abstract void InitializeEventHandlers(); 96 #endregion97 92 } 98 93 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RegularIdenticalBinPackingProblem.cs
r13461 r13605 112 112 private int CalculateLowerBound() { 113 113 //This is the obvious continuous lower bound calculation; Martello and Vigo proposed a better way but it has not been implemented yet; 114 int items = PackingItemMeasures.Select(x => x. MultipliedMeasures).Sum();115 int bin = PackingBinMeasures. MultipliedMeasures;114 int items = PackingItemMeasures.Select(x => x.Volume).Sum(); 115 int bin = PackingBinMeasures.Volume; 116 116 return (items + bin - 1)/(bin); 117 117 } … … 229 229 #region Problem instance handling 230 230 public virtual void Load(BPPData data) { 231 var realData = data as RealBPPData; 232 var binData = new B(); 233 binData.InitializeFromMeasures (data.BinMeasures); 234 235 var itemData = new ItemList<I>(data.Items); 236 for (int j = 0; j < data.Items; j++) { 237 var item = new I(); 238 item.InitializeFromMeasures(data.ItemMeasures[j]); 239 item.AddTargetBinMeasures(data.BinMeasures); 240 if (realData != null) { 241 item.Weight = realData.ItemWeights[j]; 242 item.Material = realData.ItemMaterials[j]; 243 } 244 itemData.Add(item); 245 } 246 247 BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null; 248 249 PackingBinMeasures = binData; 250 PackingItemMeasures = itemData; 251 252 ApplyHorizontalOrientation(); 253 SortItems(); 254 PackingItemsParameter.Value.Value = PackingItemMeasures.Count; 255 LowerBoundParameter.Value.Value = CalculateLowerBound(); 231 // var realData = data as RealBPPData; 232 // var binData = new B(); 233 // binData.InitializeFromMeasures (data.BinMeasures); 234 // 235 // var itemData = new ItemList<I>(data.Items); 236 // for (int j = 0; j < data.Items; j++) { 237 // var item = new I(); 238 // item.InitializeFromMeasures(data.ItemMeasures[j]); 239 // item.AddTargetBinMeasures(data.BinMeasures); 240 // if (realData != null) { 241 // item.Weight = realData.ItemWeights[j]; 242 // item.Material = realData.ItemMaterials[j]; 243 // } 244 // itemData.Add(item); 245 // } 246 // 247 // BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null; 248 // 249 // PackingBinMeasures = binData; 250 // PackingItemMeasures = itemData; 251 // 252 // ApplyHorizontalOrientation(); 253 // SortItems(); 254 // PackingItemsParameter.Value.Value = PackingItemMeasures.Count; 255 // LowerBoundParameter.Value.Value = CalculateLowerBound(); 256 257 throw new NotImplementedException(); 256 258 } 257 259 258 260 public BPPData Export() { 259 var result = new BPPData{ 260 Name = Name, 261 Description = Description, 262 Items = PackingItemsParameter.Value.Value, 263 BinMeasures = PackingBinMeasures.ToArray() 264 }; 265 266 var itemMeasures = new int[result.Items][]; 267 int i = 0; 268 foreach (var item in PackingItemMeasures) { 269 itemMeasures[i] = item.ToArray(); 270 i++; 271 } 272 result.ItemMeasures = itemMeasures; 273 return result; 261 // var result = new BPPData{ 262 // Name = Name, 263 // Description = Description, 264 // Items = PackingItemsParameter.Value.Value, 265 // BinMeasures = PackingBinMeasures.ToArray() // TODO: split functionality of class in 2d and 3d code 266 // }; 267 // 268 // var itemMeasures = new int[result.Items][]; 269 // int i = 0; 270 // foreach (var item in PackingItemMeasures) { 271 // itemMeasures[i] = item.ToArray(); 272 // i++; 273 // } 274 // result.ItemMeasures = itemMeasures; 275 // return result; 276 277 throw new NotImplementedException(); 274 278 } 275 279 #endregion -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r13574 r13605 21 21 22 22 using System; 23 using System.Diagnostics;24 23 using HeuristicLab.Problems.BinPacking.Interfaces; 25 24 using HeuristicLab.Core; … … 34 33 [StorableClass] 35 34 public abstract class CuboidPackingShape : PackingShape<ThreeDimensionalPacking>, IRegularPackingShape, IComparable<CuboidPackingShape> { 36 #region Properties 35 public IFixedValueParameter<IntValue> HeightParameter { 36 get { return (IFixedValueParameter<IntValue>)Parameters["Height"]; } 37 } 38 public IFixedValueParameter<IntValue> WidthParameter { 39 get { return (IFixedValueParameter<IntValue>)Parameters["Width"]; } 40 } 41 public IFixedValueParameter<IntValue> DepthParameter { 42 get { return (IFixedValueParameter<IntValue>)Parameters["Depth"]; } 43 } 44 37 45 public int Height { 38 get { return ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value; }39 set { ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value = value; }46 get { return HeightParameter.Value.Value; } 47 set { HeightParameter.Value.Value = value; } 40 48 } 41 49 42 50 public int Width { 43 get { return ((IFixedValueParameter<IntValue>)Parameters["Width"]).Value.Value; }44 set { ((IFixedValueParameter<IntValue>)Parameters["Width"]).Value.Value = value; }51 get { return WidthParameter.Value.Value; } 52 set { WidthParameter.Value.Value = value; } 45 53 } 46 54 47 55 public int Depth { 48 get { return ((IFixedValueParameter<IntValue>)Parameters["Depth"]).Value.Value; } 49 set { ((IFixedValueParameter<IntValue>)Parameters["Depth"]).Value.Value = value; } 56 get { return DepthParameter.Value.Value; } 57 set { DepthParameter.Value.Value = value; } 58 } 59 60 [StorableConstructor] 61 protected CuboidPackingShape(bool deserializing) : base(deserializing) { } 62 protected CuboidPackingShape(CuboidPackingShape original, Cloner cloner) 63 : base(original, cloner) { 64 RegisterEvents(); 65 } 66 protected CuboidPackingShape() 67 : base() { 68 Parameters.Add(new FixedValueParameter<IntValue>("Width")); 69 Parameters.Add(new FixedValueParameter<IntValue>("Height")); 70 Parameters.Add(new FixedValueParameter<IntValue>("Depth")); 71 72 RegisterEvents(); 73 } 74 75 protected CuboidPackingShape(int width, int height, int depth) 76 : this() { 77 this.Width = width; 78 this.Height = height; 79 this.Depth = depth; 80 } 81 82 [StorableHook(HookType.AfterDeserialization)] 83 private void AfterDeserialization() { 84 RegisterEvents(); 85 } 86 87 private void RegisterEvents() { 88 // only because of ToString override 89 HeightParameter.Value.ValueChanged += (sender, args) => OnToStringChanged(); 90 WidthParameter.Value.ValueChanged += (sender, args) => OnToStringChanged(); 91 DepthParameter.Value.ValueChanged += (sender, args) => OnToStringChanged(); 92 } 93 94 public override string ToString() { 95 return String.Format("CuboidPackingShape ({0}, {1}, {2})", this.Width, this.Height, this.Depth); 96 } 97 98 #region IComparable Members 99 100 public int CompareTo(CuboidPackingShape other) { 101 //Using "Clustered-Area-Height"-comparison as descr 102 103 int result = (this.Width * this.Depth).CompareTo(other.Width * other.Depth); 104 105 if (result == 0) 106 result = this.Volume.CompareTo(other.Volume); 107 if (result == 0) 108 result = this.Height.CompareTo(other.Height); 109 return result; 110 } 111 112 public int CompareTo(object obj) { 113 var other = (CuboidPackingShape)obj; 114 if (other != null) return CompareTo(other); 115 else throw new ArgumentException(string.Format("Cannot compare with object {0}", obj), "obj"); 50 116 } 51 117 52 118 #endregion 53 119 120 private struct CuboidDiagonal { 121 public int x1; 122 public int y1; 123 public int z1; 124 public int x2; 125 public int y2; 126 public int z2; 127 public CuboidDiagonal(CuboidPackingShape myShape) : this(new ThreeDimensionalPacking(0, 0, 0, 0), myShape) { } 128 public CuboidDiagonal(ThreeDimensionalPacking myPosition, CuboidPackingShape myShape) { 129 x1 = myPosition.X; 130 y1 = myPosition.Y; 131 z1 = myPosition.Z; 132 x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width) - 1; 133 y2 = myPosition.Y + myShape.Height - 1; 134 z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth) - 1; 135 } 136 } 137 138 54 139 #region Helpers 55 140 public override ThreeDimensionalPacking Origin { get { return new ThreeDimensionalPacking(0, 0, 0, 0); } } 56 public override int MultipliedMeasures{ get { return Width * Height * Depth; } }141 public override int Volume { get { return Width * Height * Depth; } } 57 142 58 143 public override bool EnclosesPoint(ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPoint) { … … 103 188 #endregion 104 189 105 106 107 public override void InitializeFromMeasures(int[] measures) {108 if (measures.Length != 3)109 throw new InvalidOperationException("Nr of measures does not fit shape-dimension.");110 this.Width = measures[0];111 this.Height = measures[1];112 this.Depth = measures[2];113 }114 public override int[] ToArray() {115 return new int[] { Width, Height, Depth };116 }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 133 [StorableConstructor]134 protected CuboidPackingShape(bool deserializing) : base(deserializing) { }135 protected CuboidPackingShape(CuboidPackingShape original, Cloner cloner)136 : base(original, cloner) {137 }138 139 public override string ToString() {140 return String.Format("CuboidPackingShape ({0}, {1}, {2})", this.Width, this.Height, this.Depth);141 }142 143 #region IComparable Members144 145 public int CompareTo(CuboidPackingShape other) {146 //Using "Clustered-Area-Height"-comparison as descr147 148 int result = (this.Width * this.Depth).CompareTo(other.Width * other.Depth);149 150 if (result == 0)151 result = this.MultipliedMeasures.CompareTo(other.MultipliedMeasures);152 if (result == 0)153 result = this.Height.CompareTo(other.Height);154 return result;155 }156 157 public int CompareTo(object obj) {158 var other = (CuboidPackingShape)obj;159 if (other != null) return CompareTo(other);160 else throw new ArgumentException(string.Format("Cannot compare with object {0}", obj), "obj");161 }162 163 #endregion164 165 private struct CuboidDiagonal {166 public int x1;167 public int y1;168 public int z1;169 public int x2;170 public int y2;171 public int z2;172 public CuboidDiagonal(CuboidPackingShape myShape) : this(new ThreeDimensionalPacking(0, 0, 0, 0), myShape) { }173 public CuboidDiagonal(ThreeDimensionalPacking myPosition, CuboidPackingShape myShape) {174 x1 = myPosition.X;175 y1 = myPosition.Y;176 z1 = myPosition.Z;177 x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width) - 1;178 y2 = myPosition.Y + myShape.Height - 1;179 z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth) - 1;180 }181 }182 190 } 183 191 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/PackingShape.cs
r13574 r13605 42 42 public abstract bool Encloses(T checkedPosition, PackingShape<T> checkedShape); 43 43 public abstract bool Overlaps(T myPosition, T checkedPosition, PackingShape<T> checkedShape); 44 public abstract void InitializeFromMeasures(int[] measures); 45 public abstract int[] ToArray(); 46 public abstract int MultipliedMeasures { get; } 44 public abstract int Volume { get; } 47 45 public abstract T Origin { get; } 48 46 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
r13574 r13605 34 34 [StorableClass] 35 35 public abstract class RectangularPackingShape : PackingShape<TwoDimensionalPacking>, IRegularPackingShape, IComparable<RectangularPackingShape> { 36 #region Properties37 36 public int Height { 38 37 get { return ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value; } … … 45 44 } 46 45 47 #endregion 48 46 [StorableConstructor] 47 protected RectangularPackingShape(bool deserializing) : base(deserializing) { } 48 protected RectangularPackingShape(RectangularPackingShape original, Cloner cloner) 49 : base(original, cloner) { 50 } 49 51 protected RectangularPackingShape() 50 52 : base() { … … 57 59 this.Width = width; 58 60 } 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 61 75 62 public override string ToString() { … … 94 81 #endregion 95 82 96 public override int[] ToArray() {97 return new int[] { Width, Height };98 }99 100 101 83 102 84 #region Helpers 103 85 public override TwoDimensionalPacking Origin { get { return new TwoDimensionalPacking(0, 0, 0); } } 104 public override int MultipliedMeasures{ get { return Height * Width; } }86 public override int Volume { get { return Height * Width; } } 105 87 106 88 public override bool EnclosesPoint(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPoint) {
Note: See TracChangeset
for help on using the changeset viewer.