- Timestamp:
- 07/21/16 13:03:42 (8 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r14146 r14151 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Collections; 28 using HeuristicLab.Problems.BinPacking;29 28 30 namespace HeuristicLab. Encodings.PackingEncoding {29 namespace HeuristicLab.Problems.BinPacking { 31 30 [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")] 32 31 [StorableClass] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r14146 r14151 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Collections; 29 using HeuristicLab.Problems.BinPacking;30 29 31 namespace HeuristicLab. Encodings.PackingEncoding {30 namespace HeuristicLab.Problems.BinPacking { 32 31 [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")] 33 32 [StorableClass] … … 145 144 } 146 145 public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) { 147 var sequenceMatrix = solution.GenerateSequenceMatrix();148 149 //Fill bins according to grouping vector150 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 else157 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);158 BinPackings.Add(bp);159 }160 UpdateBinPackings();161 162 //Try to put remaining items in existing bins163 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 bins176 while (remainingIDs.Count > 0) {177 var bp = NewBinPacking();178 if (!UseExtremePoints)179 bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);180 else181 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);194 146 } 195 147 * 196 148 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 else204 bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);205 BinPackings.Add(bp);206 }207 UpdateBinPackings();208 }209 149 210 150 */ -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r14146 r14151 160 160 <Compile Include="Encodings\PackingPlans\BinPacking.cs" /> 161 161 <Compile Include="Encodings\PackingPlans\PackingPlan.cs" /> 162 <Compile Include="Encodings\PackingSolutionCreator.cs" />163 <Compile Include="Encodings\PackingSolutionCrossover.cs" />164 <Compile Include="Encodings\PackingSolutionManipulator.cs" />165 162 <Compile Include="Interfaces\IDecodingEvaluator.cs" /> 166 163 <Compile Include="Interfaces\IPackingPosition.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingSolutionDecoder.cs
r14048 r14151 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Data; 29 using HeuristicLab.Encodings.PackingEncoding;30 29 31 30 namespace HeuristicLab.Problems.BinPacking { … … 50 49 get { return (ILookupParameter<IItem>)Parameters["EncodedSolution"]; } 51 50 } 52 public ILookupParameter<PackingPlan<D, B,I>> PackingPlanParameter {51 public ILookupParameter<PackingPlan<D, B, I>> PackingPlanParameter { 53 52 get { return (ILookupParameter<PackingPlan<D, B, I>>)Parameters["PackingPlan"]; } 54 53 } … … 58 57 59 58 60 public PackingSolutionDecoder() : base() { 59 public PackingSolutionDecoder() 60 : base() { 61 61 Parameters.Add(new LookupParameter<IItem>("EncodedSolution", "The new bin-packing solution represented as encoding.")); 62 62 Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan.")); … … 69 69 [StorableConstructor] 70 70 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) 72 72 : base(original, cloner) { 73 73 }
Note: See TracChangeset
for help on using the changeset viewer.