Changeset 13460 for branches/HeuristicLab.BinPacking
- Timestamp:
- 12/14/15 18:59:13 (9 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
- Files:
-
- 1 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r13021 r13460 154 154 <Reference Include="System.Core" /> 155 155 <Reference Include="System.Drawing" /> 156 <Reference Include="System.IO.Compression" /> 157 <Reference Include="System.IO.Compression.FileSystem" /> 156 158 <Reference Include="System.Windows.Forms" /> 157 159 </ItemGroup> … … 272 274 <Compile Include="Evaluators\Abstract\PackingPlanEvaluator.cs" /> 273 275 <Compile Include="Instances\BPPData.cs" /> 276 <Compile Include="Instances\BPPInstanceProvider.cs" /> 274 277 <Compile Include="Instances\BPPORLIBParser.cs" /> 275 278 <Compile Include="Instances\BPPORLIBDataDescriptor.cs" /> … … 341 344 <ItemGroup> 342 345 <None Include="HeuristicLab.snk" /> 343 < None Include="Instances\Data\BPPORLIB.rar" />346 <EmbeddedResource Include="Instances\Data\BPPORLIB.zip" /> 344 347 <None Include="Properties\AssemblyInfo.cs.frame" /> 345 348 <None Include="Plugin.cs.frame" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Instances/BPPInstanceProvider.cs
r13032 r13460 24 24 using System.Collections.Generic; 25 25 using System.IO; 26 using System.IO.Compression; 26 27 using System.Linq; 27 28 using System.Reflection; 28 29 using System.Text.RegularExpressions; 30 using System.Windows.Forms; 29 31 30 32 namespace HeuristicLab.Problems.Instances.BinPacking { 31 public class BPPORLIBInstanceProvider : ProblemInstanceProvider<BPPData> {33 public class BPPORLIBInstanceProvider : ProblemInstanceProvider<BPPData>, IProblemInstanceProvider<BPPData> { 32 34 33 35 public override string Name { … … 51 53 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 52 54 53 using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 54 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) { 55 yield return new BPPORLIBDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry, null); 55 56 using (var file = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 57 58 foreach (var entry in file.Entries.OrderBy(x => x.Name)) { 59 if (string.IsNullOrWhiteSpace(entry.Name)) continue; 60 yield return new BPPORLIBDataDescriptor( 61 name: Path.GetFileNameWithoutExtension(entry.Name), 62 description: GetDescription(), 63 instanceIdentifier: entry.FullName, 64 solutionIdentifier: null); 56 65 } 57 66 } … … 60 69 public override BPPData LoadData(IDataDescriptor id) { 61 70 var descriptor = (BPPORLIBDataDescriptor)id; 62 var instanceArchiveName = GetResourceName(" JSSPORLIB.zip");63 using (var instancesZipFile = new Zip File(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {71 var instanceArchiveName = GetResourceName("BPPORLIB.zip"); 72 using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 64 73 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 65 74 66 using (var stream = instancesZipFile.GetInputStream(entry)) {75 using (var stream = entry.Open()) { 67 76 var parser = new BPPORLIBParser(); 68 77 parser.Parse(stream); … … 84 93 var instance = Load(parser); 85 94 instance.Name = Path.GetFileName(path); 86 instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now .ToString();95 instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now; 87 96 return instance; 88 97 } … … 120 129 .SingleOrDefault(x => Regex.Match(x, @".*\.Data\." + fileName).Success); 121 130 } 122 123 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) {124 ZipEntry entry;125 while ((entry = zipFile.GetNextEntry()) != null) {126 yield return entry.Name;127 }128 }129 131 } 130 132 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Instances/BPPORLIBParser.cs
r13032 r13460 64 64 /// <returns>True if the file was successfully read or false otherwise.</returns> 65 65 public void Parse(Stream stream) { 66 var reader = new StreamReader(stream); 67 var delim = new char[] { ' ', '\t' }; 66 var reader = new StreamReader(stream); 67 var delim = new char[] { ' ', '\t' }; 68 68 var problemClass = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries); 69 69 … … 118 118 Description = "<Missing>"; 119 119 } 120 120 121 121 122 122 } … … 135 135 else 136 136 writer.WriteLine("{0,-5} {1,-5} {2,-5}", ItemMeasures[i][0], ItemMeasures[i][1], ItemMeasures[i][2]); 137 137 138 } 138 139 writer.Flush(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/CuboidIdenticalBinPackingProblem.cs
r13032 r13460 36 36 37 37 namespace HeuristicLab.Problems.BinPacking.Problem { 38 [Item(" CuboidIdenticalBinPackingProblem", "Represents a three-dimensional bin-packing problem using only bins with identical measures and bins/items with cuboidic shapes.")]38 [Item("Bin Packing Problem (3D, identical cuboids) (BPP)", "Represents a three-dimensional bin-packing problem using only bins with identical measures and bins/items with cuboidic shapes.")] 39 39 [StorableClass] 40 [Creatable( "Problems")]40 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 310)] 41 41 public class CuboidIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 42 42 … … 109 109 #region Helpers 110 110 protected override void InitializeDecoder() { 111 Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType()));111 Operators.RemoveAll(op => op is I2DOperator); 112 112 113 113 PackingSolutionDecoderParameter.ValidValues.Clear(); 114 114 if (SolutionCreator is PackingSequenceRandomCreator) { 115 115 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DPSDecoder>()); 116 //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder3D();117 116 } else if (SolutionCreator is GroupingVectorRandomCreator) { 118 117 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DGVDecoder>()); 119 //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder3D();120 118 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 121 119 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DMCVDecoder>()); 122 //PackingSolutionDecoder = ApplicationManager.Manager.GetInstances<ExtremePointMultiComponentVectorDecoder3D>().First();123 120 } else { 124 121 string error = "The given problem does not support the selected solution-creator."; 125 PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);122 ErrorHandling.ShowErrorDialog(error, null); 126 123 } 127 124 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/ISOContainerBinPackingProblem.cs
r13032 r13460 29 29 30 30 namespace HeuristicLab.Problems.BinPacking.Problem { 31 [Item(" ISOContainerBinPackingProblem", "Represents a three-dimensional bin-packing problem using two different bin sizes.")]31 [Item("Bin Packing Problem (3D, ISO containers) (BPP)", "Represents a three-dimensional bin-packing problem using two different bin sizes.")] 32 32 [StorableClass] 33 [Creatable( "Problems")]33 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 320)] 34 34 public class ISOContainerBinPackingProblem : CuboidIdenticalBinPackingProblem { 35 35 … … 170 170 #region Helpers 171 171 protected override void InitializeDecoder() { 172 Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType()));172 Operators.RemoveAll(op => op is I2DOperator); 173 173 174 174 PackingSolutionDecoderParameter.ValidValues.Clear(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RectangularIdenticalBinPackingProblem.cs
r13032 r13460 36 36 37 37 namespace HeuristicLab.Problems.BinPacking.Problem { 38 [Item(" RectangularIdenticalBinPackingProblem", "Represents a two-dimensional bin-packing problem using only bins with identical measures and bins/items with rectangular shapes.")]38 [Item("Bin Packing Problem (2D, identical rectangles) (BPP)", "Represents a two-dimensional bin-packing problem using only bins with identical measures and bins/items with rectangular shapes.")] 39 39 [StorableClass] 40 [Creatable( "Problems")]40 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 300)] 41 41 public class RectangularIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 42 42 … … 104 104 #region Helpers 105 105 protected override void InitializeDecoder() { 106 Operators.RemoveAll(op => typeof(I3DOperator).IsAssignableFrom(op.GetType()));106 Operators.RemoveAll(op => op is I3DOperator); 107 107 108 108 PackingSolutionDecoderParameter.ValidValues.Clear(); 109 109 if (SolutionCreator is PackingSequenceRandomCreator) { 110 110 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DPSDecoder>()); 111 //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder2D();112 111 } else if (SolutionCreator is GroupingVectorRandomCreator) { 113 112 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DGVDecoder>()); 114 //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder2D();115 113 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 116 114 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DMCVDecoder>()); 117 //PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder2D();118 115 } else { 119 116 string error = "The given problem does not support the selected solution-creator."; 120 PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);117 ErrorHandling.ShowErrorDialog(error, null); 121 118 } 122 119 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RegularIdenticalBinPackingProblem.cs
r13032 r13460 246 246 247 247 BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null; 248 248 249 249 PackingBinMeasures = binData; 250 //PackingItemsParameter.Value.Value = data.Items;251 250 PackingItemMeasures = itemData; 252 251 … … 255 254 PackingItemsParameter.Value.Value = PackingItemMeasures.Count; 256 255 LowerBoundParameter.Value.Value = CalculateLowerBound(); 257 } 256 } 258 257 259 258 public BPPData Export() {
Note: See TracChangeset
for help on using the changeset viewer.