Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj	(revision 14052)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj	(revision 14053)
@@ -165,4 +165,9 @@
     <Compile Include="Decoders\EP\ExtremePointMultiComponentVectorDecoder2D.cs" />
     <Compile Include="Decoders\EP\ExtremePointPackingSequenceDecoder2D.cs" />
+    <Compile Include="Instances\BPPData.cs" />
+    <Compile Include="Instances\BPPInstanceProvider.cs" />
+    <Compile Include="Instances\BPPORLIBDataDescriptor.cs" />
+    <Compile Include="Instances\BPPORLIBParser.cs" />
+    <Compile Include="Instances\RealBPPData.cs" />
     <Compile Include="Interfaces\I2DGVDecoder.cs" />
     <Compile Include="Interfaces\I2DMCVDecoder.cs" />
@@ -183,4 +188,5 @@
   <ItemGroup>
     <None Include="HeuristicLab.snk" />
+    <EmbeddedResource Include="Instances\Data\BPPORLIB.zip" />
     <None Include="Properties\AssemblyInfo.cs.frame" />
     <None Include="Plugin.cs.frame" />
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPData.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPData.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPData.cs	(revision 14053)
@@ -0,0 +1,59 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+
+namespace HeuristicLab.Problems.BinPacking2D {
+  /// <summary>
+  /// Describes instances of the regular two dimensional bin packing problem (2DBPP).
+
+  /// </summary>
+
+  // TODO implement specifically for 2d and 3d instances
+  public class BPPData {
+    /// <summary>
+    /// The name of the instance
+    /// </summary>
+    public string Name { get; set; }
+    /// <summary>
+    /// Optional! The description of the instance
+    /// </summary>
+    public string Description { get; set; }
+
+    /// <summary>
+    /// The number of items.
+    /// </summary>
+    public int Items { get; set; }
+    /// <summary>
+    /// The measures of the bin.
+    /// </summary>
+    public int[] BinMeasures { get; set; }
+    /// <summary>
+    /// The measures of the items.
+    /// </summary>
+    public int[][] ItemMeasures { get; set; }
+
+    /// <summary>
+    /// Optional! The quality of the best-known solution.
+    /// </summary>
+    public double? BestKnownQuality { get; set; }
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPInstanceProvider.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPInstanceProvider.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPInstanceProvider.cs	(revision 14053)
@@ -0,0 +1,132 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Problems.BinPacking2D {
+  public class BPPORLIBInstanceProvider : ProblemInstanceProvider<BPPData>, IProblemInstanceProvider<BPPData> {
+
+    public override string Name {
+      get { return "ORLIB BPP"; }
+    }
+
+    public override string Description {
+      get { return "Bin packing problems from the Operations Research Library."; }
+    }
+
+    public override Uri WebLink {
+      get { return new Uri("http://people.brunel.ac.uk/~mastjjb/jeb/orlib/binpacktwoinfo.html , http://www.diku.dk/~pisinger/new3dbpp/readme.3dbpp"); }
+    }
+
+    public override string ReferencePublication {
+      get { return String.Empty; }
+    }
+
+    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
+      var instanceArchiveName = GetResourceName("BPPORLIB.zip");
+      if (String.IsNullOrEmpty(instanceArchiveName)) yield break;
+
+
+      using (var file = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
+
+        foreach (var entry in file.Entries.OrderBy(x => x.Name)) {
+          if (string.IsNullOrWhiteSpace(entry.Name)) continue;
+          yield return new BPPORLIBDataDescriptor(
+            name: Path.GetFileNameWithoutExtension(entry.Name), 
+            description: GetDescription(), 
+            instanceIdentifier: entry.FullName, 
+            solutionIdentifier: null);
+        }
+      }
+    }
+
+    public override BPPData LoadData(IDataDescriptor id) {
+      var descriptor = (BPPORLIBDataDescriptor)id;
+      var instanceArchiveName = GetResourceName("BPPORLIB.zip");
+      using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
+        var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier);
+
+        using (var stream = entry.Open()) {
+          var parser = new BPPORLIBParser();
+          parser.Parse(stream);
+          var instance = Load(parser);
+          instance.Name = id.Name;
+          instance.Description = id.Description;
+
+          return instance;
+        }
+      }
+    }
+
+    public override bool CanImportData {
+      get { return true; }
+    }
+    public override BPPData ImportData(string path) {
+      var parser = new BPPORLIBParser();
+      parser.Parse(path);
+      var instance = Load(parser);
+      instance.Name = Path.GetFileName(path);
+      instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now;
+      return instance;
+    }
+
+    private BPPData Load(BPPORLIBParser parser) {
+      var instance = new BPPData {
+        Items = parser.Items,
+        BinMeasures = parser.BinMeasures,
+        ItemMeasures = parser.ItemMeasures
+      };
+      return instance;
+    }
+
+    public override bool CanExportData {
+      get { return true; }
+    }
+
+    public override void ExportData(BPPData instance, string path) {
+      var parser = new BPPORLIBParser {
+        Name = instance.Name,
+        Description = instance.Description,
+        Items = instance.Items,
+        BinMeasures = instance.BinMeasures,
+        ItemMeasures = instance.ItemMeasures
+      };
+      parser.Export(path);
+    }
+
+    private string GetDescription() {
+      return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + ".";
+    }
+
+    protected virtual string GetResourceName(string fileName) {
+      return Assembly.GetExecutingAssembly().GetManifestResourceNames()
+        .SingleOrDefault(x => Regex.Match(x, @".*\.Data\." + fileName).Success);
+    }
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPORLIBDataDescriptor.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPORLIBDataDescriptor.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPORLIBDataDescriptor.cs	(revision 14053)
@@ -0,0 +1,40 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Problems.BinPacking2D {
+  internal class BPPORLIBDataDescriptor : IDataDescriptor {
+    public string Name { get; internal set; }
+    public string Description { get; internal set; }
+
+    internal string InstanceIdentifier { get; set; }
+    internal string SolutionIdentifier { get; set; }
+
+    internal BPPORLIBDataDescriptor(string name, string description, string instanceIdentifier, string solutionIdentifier) {
+      this.Name = name;
+      this.Description = description;
+      this.InstanceIdentifier = instanceIdentifier;
+      this.SolutionIdentifier = solutionIdentifier;
+    }
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPORLIBParser.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPORLIBParser.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/BPPORLIBParser.cs	(revision 14053)
@@ -0,0 +1,143 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+using System;
+using System.IO;
+
+namespace HeuristicLab.Problems.BinPacking2D {
+  public class BPPORLIBParser {
+    public string Name { get; set; }
+    public string Description { get; set; }
+    public int Items { get; set; }
+    public int[] BinMeasures { get; set; }
+    public int[][] ItemMeasures { get; set; }
+
+    public BPPORLIBParser() {
+      Reset();
+    }
+
+    public void Reset() {
+      Name = Description = String.Empty;
+      Items = 0;
+      BinMeasures = null;
+      ItemMeasures = null;
+    }
+
+    public void Parse(string file) {
+      using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
+        Parse(stream);
+      }
+    }
+
+    public void Export(string file) {
+      using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
+        Export(stream);
+      }
+    }
+
+    /// <summary>
+    /// Reads from the given stream data which is expected to be in the BPP ORLIB format.
+    /// </summary>
+    /// <remarks>
+    /// The stream is not closed or disposed. The caller has to take care of that.
+    /// </remarks>
+    /// <param name="stream">The stream to read data from.</param>
+    /// <returns>True if the file was successfully read or false otherwise.</returns>
+    public void Parse(Stream stream) {
+      var reader = new StreamReader(stream);
+      var delim = new char[] { ' ', '\t' };
+      var problemClass = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
+
+      var nrOfItems = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
+      Items = int.Parse(nrOfItems[0]);
+      //Numbering of instances..
+      reader.ReadLine();
+      var binMeasures = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
+      int depth;
+      bool isThreeDimensional = false;
+      if (int.TryParse(binMeasures[2], out depth)) {
+        isThreeDimensional = true;
+        BinMeasures = new int[3];
+        BinMeasures[0] = int.Parse(binMeasures[0]);
+        BinMeasures[1] = int.Parse(binMeasures[1]);
+        BinMeasures[2] = depth;
+      } else {
+        BinMeasures = new int[2];
+        BinMeasures[0] = int.Parse(binMeasures[0]);
+        BinMeasures[1] = int.Parse(binMeasures[1]);
+      }
+      ItemMeasures = new int[Items][];
+
+      for (int k = 0; k < Items; k++) {
+        if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream (at line " + k + ").");
+        var valLine = reader.ReadLine();
+        while (String.IsNullOrWhiteSpace(valLine)) valLine = reader.ReadLine();
+        var vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
+        ItemMeasures[k] = new int[isThreeDimensional ? 3 : 2];
+        ItemMeasures[k][0] = int.Parse(vals[0]);
+        ItemMeasures[k][1] = int.Parse(vals[1]);
+        if (isThreeDimensional)
+          ItemMeasures[k][2] = int.Parse(vals[2]);
+      }
+
+      Int32 problemClassNr = -1;
+      if (int.TryParse(problemClass[0], out problemClassNr)) {
+        Name = (isThreeDimensional ? "3" : "2") + "dbpp_class_0" + problemClassNr;
+        if (!isThreeDimensional) {
+          if (problemClassNr >= 1 && problemClassNr <= 5)
+            Description = "Proposed by Berkey and Wang.";
+          else if (problemClassNr >= 6 && problemClassNr <= 10)
+            Description = "Proposed by Martello and Vigo.";
+        } else {
+          if (problemClassNr >= 1 && problemClassNr <= 5)
+            Description = "Proposed by Martello and Vigo.";
+          else if (problemClassNr >= 6 && problemClassNr <= 9)
+            Description = "Proposed by Berkey and Wang.";
+        }
+      } else {
+        Name = "Unknown";
+        Description = "<Missing>";
+      }
+
+
+    }
+
+    public void Export(Stream stream) {
+      bool isThreeDimensional = BinMeasures.Length == 3;
+      var nameParts = Name.Split('_');
+      int problemClassNr = int.Parse(nameParts[2]);
+
+      var writer = new StreamWriter(stream);
+      writer.WriteLine(String.Format("{0,-5}               PROBLEM CLASS ({1})", problemClassNr, Description));
+      writer.WriteLine(String.Format("{0,-5} {1,-5} {2,-5}   WBIN,HBIN,DBIN", BinMeasures[0], BinMeasures[1], BinMeasures[2]));
+      for (int i = 0; i < Items; i++) {
+        if (i == 0)
+          writer.WriteLine("{0,-5} {1,-5} {2,-5}   W(I),H(I),D(I),I=1,...,N", ItemMeasures[i][0], ItemMeasures[i][1], ItemMeasures[i][2]);
+        else
+          writer.WriteLine("{0,-5} {1,-5} {2,-5}", ItemMeasures[i][0], ItemMeasures[i][1], ItemMeasures[i][2]);
+
+      }
+      writer.Flush();
+    }
+
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/RealBPPData.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/RealBPPData.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Instances/RealBPPData.cs	(revision 14053)
@@ -0,0 +1,39 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+
+namespace HeuristicLab.Problems.BinPacking2D {
+  /// <summary>
+  /// Describes instances of the regular two dimensional bin packing problem (2DBPP).
+  /// </summary>
+  public class RealBPPData : BPPData {
+    /// <summary>
+    /// The weight of the items.
+    /// </summary>
+    public double[] ItemWeights { get; set; }
+    /// <summary>
+    /// The category of packing material for each item.
+    /// </summary>
+    public int[] ItemMaterials { get; set; }
+
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/HeuristicLab.Problems.BinPacking3D-3.3.csproj
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/HeuristicLab.Problems.BinPacking3D-3.3.csproj	(revision 14052)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/HeuristicLab.Problems.BinPacking3D-3.3.csproj	(revision 14053)
@@ -169,4 +169,9 @@
     <Compile Include="Decoders\EP\ExtremePointPackingSequenceDecoder3D.cs" />
     <Compile Include="I3DOperator.cs" />
+    <Compile Include="Instances\BPPData.cs" />
+    <Compile Include="Instances\BPPInstanceProvider.cs" />
+    <Compile Include="Instances\BPPORLIBDataDescriptor.cs" />
+    <Compile Include="Instances\BPPORLIBParser.cs" />
+    <Compile Include="Instances\RealBPPData.cs" />
     <Compile Include="MoveEvaluators\PackingMoveEvaluator3DGV.cs" />
     <Compile Include="MoveEvaluators\PackingMoveEvaluator3DMCV.cs" />
@@ -183,4 +188,5 @@
   <ItemGroup>
     <None Include="HeuristicLab.snk" />
+    <EmbeddedResource Include="Instances\Data\BPPORLIB.zip" />
     <None Include="Properties\AssemblyInfo.cs.frame" />
     <None Include="Plugin.cs.frame" />
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPData.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPData.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPData.cs	(revision 14053)
@@ -0,0 +1,56 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+
+namespace HeuristicLab.Problems.BinPacking3D {
+  /// <summary>
+  /// Describes instances of the regular three dimensional bin packing problem (3DBPP).
+  /// </summary>
+  public class BPPData {
+    /// <summary>
+    /// The name of the instance
+    /// </summary>
+    public string Name { get; set; }
+    /// <summary>
+    /// Optional! The description of the instance
+    /// </summary>
+    public string Description { get; set; }
+
+    /// <summary>
+    /// The number of items.
+    /// </summary>
+    public int Items { get; set; }
+    /// <summary>
+    /// The measures of the bin.
+    /// </summary>
+    public int[] BinMeasures { get; set; }
+    /// <summary>
+    /// The measures of the items.
+    /// </summary>
+    public int[][] ItemMeasures { get; set; }
+
+    /// <summary>
+    /// Optional! The quality of the best-known solution.
+    /// </summary>
+    public double? BestKnownQuality { get; set; }
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPInstanceProvider.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPInstanceProvider.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPInstanceProvider.cs	(revision 14053)
@@ -0,0 +1,132 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Problems.BinPacking3D { 
+  public class BPPORLIBInstanceProvider : ProblemInstanceProvider<BPPData>, IProblemInstanceProvider<BPPData> {
+
+    public override string Name {
+      get { return "ORLIB BPP"; }
+    }
+
+    public override string Description {
+      get { return "Bin packing problems from the Operations Research Library."; }
+    }
+
+    public override Uri WebLink {
+      get { return new Uri("http://people.brunel.ac.uk/~mastjjb/jeb/orlib/binpacktwoinfo.html , http://www.diku.dk/~pisinger/new3dbpp/readme.3dbpp"); }
+    }
+
+    public override string ReferencePublication {
+      get { return String.Empty; }
+    }
+
+    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
+      var instanceArchiveName = GetResourceName("BPPORLIB.zip");
+      if (String.IsNullOrEmpty(instanceArchiveName)) yield break;
+
+
+      using (var file = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
+
+        foreach (var entry in file.Entries.OrderBy(x => x.Name)) {
+          if (string.IsNullOrWhiteSpace(entry.Name)) continue;
+          yield return new BPPORLIBDataDescriptor(
+            name: Path.GetFileNameWithoutExtension(entry.Name), 
+            description: GetDescription(), 
+            instanceIdentifier: entry.FullName, 
+            solutionIdentifier: null);
+        }
+      }
+    }
+
+    public override BPPData LoadData(IDataDescriptor id) {
+      var descriptor = (BPPORLIBDataDescriptor)id;
+      var instanceArchiveName = GetResourceName("BPPORLIB.zip");
+      using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
+        var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier);
+
+        using (var stream = entry.Open()) {
+          var parser = new BPPORLIBParser();
+          parser.Parse(stream);
+          var instance = Load(parser);
+          instance.Name = id.Name;
+          instance.Description = id.Description;
+
+          return instance;
+        }
+      }
+    }
+
+    public override bool CanImportData {
+      get { return true; }
+    }
+    public override BPPData ImportData(string path) {
+      var parser = new BPPORLIBParser();
+      parser.Parse(path);
+      var instance = Load(parser);
+      instance.Name = Path.GetFileName(path);
+      instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now;
+      return instance;
+    }
+
+    private BPPData Load(BPPORLIBParser parser) {
+      var instance = new BPPData {
+        Items = parser.Items,
+        BinMeasures = parser.BinMeasures,
+        ItemMeasures = parser.ItemMeasures
+      };
+      return instance;
+    }
+
+    public override bool CanExportData {
+      get { return true; }
+    }
+
+    public override void ExportData(BPPData instance, string path) {
+      var parser = new BPPORLIBParser {
+        Name = instance.Name,
+        Description = instance.Description,
+        Items = instance.Items,
+        BinMeasures = instance.BinMeasures,
+        ItemMeasures = instance.ItemMeasures
+      };
+      parser.Export(path);
+    }
+
+    private string GetDescription() {
+      return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + ".";
+    }
+
+    protected virtual string GetResourceName(string fileName) {
+      return Assembly.GetExecutingAssembly().GetManifestResourceNames()
+        .SingleOrDefault(x => Regex.Match(x, @".*\.Data\." + fileName).Success);
+    }
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPORLIBDataDescriptor.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPORLIBDataDescriptor.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPORLIBDataDescriptor.cs	(revision 14053)
@@ -0,0 +1,40 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Problems.BinPacking3D {
+  internal class BPPORLIBDataDescriptor : IDataDescriptor {
+    public string Name { get; internal set; }
+    public string Description { get; internal set; }
+
+    internal string InstanceIdentifier { get; set; }
+    internal string SolutionIdentifier { get; set; }
+
+    internal BPPORLIBDataDescriptor(string name, string description, string instanceIdentifier, string solutionIdentifier) {
+      this.Name = name;
+      this.Description = description;
+      this.InstanceIdentifier = instanceIdentifier;
+      this.SolutionIdentifier = solutionIdentifier;
+    }
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPORLIBParser.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPORLIBParser.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/BPPORLIBParser.cs	(revision 14053)
@@ -0,0 +1,143 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+using System;
+using System.IO;
+
+namespace HeuristicLab.Problems.BinPacking3D {
+  public class BPPORLIBParser {
+    public string Name { get; set; }
+    public string Description { get; set; }
+    public int Items { get; set; }
+    public int[] BinMeasures { get; set; }
+    public int[][] ItemMeasures { get; set; }
+
+    public BPPORLIBParser() {
+      Reset();
+    }
+
+    public void Reset() {
+      Name = Description = String.Empty;
+      Items = 0;
+      BinMeasures = null;
+      ItemMeasures = null;
+    }
+
+    public void Parse(string file) {
+      using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
+        Parse(stream);
+      }
+    }
+
+    public void Export(string file) {
+      using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
+        Export(stream);
+      }
+    }
+
+    /// <summary>
+    /// Reads from the given stream data which is expected to be in the BPP ORLIB format.
+    /// </summary>
+    /// <remarks>
+    /// The stream is not closed or disposed. The caller has to take care of that.
+    /// </remarks>
+    /// <param name="stream">The stream to read data from.</param>
+    /// <returns>True if the file was successfully read or false otherwise.</returns>
+    public void Parse(Stream stream) {
+      var reader = new StreamReader(stream);
+      var delim = new char[] { ' ', '\t' };
+      var problemClass = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
+
+      var nrOfItems = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
+      Items = int.Parse(nrOfItems[0]);
+      //Numbering of instances..
+      reader.ReadLine();
+      var binMeasures = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
+      int depth;
+      bool isThreeDimensional = false;
+      if (int.TryParse(binMeasures[2], out depth)) {
+        isThreeDimensional = true;
+        BinMeasures = new int[3];
+        BinMeasures[0] = int.Parse(binMeasures[0]);
+        BinMeasures[1] = int.Parse(binMeasures[1]);
+        BinMeasures[2] = depth;
+      } else {
+        BinMeasures = new int[2];
+        BinMeasures[0] = int.Parse(binMeasures[0]);
+        BinMeasures[1] = int.Parse(binMeasures[1]);
+      }
+      ItemMeasures = new int[Items][];
+
+      for (int k = 0; k < Items; k++) {
+        if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream (at line " + k + ").");
+        var valLine = reader.ReadLine();
+        while (String.IsNullOrWhiteSpace(valLine)) valLine = reader.ReadLine();
+        var vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
+        ItemMeasures[k] = new int[isThreeDimensional ? 3 : 2];
+        ItemMeasures[k][0] = int.Parse(vals[0]);
+        ItemMeasures[k][1] = int.Parse(vals[1]);
+        if (isThreeDimensional)
+          ItemMeasures[k][2] = int.Parse(vals[2]);
+      }
+
+      Int32 problemClassNr = -1;
+      if (int.TryParse(problemClass[0], out problemClassNr)) {
+        Name = (isThreeDimensional ? "3" : "2") + "dbpp_class_0" + problemClassNr;
+        if (!isThreeDimensional) {
+          if (problemClassNr >= 1 && problemClassNr <= 5)
+            Description = "Proposed by Berkey and Wang.";
+          else if (problemClassNr >= 6 && problemClassNr <= 10)
+            Description = "Proposed by Martello and Vigo.";
+        } else {
+          if (problemClassNr >= 1 && problemClassNr <= 5)
+            Description = "Proposed by Martello and Vigo.";
+          else if (problemClassNr >= 6 && problemClassNr <= 9)
+            Description = "Proposed by Berkey and Wang.";
+        }
+      } else {
+        Name = "Unknown";
+        Description = "<Missing>";
+      }
+
+
+    }
+
+    public void Export(Stream stream) {
+      bool isThreeDimensional = BinMeasures.Length == 3;
+      var nameParts = Name.Split('_');
+      int problemClassNr = int.Parse(nameParts[2]);
+
+      var writer = new StreamWriter(stream);
+      writer.WriteLine(String.Format("{0,-5}               PROBLEM CLASS ({1})", problemClassNr, Description));
+      writer.WriteLine(String.Format("{0,-5} {1,-5} {2,-5}   WBIN,HBIN,DBIN", BinMeasures[0], BinMeasures[1], BinMeasures[2]));
+      for (int i = 0; i < Items; i++) {
+        if (i == 0)
+          writer.WriteLine("{0,-5} {1,-5} {2,-5}   W(I),H(I),D(I),I=1,...,N", ItemMeasures[i][0], ItemMeasures[i][1], ItemMeasures[i][2]);
+        else
+          writer.WriteLine("{0,-5} {1,-5} {2,-5}", ItemMeasures[i][0], ItemMeasures[i][1], ItemMeasures[i][2]);
+
+      }
+      writer.Flush();
+    }
+
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/RealBPPData.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/RealBPPData.cs	(revision 14053)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Instances/RealBPPData.cs	(revision 14053)
@@ -0,0 +1,39 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+
+namespace HeuristicLab.Problems.BinPacking3D {
+  /// <summary>
+  /// Describes instances of the regular three dimensional bin packing problem (3DBPP).
+  /// </summary>
+  public class RealBPPData : BPPData {
+    /// <summary>
+    /// The weight of the items.
+    /// </summary>
+    public double[] ItemWeights { get; set; }
+    /// <summary>
+    /// The category of packing material for each item.
+    /// </summary>
+    public int[] ItemMaterials { get; set; }
+
+  }
+}
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj	(revision 14052)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj	(revision 14053)
@@ -255,9 +255,4 @@
     <Compile Include="Evaluators\PackingPlanEvaluationAlgorithm.cs" />
     <Compile Include="Evaluators\PackingRatioEvaluator.cs" />
-    <Compile Include="Instances\BPPData.cs" />
-    <Compile Include="Instances\BPPInstanceProvider.cs" />
-    <Compile Include="Instances\BPPORLIBParser.cs" />
-    <Compile Include="Instances\BPPORLIBDataDescriptor.cs" />
-    <Compile Include="Instances\RealBPPData.cs" />
     <Compile Include="Interfaces\IEvaluator.cs" />
     <Compile Include="Interfaces\IPackingPosition.cs" />
@@ -290,5 +285,4 @@
   <ItemGroup>
     <None Include="HeuristicLab.snk" />
-    <EmbeddedResource Include="Instances\Data\BPPORLIB.zip" />
     <None Include="Properties\AssemblyInfo.cs.frame" />
     <None Include="Plugin.cs.frame" />
