Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/15 18:59:13 (9 years ago)
Author:
gkronber
Message:

#1966:

  • renamed creatables
  • partially fixed bin packing problem instance provider
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  
    154154    <Reference Include="System.Core" />
    155155    <Reference Include="System.Drawing" />
     156    <Reference Include="System.IO.Compression" />
     157    <Reference Include="System.IO.Compression.FileSystem" />
    156158    <Reference Include="System.Windows.Forms" />
    157159  </ItemGroup>
     
    272274    <Compile Include="Evaluators\Abstract\PackingPlanEvaluator.cs" />
    273275    <Compile Include="Instances\BPPData.cs" />
     276    <Compile Include="Instances\BPPInstanceProvider.cs" />
    274277    <Compile Include="Instances\BPPORLIBParser.cs" />
    275278    <Compile Include="Instances\BPPORLIBDataDescriptor.cs" />
     
    341344  <ItemGroup>
    342345    <None Include="HeuristicLab.snk" />
    343     <None Include="Instances\Data\BPPORLIB.rar" />
     346    <EmbeddedResource Include="Instances\Data\BPPORLIB.zip" />
    344347    <None Include="Properties\AssemblyInfo.cs.frame" />
    345348    <None Include="Plugin.cs.frame" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Instances/BPPInstanceProvider.cs

    r13032 r13460  
    2424using System.Collections.Generic;
    2525using System.IO;
     26using System.IO.Compression;
    2627using System.Linq;
    2728using System.Reflection;
    2829using System.Text.RegularExpressions;
     30using System.Windows.Forms;
    2931
    3032namespace HeuristicLab.Problems.Instances.BinPacking {
    31   public class BPPORLIBInstanceProvider : ProblemInstanceProvider<BPPData> {
     33  public class BPPORLIBInstanceProvider : ProblemInstanceProvider<BPPData>, IProblemInstanceProvider<BPPData> {
    3234
    3335    public override string Name {
     
    5153      if (String.IsNullOrEmpty(instanceArchiveName)) yield break;
    5254
    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);
    5665        }
    5766      }
     
    6069    public override BPPData LoadData(IDataDescriptor id) {
    6170      var descriptor = (BPPORLIBDataDescriptor)id;
    62       var instanceArchiveName = GetResourceName("JSSPORLIB.zip");
    63       using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
     71      var instanceArchiveName = GetResourceName("BPPORLIB.zip");
     72      using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
    6473        var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier);
    6574
    66         using (var stream = instancesZipFile.GetInputStream(entry)) {
     75        using (var stream = entry.Open()) {
    6776          var parser = new BPPORLIBParser();
    6877          parser.Parse(stream);
     
    8493      var instance = Load(parser);
    8594      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;
    8796      return instance;
    8897    }
     
    120129        .SingleOrDefault(x => Regex.Match(x, @".*\.Data\." + fileName).Success);
    121130    }
    122 
    123     protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) {
    124       ZipEntry entry;
    125       while ((entry = zipFile.GetNextEntry()) != null) {
    126         yield return entry.Name;
    127       }
    128     }
    129131  }
    130132}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Instances/BPPORLIBParser.cs

    r13032 r13460  
    6464    /// <returns>True if the file was successfully read or false otherwise.</returns>
    6565    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' };
    6868      var problemClass = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
    6969
     
    118118        Description = "<Missing>";
    119119      }
    120      
     120
    121121
    122122    }
     
    135135        else
    136136          writer.WriteLine("{0,-5} {1,-5} {2,-5}", ItemMeasures[i][0], ItemMeasures[i][1], ItemMeasures[i][2]);
     137
    137138      }
    138139      writer.Flush();
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/CuboidIdenticalBinPackingProblem.cs

    r13032 r13460  
    3636
    3737namespace 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.")]
    3939  [StorableClass]
    40   [Creatable("Problems")]
     40  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 310)]
    4141  public class CuboidIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
    4242
     
    109109    #region Helpers
    110110    protected override void InitializeDecoder() {
    111       Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType()));
     111      Operators.RemoveAll(op => op is I2DOperator);
    112112
    113113      PackingSolutionDecoderParameter.ValidValues.Clear();
    114114      if (SolutionCreator is PackingSequenceRandomCreator) {   
    115115        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DPSDecoder>());
    116         //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder3D();
    117116      } else if (SolutionCreator is GroupingVectorRandomCreator) {     
    118117        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DGVDecoder>());
    119         //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder3D();
    120118      } else if (SolutionCreator is MultiComponentVectorRandomCreator) {   
    121119        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DMCVDecoder>());
    122         //PackingSolutionDecoder = ApplicationManager.Manager.GetInstances<ExtremePointMultiComponentVectorDecoder3D>().First();
    123120      } else {
    124121        string error = "The given problem does not support the selected solution-creator.";
    125         PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
     122        ErrorHandling.ShowErrorDialog(error, null);
    126123      }
    127124    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/ISOContainerBinPackingProblem.cs

    r13032 r13460  
    2929
    3030namespace 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.")]
    3232  [StorableClass]
    33   [Creatable("Problems")]
     33  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 320)]
    3434  public class ISOContainerBinPackingProblem : CuboidIdenticalBinPackingProblem {
    3535
     
    170170    #region Helpers
    171171    protected override void InitializeDecoder() {
    172       Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType()));
     172      Operators.RemoveAll(op => op is I2DOperator);
    173173
    174174      PackingSolutionDecoderParameter.ValidValues.Clear();
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RectangularIdenticalBinPackingProblem.cs

    r13032 r13460  
    3636
    3737namespace 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.")]
    3939  [StorableClass]
    40   [Creatable("Problems")]
     40  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 300)]
    4141  public class RectangularIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
    4242
     
    104104    #region Helpers
    105105    protected override void InitializeDecoder() {
    106       Operators.RemoveAll(op => typeof(I3DOperator).IsAssignableFrom(op.GetType()));
     106      Operators.RemoveAll(op => op is I3DOperator);
    107107
    108108      PackingSolutionDecoderParameter.ValidValues.Clear();
    109109      if (SolutionCreator is PackingSequenceRandomCreator) {       
    110110        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DPSDecoder>());
    111         //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder2D();
    112111      } else if (SolutionCreator is GroupingVectorRandomCreator) { 
    113112        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DGVDecoder>());
    114         //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder2D();
    115113      } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 
    116114        PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DMCVDecoder>());
    117         //PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder2D();
    118115      } else {
    119116        string error = "The given problem does not support the selected solution-creator.";
    120         PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
     117        ErrorHandling.ShowErrorDialog(error, null);
    121118      }
    122119    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RegularIdenticalBinPackingProblem.cs

    r13032 r13460  
    246246
    247247      BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
    248                                                                    
     248
    249249      PackingBinMeasures = binData;   
    250       //PackingItemsParameter.Value.Value = data.Items;
    251250      PackingItemMeasures = itemData;
    252251
     
    255254      PackingItemsParameter.Value.Value = PackingItemMeasures.Count;
    256255      LowerBoundParameter.Value.Value = CalculateLowerBound();
    257     }           
     256    }
    258257
    259258    public BPPData Export() {
Note: See TracChangeset for help on using the changeset viewer.