Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/13/17 15:25:11 (7 years ago)
Author:
abeham
Message:

#2762: integrated bin packing extension into trunk

Location:
trunk/sources/HeuristicLab.Problems.BinPacking
Files:
11 edited
8 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.BinPacking

  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/BinPacking2D.cs

    r14916 r15230  
    8888      };
    8989
    90       int epIndex = 0;
    91       while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(rotatedItem, ExtremePoints.ElementAt(epIndex)))) { epIndex++; }
    92 
    93       if (epIndex < ExtremePoints.Count) {
    94         var currentPoint = ExtremePoints.ElementAt(epIndex);
    95 
    96         var result = new PackingPosition(currentPoint.AssignedBin, currentPoint.X, currentPoint.Y, rotated);
     90      var ep = ExtremePoints.Where(x => IsPositionFeasible(rotatedItem, x, stackingConstraints)).FirstOrDefault();
     91      if (ep != null) {
     92        var result = new PackingPosition(ep.AssignedBin, ep.X, ep.Y, rotated);
    9793        return result;
    9894      }
    9995      return null;
    10096    }
    101     public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated) {
     97    public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated, bool stackingConstraints) {
    10298      PackingPosition currentPosition = new PackingPosition(0,
    10399        BinShape.Width - (rotated ? item.Height : item.Width),
    104100        BinShape.Height - (rotated ? item.Width : item.Height), rotated);
    105101      //Slide the item as far as possible to the left
    106       while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition))
    107         || IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition))) {
     102      while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints)
     103        || IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition), stackingConstraints)) {
    108104        //Slide the item as far as possible to the bottom
    109         while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition))) {
     105        while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition), stackingConstraints)) {
    110106          currentPosition = PackingPosition.MoveDown(currentPosition);
    111107        }
    112         if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition)))
     108        if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints))
    113109          currentPosition = PackingPosition.MoveLeft(currentPosition);
    114110      }
    115111
    116       return IsPositionFeasible(item, currentPosition) ? currentPosition : null;
    117     }
    118 
    119     public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items) {
     112      return IsPositionFeasible(item, currentPosition, stackingConstraints) ? currentPosition : null;
     113    }
     114
     115    public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, bool stackingConstraints) {
    120116      var temp = new List<int>(sequence);
    121117      for (int i = 0; i < temp.Count; i++) {
    122118        var item = items[temp[i]];
    123         var position = FindPositionBySliding(item, false);
     119        var position = FindPositionBySliding(item, false, stackingConstraints);
    124120        if (position != null) {
    125121          PackItem(temp[i], item, position);
     
    128124      }
    129125    }
    130     public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, Dictionary<int, bool> rotationArray) {
     126    public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, Dictionary<int, bool> rotationArray, bool stackingConstraints) {
    131127      var temp = new List<int>(sequence);
    132128      for (int i = 0; i < temp.Count; i++) {
    133129        var item = items[temp[i]];
    134         var position = FindPositionBySliding(item, rotationArray[temp[i]]);
     130        var position = FindPositionBySliding(item, rotationArray[temp[i]], stackingConstraints);
    135131        if (position != null) {
    136132          PackItem(temp[i], item, position);
     
    150146      }
    151147    }
     148   
    152149    public override void ExtremePointBasedPacking(ref IList<int> sequence, IList<PackingItem> items, bool stackingConstraints, Dictionary<int, bool> rotationArray) {
    153150      var temp = new List<int>(sequence);
     
    186183      throw new NotSupportedException();
    187184    }
    188 
    189185    protected override void InitializeOccupationLayers() {
    190186      for (int i = 0; i * 10 <= BinShape.Width; i += 1) {
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/IntegerVectorEncoding/BottomLeftIntegerVectorDecoder.cs

    r14167 r15230  
    4747
    4848    protected override PackingPosition FindPositionForItem(BinPacking2D bp, PackingItem item) {
    49       return bp.FindPositionBySliding(item, rotated: false);
     49      return bp.FindPositionBySliding(item, rotated: false, stackingConstraints: false);
    5050    }
    5151
     
    5454      ref IList<int> remainingIDs, IList<PackingItem> items) {
    5555      var bp = new BinPacking2D(partialSolution.BinShape);
    56       bp.SlidingBasedPacking(ref remainingIDs, items);
     56      bp.SlidingBasedPacking(ref remainingIDs, items, stackingConstraints: false);
    5757      return bp;
    5858    }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/PermutationEncoding/BottomLeftPermutationDecoder.cs

    r14167 r15230  
    4646      while (remainingIDs.Count > 0) {
    4747        var bp = new BinPacking2D(binShape);
    48         bp.SlidingBasedPacking(ref remainingIDs, items);
     48        bp.SlidingBasedPacking(ref remainingIDs, items, stackingConstraints: false);
    4949        result.Bins.Add(bp);
    5050      }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/BinPacking3D.cs

    r14916 r15230  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    3536      : base(binShape) {
    3637      ExtremePoints = new SortedSet<PackingPosition>();
    37       ExtremePoints.Add(binShape.Origin);
     38      ResidualSpace = new Dictionary<PackingPosition, Tuple<int,int,int>>();
     39      AddExtremePoint(binShape.Origin);
    3840      InitializeOccupationLayers();
    3941    }
     
    4345      : base(original, cloner) {
    4446      this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints.Select(p => cloner.Clone(p)));
     47      this.ResidualSpace = new Dictionary<PackingPosition, Tuple<int, int, int>>();
     48      foreach (var o in original.ResidualSpace)
     49        this.ResidualSpace.Add(cloner.Clone(o.Key), Tuple.Create(o.Value.Item1, o.Value.Item2, o.Value.Item3));
    4550    }
    4651    public override IDeepCloneable Clone(Cloner cloner) {
     
    6065          current = PackingPosition.MoveDown(current);
    6166        }
    62         ExtremePoints.Add((PackingPosition)current.Clone());
     67        AddExtremePoint((PackingPosition)current.Clone());
    6368        while (current.X > 0 && !IsPointOccupied(PackingPosition.MoveLeft(current))) {
    6469          current = PackingPosition.MoveLeft(current);
    6570        }
    66         ExtremePoints.Add(current);
     71        AddExtremePoint(current);
    6772
    6873        //Traversing down the z-axis
     
    7176          current = PackingPosition.MoveBack(current);
    7277        }
    73         ExtremePoints.Add((PackingPosition)current.Clone());
    74         while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
    75           current = PackingPosition.MoveDown(current);
    76         }
    77         ExtremePoints.Add(current);
     78        AddExtremePoint((PackingPosition)current.Clone());
     79        while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
     80          current = PackingPosition.MoveDown(current);
     81        }
     82        AddExtremePoint(current);
    7883      }
    7984
     
    8691          current = PackingPosition.MoveLeft(current);
    8792        }
    88         ExtremePoints.Add((PackingPosition)current.Clone());
    89         while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
    90           current = PackingPosition.MoveDown(current);
    91         }
    92         ExtremePoints.Add(current);
     93        AddExtremePoint((PackingPosition)current.Clone());
     94        while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
     95          current = PackingPosition.MoveDown(current);
     96        }
     97        AddExtremePoint(current);
    9398
    9499        //Traversing down the z-axis
     
    97102          current = PackingPosition.MoveBack(current);
    98103        }
    99         ExtremePoints.Add((PackingPosition)current.Clone());
    100         while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
    101           current = PackingPosition.MoveDown(current);
    102         }
    103         ExtremePoints.Add(current);
     104        AddExtremePoint((PackingPosition)current.Clone());
     105        while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
     106          current = PackingPosition.MoveDown(current);
     107        }
     108        AddExtremePoint(current);
    104109      }
    105110
     
    112117          current = PackingPosition.MoveLeft(current);
    113118        }
    114         ExtremePoints.Add((PackingPosition)current.Clone());
    115         while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
    116           current = PackingPosition.MoveDown(current);
    117         }
    118         ExtremePoints.Add(current);
     119        AddExtremePoint((PackingPosition)current.Clone());
     120        while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) {
     121          current = PackingPosition.MoveDown(current);
     122        }
     123        AddExtremePoint(current);
    119124
    120125        //Traversing down the y-axis
     
    123128          current = PackingPosition.MoveDown(current);
    124129        }
    125         ExtremePoints.Add((PackingPosition)current.Clone());
     130        AddExtremePoint((PackingPosition)current.Clone());
    126131        while (current.X > 0 && !IsPointOccupied(PackingPosition.MoveLeft(current))) {
    127132          current = PackingPosition.MoveLeft(current);
    128133        }
    129         ExtremePoints.Add(current);
     134        AddExtremePoint(current);
     135      }
     136    }
     137
     138    private void AddExtremePoint(PackingPosition current) {
     139      if (ExtremePoints.Add(current)) {
     140        var tuple = Tuple.Create(BinShape.Width - current.X, BinShape.Height - current.Y, BinShape.Depth - current.Z);
     141        ResidualSpace.Add(current, tuple);
    130142      }
    131143    }
    132144
    133145    public override PackingPosition FindExtremePointForItem(PackingItem item, bool rotated, bool stackingConstraints) {
    134 
    135146      PackingItem newItem = new PackingItem(
    136147        rotated ? item.Depth : item.Width,
     
    139150        item.TargetBin, item.Weight, item.Material);
    140151
    141       int epIndex = 0;
    142       while (epIndex < ExtremePoints.Count && (
    143         !IsPositionFeasible(newItem, ExtremePoints.ElementAt(epIndex))
    144         || !IsSupportedByAtLeastOnePoint(newItem, ExtremePoints.ElementAt(epIndex))
    145         || (stackingConstraints && !IsStaticStable(newItem, ExtremePoints.ElementAt(epIndex)))
    146         || (stackingConstraints && !IsWeightSupported(newItem, ExtremePoints.ElementAt(epIndex)))
    147       )) { epIndex++; }
    148 
    149       if (epIndex < ExtremePoints.Count) {
    150         var origPoint = ExtremePoints.ElementAt(epIndex);
    151         var result = new PackingPosition(origPoint.AssignedBin, origPoint.X, origPoint.Y, origPoint.Z, rotated);
     152      var ep = ExtremePoints.Where(x => IsPositionFeasible(newItem, x, stackingConstraints)).FirstOrDefault();
     153      if (ep != null) {
     154        var result = new PackingPosition(ep.AssignedBin, ep.X, ep.Y, ep.Z, rotated);
    152155        return result;
    153156      }
     
    155158    }
    156159
    157     public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated) {
    158       //TODO: does not support stacking constraints yet
     160    public override bool IsPositionFeasible(PackingItem item, PackingPosition position, bool stackingConstraints) {
     161      var feasible = base.IsPositionFeasible(item, position, stackingConstraints);
     162      return feasible
     163        && IsSupportedByAtLeastOnePoint(item, position)
     164        && (!stackingConstraints || (IsStaticStable(item, position) && IsWeightSupported(item, position)));
     165    }
     166
     167    public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated, bool stackingConstraints) {
    159168      //Starting-position at upper right corner (=left bottom point of item-rectangle is at position item.width,item.height)
    160169      PackingPosition currentPosition = new PackingPosition(0,
     
    163172        BinShape.Depth - (rotated ? item.Width : item.Depth), rotated);
    164173      //Slide the item as far as possible to the bottom
    165       while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition))
    166         || IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition))
    167         || IsPositionFeasible(item, PackingPosition.MoveBack(currentPosition))) {
     174      while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition), stackingConstraints)
     175        || IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints)
     176        || IsPositionFeasible(item, PackingPosition.MoveBack(currentPosition), stackingConstraints)) {
    168177        //Slide the item as far as possible to the left
    169         while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition))
    170       || IsPositionFeasible(item, PackingPosition.MoveBack(currentPosition))) {
     178        while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints)
     179      || IsPositionFeasible(item, PackingPosition.MoveBack(currentPosition), stackingConstraints)) {
    171180          //Slide the item as far as possible to the back
    172           while (IsPositionFeasible(item, PackingPosition.MoveBack(currentPosition))) {
     181          while (IsPositionFeasible(item, PackingPosition.MoveBack(currentPosition), stackingConstraints)) {
    173182            currentPosition = PackingPosition.MoveBack(currentPosition);
    174183          }
    175           if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition)))
     184          if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints))
    176185            currentPosition = PackingPosition.MoveLeft(currentPosition);
    177186        }
    178         if (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition)))
     187        if (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition), stackingConstraints))
    179188          currentPosition = PackingPosition.MoveDown(currentPosition);
    180189      }
    181190
    182       return IsPositionFeasible(item, currentPosition) ? currentPosition : null;
    183     }
    184 
    185     public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items) {
     191      return IsPositionFeasible(item, currentPosition, stackingConstraints) ? currentPosition : null;
     192    }
     193
     194    public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, bool stackingConstraints) {
    186195      var temp = new List<int>(sequence);
    187196      for (int i = 0; i < temp.Count; i++) {
    188197        var item = items[temp[i]];
    189         var position = FindPositionBySliding(item, false);
     198        var position = FindPositionBySliding(item, false, stackingConstraints);
    190199        if (position != null) {
    191200          PackItem(temp[i], item, position);
     
    194203      }
    195204    }
    196     public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, Dictionary<int, bool> rotationArray) {
     205    public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, Dictionary<int, bool> rotationArray, bool stackingConstraints) {
    197206      var temp = new List<int>(sequence);
    198207      for (int i = 0; i < temp.Count; i++) {
    199208        var item = items[temp[i]];
    200         var position = FindPositionBySliding(item, rotationArray[i]);
     209        var position = FindPositionBySliding(item, rotationArray[i], stackingConstraints);
    201210        if (position != null) {
    202211          PackItem(temp[i], item, position);
     
    212221        if (positionFound != null) {
    213222          PackItem(itemID, item, positionFound);
     223          if (!(positionFound.X == 0 && positionFound.Y == 0 && positionFound.Z == 0)) {
     224            UpdateResidualSpace(item, positionFound);
     225          }
    214226          sequence.Remove(itemID);
    215227        }
     
    227239      }
    228240    }
    229 
    230241    public override int ShortestPossibleSideFromPoint(PackingPosition position) {
    231242
     
    297308    }
    298309
    299 
    300310    protected override void InitializeOccupationLayers() {
    301311      for (int i = 0; i * 10 <= BinShape.Depth; i += 1) {
     
    320330      for (int i = z1; i <= z2; i++)
    321331        result.AddRange(OccupationLayers[i]);
    322 
    323332      return result;
    324333    }
     334   
     335    public void UpdateResidualSpace(PackingItem item, PackingPosition pos) {
     336      foreach (var ep in ExtremePoints) {
     337        if (ep.Z >= pos.Z && ep.Z <= pos.Z + item.Depth) {
     338          if (ep.X <= pos.X && ep.Y > pos.Y && ep.Y < pos.Y + item.Height) {
     339            var diff = pos.X - ep.X;
     340            var newRSX = ResidualSpace[ep].Item1 < diff ? ResidualSpace[ep].Item1 : diff;
     341            ResidualSpace[ep] = Tuple.Create(newRSX, ResidualSpace[ep].Item2, ResidualSpace[ep].Item3);
     342          }
     343          if (ep.Y <= pos.Y && ep.X > pos.X && ep.X < pos.X + item.Width) {
     344            var diff = pos.Y - ep.Y;
     345            var newRSY = ResidualSpace[ep].Item2 < diff ? ResidualSpace[ep].Item2 : diff;
     346            ResidualSpace[ep] = Tuple.Create(ResidualSpace[ep].Item1, newRSY, ResidualSpace[ep].Item3);
     347          }
     348        }
     349        if (ep.Z <= pos.Z &&
     350          ep.Y > pos.Y && ep.Y < pos.Y + item.Height &&
     351          ep.X > pos.X && ep.X < pos.X + item.Width) {
     352            var diff = pos.Z - ep.Z;
     353            var newRSZ = ResidualSpace[ep].Item3 < diff ? ResidualSpace[ep].Item3 : diff;
     354            ResidualSpace[ep] = Tuple.Create(ResidualSpace[ep].Item1, ResidualSpace[ep].Item2, newRSZ);
     355        }
     356      }
     357      return;
     358    }
    325359  }
    326 
    327360}
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/IntegerVectorEncoding/BottomLeftIntegerVectorDecoder.cs

    r14167 r15230  
    5454
    5555    protected override PackingPosition FindPositionForItem(BinPacking3D bp, PackingItem item, bool useStackingConstraints) {
    56       return bp.FindPositionBySliding(item, rotated: false);
     56      return bp.FindPositionBySliding(item, rotated: false, stackingConstraints: useStackingConstraints);
    5757    }
    5858
     
    6161      ref IList<int> remainingIDs, IList<PackingItem> items, bool useStackingConstraints) {
    6262      var bp = new BinPacking3D(partialSolution.BinShape);
    63       bp.SlidingBasedPacking(ref remainingIDs, items);
     63      bp.SlidingBasedPacking(ref remainingIDs, items, useStackingConstraints);
    6464      return bp;
    6565    }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/PermutationEncoding/BottomLeftPermutationDecoder.cs

    r14167 r15230  
    4646      while (remainingIDs.Count > 0) {
    4747        var bp = new BinPacking3D(binShape);
    48         bp.SlidingBasedPacking(ref remainingIDs, items);
     48        bp.SlidingBasedPacking(ref remainingIDs, items, useStackingConstraints);
    4949        result.Bins.Add(bp);
    5050      }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/PermutationEncoding/ExtremePointPermutationDecoder.cs

    r14167 r15230  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2526using System.Collections.Generic;
    2627using HeuristicLab.Encodings.PermutationEncoding;
     28using System.Linq;
     29
    2730
    2831namespace HeuristicLab.Problems.BinPacking3D {
    2932  [Item("Extreme-point Permutation Decoder (3d)", "Decodes the permutation and creates a packing solution candidate")]
    3033  [StorableClass]
    31   public class ExtremePointPermutationDecoder : Item, IDecoder<Permutation> {
     34  public class ExtremePointPermutationDecoder : ExtremePointPermutationDecoderBase {
    3235
    3336    [StorableConstructor]
     
    4144    }
    4245
    43     public Solution Decode(Permutation permutation, PackingShape binShape, IList<PackingItem> items, bool useStackingConstraints) {
     46    public override Solution Decode(Permutation permutation, PackingShape binShape, IList<PackingItem> items, bool useStackingConstraints) {
     47      return Apply(permutation, binShape, items, useStackingConstraints);
     48    }
     49
     50    public static Solution Apply(Permutation permutation, PackingShape binShape, IList<PackingItem> items, bool useStackingConstraints) {
    4451      Solution result = new Solution(binShape, useExtremePoints: true, stackingConstraints: useStackingConstraints);
    4552      IList<int> remainingIDs = new List<int>(permutation);
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/ProblemBase.cs

    r14162 r15230  
    175175    public override bool Maximization { get { return true; } }
    176176
    177 
    178177    public override double Evaluate(Individual individual, IRandom random) {
    179178      var encodedSolutionCand = (TSol)individual[EncodedSolutionName];
     
    237236      BinShape = data.BinShape;
    238237      var items = new ItemList<PackingItem>(data.Items);
    239       items.Sort((x, y) => y.CompareTo(x));
    240238      Items = items.AsReadOnly();
    241239
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/BinPacking.cs

    r14162 r15230  
    5151    protected Dictionary<int, List<int>> OccupationLayers { get; set; }
    5252
     53    [Storable]
     54    public Dictionary<TPos, Tuple<int,int,int>> ResidualSpace { get; protected set; }
     55
    5356    #endregion Properties
     57
     58    public int FreeVolume {
     59      get { return BinShape.Volume - Items.Sum(x => x.Value.Volume); }
     60    }
    5461
    5562    protected BinPacking(TBin binShape)
     
    6067      OccupationLayers = new Dictionary<int, List<int>>();
    6168    }
    62 
    6369
    6470    [StorableConstructor]
     
    8490
    8591    public abstract TPos FindExtremePointForItem(TItem item, bool rotated, bool stackingConstraints);
    86     public abstract TPos FindPositionBySliding(TItem item, bool rotated);
     92    public abstract TPos FindPositionBySliding(TItem item, bool rotated, bool stackingConstraints);
    8793
    88     public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<TItem> items);
    89     public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<TItem> items, Dictionary<int, bool> rotationArray);
     94    public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<TItem> items, bool stackingConstraints);
     95    public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<TItem> items, Dictionary<int, bool> rotationArray, bool stackingConstraints);
    9096    public abstract void ExtremePointBasedPacking(ref IList<int> sequence, IList<TItem> items, bool stackingConstraints);
    9197    public abstract void ExtremePointBasedPacking(ref IList<int> sequence, IList<TItem> items, bool stackingConstraints, Dictionary<int, bool> rotationArray);
    9298
    93     public void PackItem(int itemID, TItem item, TPos position) {
     99    public virtual void PackItem(int itemID, TItem item, TPos position) {
    94100      Items[itemID] = item;
    95101      Positions[itemID] = position;
    96102      ExtremePoints.Remove(position);
     103      if (ResidualSpace != null) ResidualSpace.Remove(position);
    97104      foreach (int id in Items.Select(x => x.Key))
    98105        GenerateNewExtremePointsForNewItem(Items[id], Positions[id]);
    99 
     106     
    100107      AddNewItemToOccupationLayers(itemID, item, position);
     108    }
     109    public virtual bool PackItemIfFeasible(int itemID, TItem item, TPos position, bool stackingConstraints) {
     110      if (IsPositionFeasible(item, position, stackingConstraints)) {
     111        PackItem(itemID, item, position);
     112        return true;
     113      }
     114      return false;
    101115    }
    102116
     
    127141      return false;
    128142    }
    129     public bool IsPositionFeasible(TItem item, TPos position) {
     143    public virtual bool IsPositionFeasible(TItem item, TPos position, bool stackingConstraints) {
    130144      //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the point is supported by something; 3. the item does not collide with another already packed item
    131145      if (!BinShape.Encloses(position, item))
     
    139153      return true;
    140154    }
     155   
    141156    public abstract int ShortestPossibleSideFromPoint(TPos position);
    142157    public abstract bool IsStaticStable(TItem measures, TPos position);
    143 
    144158
    145159    protected abstract void InitializeOccupationLayers();
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r15069 r15230  
    1919    <DebugType>full</DebugType>
    2020    <Optimize>false</Optimize>
    21     <OutputPath>..\..\bin\</OutputPath>
     21    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    2222    <DefineConstants>DEBUG;TRACE</DefineConstants>
    2323    <ErrorReport>prompt</ErrorReport>
     
    2727    <DebugType>pdbonly</DebugType>
    2828    <Optimize>true</Optimize>
    29     <OutputPath>..\..\bin\</OutputPath>
     29    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    3030    <DefineConstants>TRACE</DefineConstants>
    3131    <ErrorReport>prompt</ErrorReport>
     
    3434  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    3535    <DebugSymbols>true</DebugSymbols>
    36     <OutputPath>..\..\bin\</OutputPath>
     36    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    3737    <DefineConstants>DEBUG;TRACE</DefineConstants>
    3838    <DebugType>full</DebugType>
     
    4141  </PropertyGroup>
    4242  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    43     <OutputPath>..\..\bin\</OutputPath>
     43    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    4444    <DefineConstants>TRACE</DefineConstants>
    4545    <Optimize>true</Optimize>
     
    5151  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    5252    <DebugSymbols>true</DebugSymbols>
    53     <OutputPath>..\..\bin\</OutputPath>
     53    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    5454    <DefineConstants>DEBUG;TRACE</DefineConstants>
    5555    <DebugType>full</DebugType>
     
    5858  </PropertyGroup>
    5959  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    60     <OutputPath>..\..\bin\</OutputPath>
     60    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    6161    <DefineConstants>TRACE</DefineConstants>
    6262    <Optimize>true</Optimize>
     
    7272  </PropertyGroup>
    7373  <ItemGroup>
     74    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     75      <SpecificVersion>False</SpecificVersion>
     76      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     77      <Private>False</Private>
     78    </Reference>
     79    <Reference Include="HeuristicLab.Collections-3.3">
     80      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     81      <Private>False</Private>
     82    </Reference>
     83    <Reference Include="HeuristicLab.Common-3.3">
     84      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     85      <Private>False</Private>
     86    </Reference>
     87    <Reference Include="HeuristicLab.Core-3.3">
     88      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     89      <Private>False</Private>
     90    </Reference>
     91    <Reference Include="HeuristicLab.Data-3.3">
     92      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     93      <Private>False</Private>
     94    </Reference>
     95    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3">
     96      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath>
     97      <Private>False</Private>
     98    </Reference>
     99    <Reference Include="HeuristicLab.Encodings.PermutationEncoding-3.3">
     100      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.PermutationEncoding-3.3.dll</HintPath>
     101      <Private>False</Private>
     102    </Reference>
     103    <Reference Include="HeuristicLab.Operators-3.3">
     104      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     105      <Private>False</Private>
     106    </Reference>
     107    <Reference Include="HeuristicLab.Optimization-3.3">
     108      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     109      <Private>False</Private>
     110    </Reference>
     111    <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     112      <SpecificVersion>False</SpecificVersion>
     113      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     114      <Private>False</Private>
     115    </Reference>
     116    <Reference Include="HeuristicLab.Parameters-3.3">
     117      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     118      <Private>False</Private>
     119    </Reference>
     120    <Reference Include="HeuristicLab.Persistence-3.3">
     121      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     122      <Private>False</Private>
     123    </Reference>
     124    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     125      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     126      <Private>False</Private>
     127    </Reference>
     128    <Reference Include="HeuristicLab.Problems.Instances-3.3">
     129      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     130      <Private>False</Private>
     131    </Reference>
     132    <Reference Include="HeuristicLab.Random-3.3">
     133      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     134      <Private>False</Private>
     135    </Reference>
    74136    <Reference Include="System" />
    75137    <Reference Include="System.Core" />
     
    106168    <Compile Include="3D\Evaluators\BinUtilizationEvaluator.cs" />
    107169    <Compile Include="3D\Evaluators\PackingRatioEvaluator.cs" />
     170    <Compile Include="Algorithms\3D\ExtremePointAlgorithm.cs" />
     171    <Compile Include="3D\Instances\ThreeDInstanceDescriptor.cs" />
    108172    <Compile Include="3D\Instances\BPPData.cs" />
    109173    <Compile Include="3D\Instances\RandomDataDescriptor.cs" />
     174    <Compile Include="3D\Instances\RealWorldContainerPackingInstanceProvider.cs" />
    110175    <Compile Include="3D\Instances\RandomInstanceProvider.cs" />
     176    <Compile Include="3D\Instances\ThreeDInstanceParser.cs" />
    111177    <Compile Include="3D\IntegerVectorEncoding\BottomLeftIntegerVectorDecoder.cs" />
    112178    <Compile Include="3D\IntegerVectorEncoding\ExtremePointIntegerVectorDecoder.cs" />
     
    121187    <Compile Include="3D\PackingShape.cs" />
    122188    <Compile Include="3D\PermutationEncoding\BottomLeftPermutationDecoder.cs" />
     189    <Compile Include="3D\PermutationEncoding\ResidualSpaceBestFitExtremePointPermutationDecoder.cs" />
     190    <Compile Include="3D\PermutationEncoding\FreeVolumeBestFitExtremePointPermutationDecoder.cs" />
     191    <Compile Include="3D\PermutationEncoding\ExtremePointPermutationDecoderBase.cs" />
    123192    <Compile Include="3D\PermutationEncoding\ExtremePointPermutationDecoder.cs" />
    124193    <Compile Include="3D\PermutationEncoding\PermutationProblem.cs" />
     
    144213  </ItemGroup>
    145214  <ItemGroup>
     215    <EmbeddedResource Include="3D\Instances\ContainerPackingInstances.zip" />
    146216    <None Include="HeuristicLab.snk" />
    147217    <None Include="Properties\AssemblyInfo.cs.frame" />
     
    149219  </ItemGroup>
    150220  <ItemGroup />
    151   <ItemGroup>
    152     <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
    153       <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
    154       <Name>HeuristicLab.Analysis-3.3</Name>
    155       <Private>False</Private>
    156     </ProjectReference>
    157     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    158       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    159       <Name>HeuristicLab.Collections-3.3</Name>
    160       <Private>False</Private>
    161     </ProjectReference>
    162     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    163       <Project>{a9ad58b9-3ef9-4cc1-97e5-8d909039ff5c}</Project>
    164       <Name>HeuristicLab.Common-3.3</Name>
    165       <Private>False</Private>
    166     </ProjectReference>
    167     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    168       <Project>{c36bd924-a541-4a00-afa8-41701378ddc5}</Project>
    169       <Name>HeuristicLab.Core-3.3</Name>
    170       <Private>False</Private>
    171     </ProjectReference>
    172     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    173       <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
    174       <Name>HeuristicLab.Data-3.3</Name>
    175       <Private>False</Private>
    176     </ProjectReference>
    177     <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">
    178       <Project>{ddfb14dd-2a85-493c-a52d-e69729bbaeb0}</Project>
    179       <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>
    180       <Private>False</Private>
    181     </ProjectReference>
    182     <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
    183       <Project>{dbecb8b0-b166-4133-baf1-ed67c3fd7fca}</Project>
    184       <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name>
    185       <Private>False</Private>
    186     </ProjectReference>
    187     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    188       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    189       <Name>HeuristicLab.Operators-3.3</Name>
    190       <Private>False</Private>
    191     </ProjectReference>
    192     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    193       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    194       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    195       <Private>False</Private>
    196     </ProjectReference>
    197     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    198       <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
    199       <Name>HeuristicLab.Optimization-3.3</Name>
    200       <Private>False</Private>
    201     </ProjectReference>
    202     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    203       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    204       <Name>HeuristicLab.Parameters-3.3</Name>
    205       <Private>False</Private>
    206     </ProjectReference>
    207     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    208       <Project>{102bc7d3-0ef9-439c-8f6d-96ff0fdb8e1b}</Project>
    209       <Name>HeuristicLab.Persistence-3.3</Name>
    210       <Private>False</Private>
    211     </ProjectReference>
    212     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    213       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    214       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    215       <Private>False</Private>
    216     </ProjectReference>
    217     <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
    218       <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
    219       <Name>HeuristicLab.Problems.Instances-3.3</Name>
    220       <Private>False</Private>
    221     </ProjectReference>
    222     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    223       <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
    224       <Name>HeuristicLab.Random-3.3</Name>
    225       <Private>False</Private>
    226     </ProjectReference>
    227   </ItemGroup>
    228221  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    229222  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset for help on using the changeset viewer.