Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/21/16 10:19:55 (8 years ago)
Author:
gkronber
Message:

#1966: new implementation for 2d bin packing problem with permutation encoding

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs

    r14128 r14146  
    3131  [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")]
    3232  [StorableClass]
    33   public abstract class BinPacking<D,B,I> : Item
     33  public abstract class BinPacking<D, B, I> : Item
    3434    where D : class, IPackingPosition
    3535    where B : PackingShape<D>
    36     where I : PackingShape<D>, IPackingItem {
     36    where I : PackingShape<D> {
    3737    #region Properties
    3838    [Storable]
    39     public ObservableDictionary<int, D> ItemPositions { get; private set; } 
     39    public ObservableDictionary<int, D> ItemPositions { get; private set; }
    4040
    4141    [Storable]
     
    4343
    4444    [Storable]
    45     public B BinMeasures { get; private set; } 
     45    public B BinMeasures { get; private set; }
    4646
    4747    [Storable]
     
    5353    #endregion Properties
    5454
    55     protected BinPacking(B binMeasures) : base() {   
     55    protected BinPacking(B binMeasures)
     56      : base() {
    5657      ItemPositions = new ObservableDictionary<int, D>();
    5758      ItemMeasures = new ObservableDictionary<int, I>();
     
    6465    [StorableConstructor]
    6566    protected BinPacking(bool deserializing) : base(deserializing) { }
    66     protected BinPacking(BinPacking<D,B,I> original, Cloner cloner)
     67    protected BinPacking(BinPacking<D, B, I> original, Cloner cloner)
    6768      : base(original, cloner) {
    6869      this.ItemPositions = new ObservableDictionary<int, D>(original.ItemPositions);
    6970      this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures);
    70         this.BinMeasures = (B)original.BinMeasures.Clone(cloner);
    71         this.OccupationLayers = new Dictionary<int, List<int>>(original.OccupationLayers);
     71      this.BinMeasures = (B)original.BinMeasures.Clone(cloner);
     72      this.OccupationLayers = new Dictionary<int, List<int>>(original.OccupationLayers);
    7273    }
    73    
     74
    7475    protected abstract void GenerateNewExtremePointsForNewItem(I measures, D position);
    7576
     
    7778    public abstract D FindPositionBySliding(I measures, bool rotated);
    7879
    79     public abstract void SlidingBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures);
    80     public abstract void SlidingBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures, Dictionary<int, bool> rotationArray);
    81     public abstract void ExtremePointBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures, bool stackingConstraints);
    82     public abstract void ExtremePointBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures, bool stackingConstraints, Dictionary<int, bool> rotationArray);
     80    public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<I> itemMeasures);
     81    public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<I> itemMeasures, Dictionary<int, bool> rotationArray);
     82    public abstract void ExtremePointBasedPacking(ref IList<int> sequence, IList<I> itemMeasures, bool stackingConstraints);
     83    public abstract void ExtremePointBasedPacking(ref IList<int> sequence, IList<I> itemMeasures, bool stackingConstraints, Dictionary<int, bool> rotationArray);
    8384
    8485    public void PackItem(int itemID, I measures, D position) {
     
    8889      foreach (int id in ItemMeasures.Select(x => x.Key))
    8990        GenerateNewExtremePointsForNewItem(ItemMeasures[id], ItemPositions[id]);
    90      
    91        
    92       //GenerateNewExtremePointsForNewItem(measures, position);
    93       //OccupiedPoints.OccupyPoints(measures, position, itemID);
    9491
    9592      AddNewItemToOccupationLayers(itemID, measures, position);
    9693    }
    9794
    98     public double PackingDensity { 
     95    public double PackingDensity {
    9996      get {
    10097        double result = 0;
     
    108105
    109106    public int PointOccupation(D position) {
    110       //foreach (var ipEntry in ItemPositions) {
    111       //  if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))
    112       //    return ipEntry.Key;
    113       //}
    114107      foreach (var id in GetLayerItemIDs(position)) {
    115108        if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position))
     
    120113
    121114    public bool IsPointOccupied(D position) {
    122       //foreach (var ipEntry in ItemPositions) {
    123       //  if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))
    124       //    return true;
    125       //}     
    126115      foreach (var id in GetLayerItemIDs(position)) {
    127116        if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position))
     
    135124        return false;
    136125
    137       //foreach (var ipEntry in ItemPositions) {
    138       //  if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, position, measures))
    139       //    return false;
    140       //}
    141126      foreach (var id in GetLayerItemIDs(measures, position)) {
    142127        if (ItemMeasures[id].Overlaps(ItemPositions[id], position, measures))
     
    146131      return true;
    147132    }
    148     public abstract int ShortestPossibleSideFromPoint (D position);
    149     public abstract bool IsStaticStable (I measures, D position);
     133    public abstract int ShortestPossibleSideFromPoint(D position);
     134    public abstract bool IsStaticStable(I measures, D position);
    150135
    151136
     
    154139    protected abstract List<int> GetLayerItemIDs(D position);
    155140    protected abstract List<int> GetLayerItemIDs(I measures, D position);
    156   }   
     141  }
    157142}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs

    r14128 r14146  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2827using HeuristicLab.Data;
    2928using HeuristicLab.Collections;
    30 using HeuristicLab.Encodings.IntegerVectorEncoding;
    3129using HeuristicLab.Problems.BinPacking;
    32 using HeuristicLab.Encodings.PermutationEncoding;
    3330
    3431namespace HeuristicLab.Encodings.PackingEncoding {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r14128 r14146  
    158158  </ItemGroup>
    159159  <ItemGroup>
    160     <Compile Include="Analyzers\BestBinPackingSolutionAnalyzer.cs" />
    161     <Compile Include="Analyzers\BinPackingAnalyzer.cs" />
    162160    <Compile Include="Encodings\PackingPlans\BinPacking.cs" />
    163161    <Compile Include="Encodings\PackingPlans\PackingPlan.cs" />
     
    165163    <Compile Include="Encodings\PackingSolutionCrossover.cs" />
    166164    <Compile Include="Encodings\PackingSolutionManipulator.cs" />
    167     <Compile Include="Evaluators\BinUtilizationEvaluator.cs" />
    168     <Compile Include="Evaluators\DecodingEvaluator.cs" />
    169     <Compile Include="Evaluators\EvaluatorBase.cs" />
    170     <Compile Include="Evaluators\PackingRatioEvaluator.cs" />
    171165    <Compile Include="Interfaces\IDecodingEvaluator.cs" />
    172     <Compile Include="Interfaces\IEvaluator.cs" />
    173166    <Compile Include="Interfaces\IPackingPosition.cs" />
    174167    <Compile Include="Interfaces\IPackingSequenceMoveOperator.cs" />
     
    188181    <Compile Include="Interfaces\IPackingShape.cs" />
    189182    <Compile Include="PackingDimensions.cs" />
    190     <Compile Include="PackingMoveEvaluator.cs" />
    191183    <Compile Include="Interfaces\IPackingItem.cs" />
    192184    <Compile Include="Interfaces\IPackingPlan.cs" />
     
    194186    <Compile Include="PackingSolutionDecoder.cs" />
    195187    <Compile Include="Plugin.cs" />
    196     <Compile Include="PackingSequenceProblem.cs" />
    197188    <Compile Include="Properties\AssemblyInfo.cs" />
    198189  </ItemGroup>
     
    202193    <None Include="Plugin.cs.frame" />
    203194  </ItemGroup>
    204   <ItemGroup />
     195  <ItemGroup>
     196    <Folder Include="Evaluators\" />
     197  </ItemGroup>
    205198  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    206199  <PropertyGroup>
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IEvaluator.cs

    r14051 r14146  
    2424
    2525namespace HeuristicLab.Problems.BinPacking {
    26   public interface IEvaluator : ISingleObjectiveEvaluator {
    27      ILookupParameter<IPackingPlan> PackingPlanParameter { get; }
     26  public interface IEvaluator : IItem {
     27     double Evaluate(Solution )
    2828  }
    2929}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingMoveEvaluator.cs

    r14128 r14146  
    103103      return base.Apply();
    104104    }
     105
     106
    105107  }
    106108}
Note: See TracChangeset for help on using the changeset viewer.