- Timestamp:
- 07/21/16 15:08:21 (8 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/BinPacking2D.cs
r14151 r14154 32 32 public class BinPacking2D : BinPacking.BinPacking<PackingPosition, PackingShape, PackingItem> { 33 33 34 public BinPacking2D(PackingShape bin Measures)35 : base(bin Measures) {34 public BinPacking2D(PackingShape binShape) 35 : base(binShape) { 36 36 ExtremePoints = new SortedSet<PackingPosition>(new EPComparer2D()); 37 ExtremePoints.Add(binMeasures.Origin); 38 } 37 ExtremePoints.Add(binShape.Origin); 38 InitializeOccupationLayers(); 39 } 40 39 41 [StorableConstructor] 40 42 protected BinPacking2D(bool deserializing) : base(deserializing) { } 41 43 protected BinPacking2D(BinPacking2D original, Cloner cloner) 42 44 : base(original, cloner) { 43 this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints , new EPComparer2D());45 this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints.Select(p => cloner.Clone(p)), new EPComparer2D()); 44 46 } 45 47 public override IDeepCloneable Clone(Cloner cloner) { … … 54 56 //Find ExtremePoints beginning from sourcepointX 55 57 var sourcePointX = new PackingPosition(0, position.X + newWidth, position.Y); 56 if (sourcePointX.X < Bin Measures.Width && sourcePointX.Y < BinMeasures.Height) {58 if (sourcePointX.X < BinShape.Width && sourcePointX.Y < BinShape.Height) { 57 59 //Traversing down the y-axis 58 60 var newPoint = new PackingPosition(0, sourcePointX.X, sourcePointX.Y - 1); … … 66 68 //Find ExtremePoints beginning from sourcepointY 67 69 var sourcePointY = new PackingPosition(0, position.X, position.Y + newHeight); 68 if (sourcePointY.X < Bin Measures.Width && sourcePointY.Y < BinMeasures.Height) {70 if (sourcePointY.X < BinShape.Width && sourcePointY.Y < BinShape.Height) { 69 71 //Traversing down the x-axis 70 72 var newPoint = new PackingPosition(0, sourcePointY.X - 1, sourcePointY.Y); … … 96 98 public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated) { 97 99 PackingPosition currentPosition = new PackingPosition(0, 98 Bin Measures.Width - (rotated ? item.Height : item.Width),99 Bin Measures.Height - (rotated ? item.Width : item.Height), rotated);100 BinShape.Width - (rotated ? item.Height : item.Width), 101 BinShape.Height - (rotated ? item.Width : item.Height), rotated); 100 102 //Slide the item as far as possible to the left 101 103 while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition)) … … 159 161 public override int ShortestPossibleSideFromPoint(PackingPosition position) { 160 162 int shortestSide = int.MaxValue; 161 int width = Bin Measures.Width;162 int height = Bin Measures.Height;163 int width = BinShape.Width; 164 int height = BinShape.Height; 163 165 164 166 if (position.X >= width || position.Y >= height) … … 182 184 } 183 185 184 185 186 protected override void InitializeOccupationLayers() { 186 for (int i = 0; i * 10 <= Bin Measures.Width; i += 1) {187 for (int i = 0; i * 10 <= BinShape.Width; i += 1) { 187 188 OccupationLayers[i] = new List<int>(); 188 189 } 189 190 } 190 protected override void AddNewItemToOccupationLayers(int itemID, PackingItem measures, PackingPosition position) { 191 192 protected override void AddNewItemToOccupationLayers(int itemID, PackingItem item, PackingPosition position) { 191 193 int x1 = position.X / 10; 192 int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10;194 int x2 = (position.X + (position.Rotated ? item.Height : item.Width)) / 10; 193 195 194 196 for (int i = x1; i <= x2; i++) … … 198 200 return OccupationLayers[position.X / 10]; 199 201 } 200 protected override List<int> GetLayerItemIDs(PackingItem measures, PackingPosition position) {202 protected override List<int> GetLayerItemIDs(PackingItem item, PackingPosition position) { 201 203 List<int> result = new List<int>(); 202 204 int x1 = position.X / 10; 203 int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10;205 int x2 = (position.X + (position.Rotated ? item.Height : item.Width)) / 10; 204 206 205 207 for (int i = x1; i <= x2; i++) -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Evaluators/BinUtilizationEvaluator.cs
r14148 r14154 53 53 54 54 for (int i = 0; i < nrOfBins; i++) { 55 totalUsableSpace += solution.BinPackings[i].Bin Measures.Volume;56 totalUsedSpace += solution.BinPackings[i].Item Measures.Sum(kvp => kvp.Value.Volume);55 totalUsableSpace += solution.BinPackings[i].BinShape.Volume; 56 totalUsedSpace += solution.BinPackings[i].Items.Sum(kvp => kvp.Value.Volume); 57 57 } 58 58 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Evaluators/PackingRatioEvaluator.cs
r14151 r14154 60 60 const double k = 2; 61 61 for (int i = 0; i < nrOfBins; i++) { 62 double f = solution.BinPackings[i].Item Measures.Sum(kvp => kvp.Value.Volume);63 double c = solution.BinPackings[i].Bin Measures.Volume;62 double f = solution.BinPackings[i].Items.Sum(kvp => kvp.Value.Volume); 63 double c = solution.BinPackings[i].BinShape.Volume; 64 64 result += Math.Pow(f / c, k); 65 65 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj
r14151 r14154 172 172 <Compile Include="IntegerVectorEncoding\ExtremePointIntegerVectorDecoder.cs" /> 173 173 <Compile Include="IntegerVectorEncoding\IntegerVectorProblem.cs" /> 174 <Compile Include="Interfaces\IOperator.cs" /> 174 175 <Compile Include="Interfaces\IDecoder.cs" /> 175 176 <Compile Include="Interfaces\IEvaluator.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluatorBase.cs
r14153 r14154 31 31 [StorableClass] 32 32 public abstract class MoveEvaluatorBase<TSol, TMove> : SingleSuccessorOperator, 33 ISingleObjectiveMoveEvaluator, ISingleObjectiveMoveOperator 33 ISingleObjectiveMoveEvaluator, ISingleObjectiveMoveOperator, IOperator<TSol> 34 34 where TSol : class, IItem 35 35 where TMove : class, IItem { … … 43 43 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 44 44 } 45 public ILookupParameter<ReadOnlyItemList<PackingItem>> PackingItemMeasuresParameter {45 public ILookupParameter<ReadOnlyItemList<PackingItem>> ItemsParameter { 46 46 get { return (LookupParameter<ReadOnlyItemList<PackingItem>>)Parameters["Items"]; } 47 47 } 48 public ILookupParameter<PackingShape> PackingBinMeasuresParameter {48 public ILookupParameter<PackingShape> BinShapeParameter { 49 49 get { return (LookupParameter<PackingShape>)Parameters["BinShape"]; } 50 50 } 51 public ILookupParameter<IDecoder<TSol>> PackingSolutionDecoderParameter {51 public ILookupParameter<IDecoder<TSol>> DecoderParameter { 52 52 get { return (ILookupParameter<IDecoder<TSol>>)Parameters["Decoder"]; } 53 53 } 54 public ILookupParameter<IEvaluator> PackingPlanEvaluatorParameter {54 public ILookupParameter<IEvaluator> SolutionEvaluatorParameter { 55 55 get { return (ILookupParameter<IEvaluator>)Parameters["SolutionEvaluator"]; } 56 56 } … … 78 78 var move = MoveParameter.ActualValue; 79 79 var encSolCandidate = EncodedSolutionParameter.ActualValue; 80 var binShape = PackingBinMeasuresParameter.ActualValue;81 var items = PackingItemMeasuresParameter.ActualValue;80 var binShape = BinShapeParameter.ActualValue; 81 var items = ItemsParameter.ActualValue; 82 82 83 83 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PermutationEncoding/PermutationProblem.cs
r14153 r14154 23 23 24 24 using System.Linq; 25 using System.Windows.Forms; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 72 73 Encoding.ConfigureOperators(Operators.OfType<IOperator>()); 73 74 74 // TODO: configure the move evaluators (add interface for my move evaluators) 75 foreach (var op in Operators.OfType<IOperator<Permutation>>()) { 76 op.BinShapeParameter.ActualName = BinShapeParameter.Name; 77 op.ItemsParameter.ActualName = ItemsParameter.Name; 78 op.SolutionEvaluatorParameter.ActualName = SolutionEvaluatorParameter.Name; 79 op.DecoderParameter.ActualName = DecoderParameter.Name; 80 } 75 81 } 76 82 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PermutationEncoding/Swap2MoveEvaluator.cs
r14149 r14154 50 50 // uses full evaluation 51 51 Swap2Manipulator.Apply(permutation, move.Index1, move.Index2); 52 var solution = PackingSolutionDecoderParameter.ActualValue.Decode(permutation, binShape, items);52 var solution = DecoderParameter.ActualValue.Decode(permutation, binShape, items); 53 53 54 return PackingPlanEvaluatorParameter.ActualValue.Evaluate(solution);54 return SolutionEvaluatorParameter.ActualValue.Evaluate(solution); 55 55 } 56 56 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PermutationEncoding/TranslocationMoveEvaluator.cs
r14149 r14154 51 51 // uses full evaluation 52 52 TranslocationManipulator.Apply(permutation, move.Index1, move.Index2, move.Index3); 53 var solution = PackingSolutionDecoderParameter.ActualValue.Decode(permutation, binShape, items);53 var solution = DecoderParameter.ActualValue.Decode(permutation, binShape, items); 54 54 55 return PackingPlanEvaluatorParameter.ActualValue.Evaluate(solution);55 return SolutionEvaluatorParameter.ActualValue.Evaluate(solution); 56 56 } 57 57 }
Note: See TracChangeset
for help on using the changeset viewer.