Changeset 14151


Ignore:
Timestamp:
07/21/16 13:03:42 (11 months ago)
Author:
gkronber
Message:

#1966: added abstract problem and move evaluator classes and implemented 2d bin packing problem based on integer vector encoding

Location:
branches/HeuristicLab.BinPacking
Files:
5 added
15 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/BinPacking2D.cs

    r14149 r14151  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Common;
    28 using HeuristicLab.Encodings.PackingEncoding;
    2928
    3029namespace HeuristicLab.Problems.BinPacking2D {
    3130  [Item("BinPacking2D", "Represents a single-bin packing for a 2D bin-packing problem.")]
    3231  [StorableClass]
    33   public class BinPacking2D : BinPacking<PackingPosition, PackingShape, PackingItem> {
     32  public class BinPacking2D : BinPacking.BinPacking<PackingPosition, PackingShape, PackingItem> {
    3433
    3534    public BinPacking2D(PackingShape binMeasures)
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Evaluators/PackingRatioEvaluator.cs

    r14148 r14151  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Common;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.Encodings.PackingEncoding;
    29 using HeuristicLab.Problems.BinPacking;
    30 using System.Collections.Generic;
    3127
    3228namespace HeuristicLab.Problems.BinPacking2D {
     
    6460      const double k = 2;
    6561      for (int i = 0; i < nrOfBins; i++) {
    66         var f = solution.BinPackings[i].ItemMeasures.Sum(kvp => kvp.Value.Volume);
    67         var c = solution.BinPackings[i].BinMeasures.Volume;
     62        double f = solution.BinPackings[i].ItemMeasures.Sum(kvp => kvp.Value.Volume);
     63        double c = solution.BinPackings[i].BinMeasures.Volume;
    6864        result += Math.Pow(f / c, k);
    6965      }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj

    r14149 r14151  
    168168    <Compile Include="Instances\RandomDataDescriptor.cs" />
    169169    <Compile Include="Instances\RandomInstanceProvider.cs" />
     170    <Compile Include="IntegerVectorEncoding\BottomLeftIntegerVectorDecoder.cs" />
     171    <Compile Include="IntegerVectorEncoding\IntegerVectorDecoderBase.cs" />
     172    <Compile Include="IntegerVectorEncoding\ExtremePointIntegerVectorDecoder.cs" />
     173    <Compile Include="IntegerVectorEncoding\IntegerVectorProblem.cs" />
    170174    <Compile Include="Interfaces\IDecoder.cs" />
    171175    <Compile Include="Interfaces\IEvaluator.cs" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PermutationEncoding/PermutationProblem.cs

    r14149 r14151  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    2827using HeuristicLab.Encodings.PermutationEncoding;
    2928using HeuristicLab.Optimization;
    30 using HeuristicLab.Parameters;
    3129using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    32 using HeuristicLab.Problems.Instances;
    3330
    3431namespace HeuristicLab.Problems.BinPacking2D {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Solution.cs

    r14049 r14151  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.PackingEncoding;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Problems.BinPacking;
    2626
    2727namespace HeuristicLab.Problems.BinPacking2D {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/BinPacking3D.cs

    r14146 r14151  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Common;
    27 using HeuristicLab.Encodings.PackingEncoding;
     27using HeuristicLab.Problems.BinPacking;
    2828
    2929namespace HeuristicLab.Problems.BinPacking3D {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Solution.cs

    r14049 r14151  
    11using HeuristicLab.Common;
    22using HeuristicLab.Core;
    3 using HeuristicLab.Encodings.PackingEncoding;
    43using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     4using HeuristicLab.Problems.BinPacking;
    55
    66namespace HeuristicLab.Problems.BinPacking3D {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container2DView.xaml.cs

    r14049 r14151  
    2323using System.Windows;
    2424using System.Windows.Media;
    25 using HeuristicLab.Encodings.PackingEncoding;
    2625using HeuristicLab.Problems.BinPacking2D;
    2726using Point = System.Windows.Point;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml.cs

    r14049 r14151  
    2424using System.Windows.Input;
    2525using System.Windows.Media.Media3D;
    26 using HeuristicLab.Encodings.PackingEncoding;
    2726using HeuristicLab.Problems.BinPacking3D;
    2827
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlan2DView.cs

    r14049 r14151  
    2424using HeuristicLab.MainForm;
    2525using HeuristicLab.Problems.BinPacking2D;
    26 using HeuristicLab.Encodings.PackingEncoding;
    2726
    2827namespace HeuristicLab.Problems.BinPacking.Views {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlan3DView.cs

    r14049 r14151  
    2222using System;
    2323using HeuristicLab.Core.Views;
    24 using HeuristicLab.Encodings.PackingEncoding;
    2524using HeuristicLab.MainForm;
    2625using HeuristicLab.Problems.BinPacking3D;
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs

    r14146 r14151  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Collections;
    28 using HeuristicLab.Problems.BinPacking;
    2928
    30 namespace HeuristicLab.Encodings.PackingEncoding {
     29namespace HeuristicLab.Problems.BinPacking {
    3130  [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")]
    3231  [StorableClass]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs

    r14146 r14151  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Collections;
    29 using HeuristicLab.Problems.BinPacking;
    3029
    31 namespace HeuristicLab.Encodings.PackingEncoding {
     30namespace HeuristicLab.Problems.BinPacking {
    3231  [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")]
    3332  [StorableClass]
     
    145144    }
    146145    public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) {
    147       var sequenceMatrix = solution.GenerateSequenceMatrix();
    148 
    149       //Fill bins according to grouping vector
    150       List<int> remainingIDs = new List<int>();
    151       foreach (var sequence in sequenceMatrix) {
    152         remainingIDs = remainingIDs.Concat(sequence).ToList();
    153         var bp = NewBinPacking();
    154         if (!UseExtremePoints)
    155           bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
    156         else
    157           bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
    158         BinPackings.Add(bp);
    159       }
    160       UpdateBinPackings();
    161 
    162       //Try to put remaining items in existing bins
    163       var temp = new List<int>(remainingIDs);
    164       foreach (int id in temp) {
    165         foreach (var bp in BinPackings) {
    166           var position = UseExtremePoints ? bp.FindExtremePointForItem(itemMeasures[id], false, StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], false);
    167           if (position != null) {
    168             bp.PackItem(id, itemMeasures[id], position);
    169             remainingIDs.Remove(id);
    170             break;
    171           }
    172         }
    173       }
    174 
    175       //Put still remaining items in new bins
    176       while (remainingIDs.Count > 0) {
    177         var bp = NewBinPacking();
    178         if (!UseExtremePoints)
    179           bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
    180         else
    181           bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
    182         BinPackings.Add(bp);
    183       }
    184       UpdateBinPackings();
    185 
    186       var newSolution = new int[solution.GroupingVector.Length];
    187       int binIndex = 0;
    188       foreach (var bp in BinPackings) {
    189         foreach (var entry in bp.ItemPositions)
    190           newSolution[entry.Key] = binIndex;
    191         binIndex++;
    192       }
    193       solution.GroupingVector = new IntegerVector(newSolution);
    194146    }
    195147     *
    196148     
    197     public void Pack(Permutation solution, ItemList<I> itemMeasures) {
    198       List<int> remainingIDs = new List<int>(solution);
    199       while (remainingIDs.Count > 0) {
    200         var bp = NewBinPacking();
    201         if (!UseExtremePoints)
    202           bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
    203         else
    204           bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
    205         BinPackings.Add(bp);
    206       }
    207       UpdateBinPackings();
    208     }
    209149
    210150    */
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r14146 r14151  
    160160    <Compile Include="Encodings\PackingPlans\BinPacking.cs" />
    161161    <Compile Include="Encodings\PackingPlans\PackingPlan.cs" />
    162     <Compile Include="Encodings\PackingSolutionCreator.cs" />
    163     <Compile Include="Encodings\PackingSolutionCrossover.cs" />
    164     <Compile Include="Encodings\PackingSolutionManipulator.cs" />
    165162    <Compile Include="Interfaces\IDecodingEvaluator.cs" />
    166163    <Compile Include="Interfaces\IPackingPosition.cs" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingSolutionDecoder.cs

    r14048 r14151  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Data;
    29 using HeuristicLab.Encodings.PackingEncoding;
    3029
    3130namespace HeuristicLab.Problems.BinPacking {
     
    5049      get { return (ILookupParameter<IItem>)Parameters["EncodedSolution"]; }
    5150    }
    52     public ILookupParameter<PackingPlan<D,B,I>> PackingPlanParameter {
     51    public ILookupParameter<PackingPlan<D, B, I>> PackingPlanParameter {
    5352      get { return (ILookupParameter<PackingPlan<D, B, I>>)Parameters["PackingPlan"]; }
    5453    }
     
    5857
    5958
    60     public PackingSolutionDecoder() : base() {
     59    public PackingSolutionDecoder()
     60      : base() {
    6161      Parameters.Add(new LookupParameter<IItem>("EncodedSolution", "The new bin-packing solution represented as encoding."));
    6262      Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan."));
     
    6969    [StorableConstructor]
    7070    protected PackingSolutionDecoder(bool deserializing) : base(deserializing) { }
    71     protected PackingSolutionDecoder(PackingSolutionDecoder<D,B,I> original, Cloner cloner)
     71    protected PackingSolutionDecoder(PackingSolutionDecoder<D, B, I> original, Cloner cloner)
    7272      : base(original, cloner) {
    7373    }
Note: See TracChangeset for help on using the changeset viewer.