Ignore:
Timestamp:
07/13/16 09:30:01 (5 years ago)
Author:
gkronber
Message:

#1966: simplified parsers

File:
1 edited

Legend:

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

    r14049 r14055  
    8585    }
    8686
    87     public override PackingPosition FindExtremePointForItem(PackingItem measures, bool rotated, bool stackingConstraints) {
    88       PackingItem item = new PackingItem(
    89         rotated ? measures.Height : measures.Width,
    90         rotated ? measures.Width : measures.Height,
    91         measures.TargetBin);
     87    public override PackingPosition FindExtremePointForItem(PackingItem item, bool rotated, bool stackingConstraints) {
     88      PackingItem rotatedItem = new PackingItem(
     89        rotated ? item.Height : item.Width,
     90        rotated ? item.Width : item.Height,
     91        item.TargetBin);
    9292
    9393      int epIndex = 0;
    94       while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)))) { epIndex++; }
     94      while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(rotatedItem, ExtremePoints.ElementAt(epIndex)))) { epIndex++; }
    9595
    9696      if (epIndex < ExtremePoints.Count) {
     
    102102      return null;
    103103    }
    104     public override PackingPosition FindPositionBySliding(PackingItem measures, bool rotated) {
     104    public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated) {
    105105      PackingPosition currentPosition = new PackingPosition(0,
    106         BinMeasures.Width - (rotated ? measures.Height : measures.Width),
    107         BinMeasures.Height - (rotated ? measures.Width : measures.Height), rotated);
     106        BinMeasures.Width - (rotated ? item.Height : item.Width),
     107        BinMeasures.Height - (rotated ? item.Width : item.Height), rotated);
    108108      //Slide the item as far as possible to the left
    109       while (IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition))
    110         || IsPositionFeasible(measures, PackingPosition.MoveDown(currentPosition))) {
     109      while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition))
     110        || IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition))) {
    111111        //Slide the item as far as possible to the bottom
    112         while (IsPositionFeasible(measures, PackingPosition.MoveDown(currentPosition))) {
     112        while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition))) {
    113113          currentPosition = PackingPosition.MoveDown(currentPosition);
    114114        }
    115         if (IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition)))
     115        if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition)))
    116116          currentPosition = PackingPosition.MoveLeft(currentPosition);
    117117      }
    118118
    119       return IsPositionFeasible(measures, currentPosition) ? currentPosition : null;
    120     }
    121 
    122     public override void SlidingBasedPacking(ref List<int> sequence, ItemList<PackingItem> itemMeasures) {
     119      return IsPositionFeasible(item, currentPosition) ? currentPosition : null;
     120    }
     121
     122    public override void SlidingBasedPacking(ref List<int> sequence, ItemList<PackingItem> items) {
    123123      var temp = new List<int>(sequence);
    124124      for (int i = 0; i < temp.Count; i++) {
    125         var item = itemMeasures[temp[i]];
     125        var item = items[temp[i]];
    126126        var position = FindPositionBySliding(item, false);
    127127        if (position != null) {
     
    131131      }
    132132    }
    133     public override void SlidingBasedPacking(ref List<int> sequence, ItemList<PackingItem> itemMeasures, Dictionary<int, bool> rotationArray) {
     133    public override void SlidingBasedPacking(ref List<int> sequence, ItemList<PackingItem> items, Dictionary<int, bool> rotationArray) {
    134134      var temp = new List<int>(sequence);
    135135      for (int i = 0; i < temp.Count; i++) {
    136         var item = itemMeasures[temp[i]];
     136        var item = items[temp[i]];
    137137        var position = FindPositionBySliding(item, rotationArray[temp[i]]);
    138138        if (position != null) {
     
    142142      }
    143143    }
    144     public override void ExtremePointBasedPacking(ref List<int> sequence, ItemList<PackingItem> itemMeasures, bool stackingConstraints) {
     144    public override void ExtremePointBasedPacking(ref List<int> sequence, ItemList<PackingItem> items, bool stackingConstraints) {
    145145      var temp = new List<int>(sequence);
    146146      foreach (int itemID in temp) {
    147         var item = itemMeasures[itemID];
     147        var item = items[itemID];
    148148        var positionFound = FindExtremePointForItem(item, false, false);
    149149        if (positionFound != null) {
     
    153153      }
    154154    }
    155     public override void ExtremePointBasedPacking(ref List<int> sequence, ItemList<PackingItem> itemMeasures, bool stackingConstraints, Dictionary<int, bool> rotationArray) {
     155    public override void ExtremePointBasedPacking(ref List<int> sequence, ItemList<PackingItem> items, bool stackingConstraints, Dictionary<int, bool> rotationArray) {
    156156      var temp = new List<int>(sequence);
    157157      foreach (int itemID in temp) {
    158         var item = itemMeasures[itemID];
     158        var item = items[itemID];
    159159        var positionFound = FindExtremePointForItem(item, rotationArray[itemID], false);
    160160        if (positionFound != null) {
Note: See TracChangeset for help on using the changeset viewer.