Changeset 14128
- Timestamp:
- 07/20/16 14:02:36 (8 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 1 added
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/BinPacking2D.cs
r14055 r14128 66 66 67 67 //Find ExtremePoints beginning from sourcepointY 68 var sourcePointY = new PackingPosition(0, position.X, position.Y + new Item.Height);68 var sourcePointY = new PackingPosition(0, position.X, position.Y + newHeight); 69 69 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) { 70 70 //Traversing down the x-axis -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/BL/BottomLeftPackingSequenceDecoder.cs
r14049 r14128 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Common; 27 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;28 27 using HeuristicLab.Problems.BinPacking; 29 28 using HeuristicLab.Encodings.PackingEncoding; 29 using HeuristicLab.Encodings.PermutationEncoding; 30 30 31 31 namespace HeuristicLab.Problems.BinPacking2D { … … 45 45 46 46 public override PackingPlan<PackingPosition, PackingShape, PackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, PackingShape binMeasures, ItemList<PackingItem> itemMeasures) { 47 var solution = encodedSolution as P ackingSequenceEncoding;47 var solution = encodedSolution as Permutation; 48 48 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); 49 49 Solution result = new Solution(binMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r14049 r14128 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;27 26 using HeuristicLab.Problems.BinPacking; 28 27 using HeuristicLab.Encodings.PackingEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/EP/ExtremePointPackingSequenceDecoder2D.cs
r14049 r14128 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Common; 27 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;28 27 using HeuristicLab.Problems.BinPacking; 29 28 using HeuristicLab.Encodings.PackingEncoding; 29 using HeuristicLab.Encodings.PermutationEncoding; 30 30 31 31 namespace HeuristicLab.Problems.BinPacking2D { … … 45 45 46 46 public override PackingPlan<PackingPosition, PackingShape, PackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, PackingShape binMeasures, ItemList<PackingItem> itemMeasures) { 47 var solution = encodedSolution as P ackingSequenceEncoding;48 if (solution == null) throw new InvalidOperationException("Encoding is not of type P ackingSequence");47 var solution = encodedSolution as Permutation; 48 if (solution == null) throw new InvalidOperationException("Encoding is not of type Permutation"); 49 49 Solution result = new Solution(binMeasures, true, false); 50 50 result.Pack(solution, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj
r14063 r14128 163 163 <ItemGroup> 164 164 <Compile Include="BinPacking2D.cs" /> 165 <Compile Include="Decoders\BL\BottomLeftGroupingVectorDecoder.cs" /> 166 <Compile Include="Decoders\BL\BottomLeftMultiComponentVectorDecoder.cs" /> 167 <Compile Include="Decoders\BL\BottomLeftPackingSequenceDecoder.cs" /> 168 <Compile Include="Decoders\EP\ExtremePointGroupingVectorDecoder2D.cs" /> 169 <Compile Include="Decoders\EP\ExtremePointMultiComponentVectorDecoder2D.cs" /> 170 <Compile Include="Decoders\EP\ExtremePointPackingSequenceDecoder2D.cs" /> 165 <Compile Include="Decoders\EP\ExtremePointPackingSequenceDecoder2D.cs"> 166 <SubType>Code</SubType> 167 </Compile> 171 168 <Compile Include="Instances\BPPData.cs" /> 172 169 <Compile Include="Instances\RandomDataDescriptor.cs" /> … … 176 173 <Compile Include="Interfaces\I2DOperator.cs" /> 177 174 <Compile Include="Interfaces\I2DPSDecoder.cs" /> 178 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DGV.cs" />179 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DMCV.cs" />180 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DPS.cs" />181 175 <Compile Include="PackingItem.cs" /> 182 176 <Compile Include="PackingPosition.cs" /> 183 177 <Compile Include="PackingRatioEvaluator.cs" /> 178 <Compile Include="PackingSequenceProblem.cs" /> 184 179 <Compile Include="PackingShape.cs" /> 185 180 <Compile Include="Plugin.cs" /> 186 <Compile Include="Problem.cs" />187 181 <Compile Include="Properties\AssemblyInfo.cs" /> 188 182 <Compile Include="Solution.cs" /> … … 198 192 <Name>HeuristicLab.Problems.BinPacking-3.3</Name> 199 193 </ProjectReference> 194 </ItemGroup> 195 <ItemGroup> 196 <Folder Include="Decoders\BL\" /> 197 <Folder Include="MoveEvaluators\" /> 200 198 </ItemGroup> 201 199 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluators/PackingMoveEvaluator2DGV.cs
r14049 r14128 29 29 [Item("GroupingVectorMoveEvaluator2D", "Class for evaluating packing moves for 2dimensional problems.")] 30 30 [StorableClass] 31 public class PackingMoveEvaluator2DGV : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I2DOperator { 31 public class PackingMoveEvaluator2DGV<T> : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem, T>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I2DOperator 32 where T : class , IItem { 32 33 [StorableConstructor] 33 34 protected PackingMoveEvaluator2DGV(bool deserializing) : base(deserializing) { } 34 protected PackingMoveEvaluator2DGV(PackingMoveEvaluator2DGV original, Cloner cloner)35 protected PackingMoveEvaluator2DGV(PackingMoveEvaluator2DGV<T> original, Cloner cloner) 35 36 : base(original, cloner) { 36 37 } 37 38 public override IDeepCloneable Clone(Cloner cloner) { 38 return new PackingMoveEvaluator2DGV (this, cloner);39 return new PackingMoveEvaluator2DGV<T>(this, cloner); 39 40 } 40 41 public PackingMoveEvaluator2DGV() -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluators/PackingMoveEvaluator2DMCV.cs
r14049 r14128 29 29 [Item("MultiComponentVectorMoveEvaluator2D", "Class for evaluating packing moves for 2dimensional problems.")] 30 30 [StorableClass] 31 public class PackingMoveEvaluator2DMCV : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I2DOperator { 31 public class PackingMoveEvaluator2DMCV<T> : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem, T>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I2DOperator 32 where T : class, IItem { 32 33 [StorableConstructor] 33 34 protected PackingMoveEvaluator2DMCV(bool deserializing) : base(deserializing) { } 34 protected PackingMoveEvaluator2DMCV(PackingMoveEvaluator2DMCV original, Cloner cloner)35 protected PackingMoveEvaluator2DMCV(PackingMoveEvaluator2DMCV<T> original, Cloner cloner) 35 36 : base(original, cloner) { 36 37 } 37 38 public override IDeepCloneable Clone(Cloner cloner) { 38 return new PackingMoveEvaluator2DMCV (this, cloner);39 return new PackingMoveEvaluator2DMCV<T>(this, cloner); 39 40 } 40 41 public PackingMoveEvaluator2DMCV() -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluators/PackingMoveEvaluator2DPS.cs
r14049 r14128 29 29 [Item("PackingSequenceMoveEvaluator2D", "Class for evaluating packing moves for 2dimensional problems.")] 30 30 [StorableClass] 31 public class PackingMoveEvaluator2DPS : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I2DOperator { 31 public class PackingMoveEvaluator2DPS<T> : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem, T>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I2DOperator 32 where T : class, IItem { 32 33 [StorableConstructor] 33 34 protected PackingMoveEvaluator2DPS(bool deserializing) : base(deserializing) { } 34 protected PackingMoveEvaluator2DPS(PackingMoveEvaluator2DPS original, Cloner cloner)35 protected PackingMoveEvaluator2DPS(PackingMoveEvaluator2DPS<T> original, Cloner cloner) 35 36 : base(original, cloner) { 36 37 } 37 38 public override IDeepCloneable Clone(Cloner cloner) { 38 return new PackingMoveEvaluator2DPS (this, cloner);39 return new PackingMoveEvaluator2DPS<T>(this, cloner); 39 40 } 40 41 public PackingMoveEvaluator2DPS() -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Problem.cs
r14055 r14128 26 26 using HeuristicLab.PluginInfrastructure; 27 27 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 28 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;29 28 using HeuristicLab.Problems.Instances; 30 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;31 29 using HeuristicLab.Data; 32 using System;33 30 using HeuristicLab.Problems.BinPacking; 34 31 … … 37 34 [StorableClass] 38 35 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 300)] 39 // TODO: only support 2d BPPData40 36 public class Problem : Problem<PackingPosition, PackingShape, PackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> { 41 37 … … 131 127 if (SolutionCreator is PackingSequenceRandomCreator) { 132 128 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DPSDecoder>()); 133 } else if (SolutionCreator is GroupingVectorRandomCreator) {129 } /*else if (SolutionCreator is GroupingVectorRandomCreator) { 134 130 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DGVDecoder>()); 135 131 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 136 132 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DMCVDecoder>()); 137 } else {133 } */ else { 138 134 string error = "The given problem does not support the selected solution-creator."; 139 135 ErrorHandling.ShowErrorDialog(error, null); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/DBL/DeepestBottomLeftPackingSequenceDecoder.cs
r14049 r14128 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;27 26 using HeuristicLab.Problems.BinPacking; 28 27 using HeuristicLab.Encodings.PackingEncoding; 28 using HeuristicLab.Encodings.PermutationEncoding; 29 29 30 30 namespace HeuristicLab.Problems.BinPacking3D { … … 32 32 [StorableClass] 33 33 public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder<PackingPosition, PackingShape, PackingItem>, I3DPSDecoder { 34 public DeepestBottomLeftPackingSequenceDecoder() : base() {}34 public DeepestBottomLeftPackingSequenceDecoder() : base() { } 35 35 [StorableConstructor] 36 36 protected DeepestBottomLeftPackingSequenceDecoder(bool deserializing) : base(deserializing) { } … … 43 43 44 44 public override PackingPlan<PackingPosition, PackingShape, PackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, PackingShape binMeasures, ItemList<PackingItem> itemMeasures) { 45 var solution = encodedSolution as P ackingSequenceEncoding;46 if (solution == null) throw new InvalidOperationException("Encoding is not of type P ackingSequence");45 var solution = encodedSolution as Permutation; 46 if (solution == null) throw new InvalidOperationException("Encoding is not of type Permutation"); 47 47 Solution result = new Solution(binMeasures); 48 48 result.Pack(solution, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/EP/ExtremePointPackingSequenceDecoder3D.cs
r14049 r14128 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Common; 27 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;28 27 using HeuristicLab.Problems.BinPacking; 29 28 using HeuristicLab.Encodings.PackingEncoding; 29 using HeuristicLab.Encodings.PermutationEncoding; 30 30 31 31 namespace HeuristicLab.Problems.BinPacking3D { … … 45 45 46 46 public override PackingPlan<PackingPosition, PackingShape, PackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, PackingShape binMeasures, ItemList<PackingItem> itemMeasures) { 47 var solution = encodedSolution as P ackingSequenceEncoding;48 if (solution == null) throw new InvalidOperationException("Encoding is not of type P ackingSequence");47 var solution = encodedSolution as Permutation; 48 if (solution == null) throw new InvalidOperationException("Encoding is not of type Permutation"); 49 49 Solution result = new Solution(binMeasures, true, StackingConstraintsParameter.Value.Value); 50 50 result.Pack(solution, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/HeuristicLab.Problems.BinPacking3D-3.3.csproj
r14062 r14128 166 166 <Compile Include="DecoderInterfaces\I3DMCVDecoder.cs" /> 167 167 <Compile Include="DecoderInterfaces\I3DPSDecoder.cs" /> 168 <Compile Include="Decoders\DBL\DeepestBottomLeftGroupingVectorDecoder.cs" />169 <Compile Include="Decoders\DBL\DeepestBottomLeftMultiComponentVectorDecoder.cs" />170 168 <Compile Include="Decoders\DBL\DeepestBottomLeftPackingSequenceDecoder.cs" /> 171 <Compile Include="Decoders\EP\ExtremePointGroupingVectorDecoder3D.cs" />172 <Compile Include="Decoders\EP\ExtremePointMultiComponentVectorDecoder3D.cs" />173 169 <Compile Include="Decoders\EP\ExtremePointPackingSequenceDecoder3D.cs" /> 174 170 <Compile Include="I3DOperator.cs" /> … … 184 180 <Compile Include="PackingShape.cs" /> 185 181 <Compile Include="Plugin.cs" /> 186 <Compile Include="Problem.cs" />187 182 <Compile Include="Properties\AssemblyInfo.cs" /> 188 183 <Compile Include="Solution.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/MoveEvaluators/PackingMoveEvaluator3DGV.cs
r14049 r14128 30 30 [Item("GroupingVectorMoveEvaluator3D", "Class for evaluating packing moves for 3dimensional problems.")] 31 31 [StorableClass] 32 public class PackingMoveEvaluator3DGV : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I3DOperator { 32 public class PackingMoveEvaluator3DGV<M> : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem, M>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I3DOperator 33 where M: class, IItem { 33 34 [StorableConstructor] 34 35 protected PackingMoveEvaluator3DGV(bool deserializing) : base(deserializing) { } 35 protected PackingMoveEvaluator3DGV(PackingMoveEvaluator3DGV original, Cloner cloner)36 protected PackingMoveEvaluator3DGV(PackingMoveEvaluator3DGV<M> original, Cloner cloner) 36 37 : base(original, cloner) { 37 38 } 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 return new PackingMoveEvaluator3DGV (this, cloner);40 return new PackingMoveEvaluator3DGV<M>(this, cloner); 40 41 } 41 42 public PackingMoveEvaluator3DGV() -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/MoveEvaluators/PackingMoveEvaluator3DMCV.cs
r14049 r14128 30 30 [Item("MultiComponentVectorMoveEvaluator3D", "Class for evaluating packing moves for 3dimensional problems.")] 31 31 [StorableClass] 32 public class PackingMoveEvaluator3DMCV : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I3DOperator { 32 public class PackingMoveEvaluator3DMCV<M> : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem, M>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I3DOperator 33 where M : class, IItem { 33 34 [StorableConstructor] 34 35 protected PackingMoveEvaluator3DMCV(bool deserializing) : base(deserializing) { } 35 protected PackingMoveEvaluator3DMCV(PackingMoveEvaluator3DMCV original, Cloner cloner)36 protected PackingMoveEvaluator3DMCV(PackingMoveEvaluator3DMCV<M> original, Cloner cloner) 36 37 : base(original, cloner) { 37 38 } 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 return new PackingMoveEvaluator3DMCV (this, cloner);40 return new PackingMoveEvaluator3DMCV<M>(this, cloner); 40 41 } 41 42 public PackingMoveEvaluator3DMCV() -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/MoveEvaluators/PackingMoveEvaluator3DPS.cs
r14049 r14128 30 30 [Item("PackingSequenceMoveEvaluator3D", "Class for evaluating packing moves for 3dimensional problems.")] 31 31 [StorableClass] 32 public class PackingMoveEvaluator3DPS : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I3DOperator { 32 public class PackingMoveEvaluator3DPS<M> : PackingMoveEvaluator<PackingPosition, PackingShape, PackingItem, M>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I3DOperator 33 where M : class, IItem { 33 34 [StorableConstructor] 34 35 protected PackingMoveEvaluator3DPS(bool deserializing) : base(deserializing) { } 35 protected PackingMoveEvaluator3DPS(PackingMoveEvaluator3DPS original, Cloner cloner)36 protected PackingMoveEvaluator3DPS(PackingMoveEvaluator3DPS<M> original, Cloner cloner) 36 37 : base(original, cloner) { 37 38 } 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 return new PackingMoveEvaluator3DPS (this, cloner);40 return new PackingMoveEvaluator3DPS<M>(this, cloner); 40 41 } 41 42 public PackingMoveEvaluator3DPS() -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Problem.cs
r14055 r14128 26 26 using HeuristicLab.Encodings.PermutationEncoding; 27 27 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 28 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;29 28 using HeuristicLab.Problems.Instances; 30 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;31 29 using HeuristicLab.PluginInfrastructure; 32 30 using HeuristicLab.Data; … … 131 129 if (SolutionCreator is PackingSequenceRandomCreator) { 132 130 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DPSDecoder>()); 133 } else if (SolutionCreator is GroupingVectorRandomCreator) {131 } /* else if (SolutionCreator is GroupingVectorRandomCreator) { 134 132 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DGVDecoder>()); 135 133 } else if (SolutionCreator is MultiComponentVectorRandomCreator) { 136 134 PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DMCVDecoder>()); 137 } else {135 } */ else { 138 136 string error = "The given problem does not support the selected solution-creator."; 139 137 ErrorHandling.ShowErrorDialog(error, null); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/HeuristicLab.Problems.BinPacking.Views-3.3.csproj
r14038 r14128 108 108 </PropertyGroup> 109 109 <ItemGroup> 110 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 111 <Private>False</Private> 112 </Reference> 113 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 114 <Private>False</Private> 115 </Reference> 116 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 117 <Private>False</Private> 118 </Reference> 119 <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 120 <Private>False</Private> 121 </Reference> 122 <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 123 <Private>False</Private> 124 </Reference> 125 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 126 <Private>False</Private> 127 </Reference> 128 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 129 <Private>False</Private> 130 </Reference> 131 <Reference Include="HeuristicLab.Optimization.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 132 <Private>False</Private> 133 </Reference> 134 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 135 <Private>False</Private> 110 <Reference Include="HeuristicLab.Collections-3.3"> 111 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> 112 </Reference> 113 <Reference Include="HeuristicLab.Common-3.3"> 114 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 115 </Reference> 116 <Reference Include="HeuristicLab.Core-3.3"> 117 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 118 </Reference> 119 <Reference Include="HeuristicLab.Core.Views-3.3"> 120 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath> 121 </Reference> 122 <Reference Include="HeuristicLab.Data.Views-3.3"> 123 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data.Views-3.3.dll</HintPath> 124 </Reference> 125 <Reference Include="HeuristicLab.MainForm-3.3"> 126 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath> 127 </Reference> 128 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3"> 129 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath> 130 </Reference> 131 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 132 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 136 133 </Reference> 137 134 <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> … … 177 174 </ItemGroup> 178 175 <ItemGroup> 176 <EmbeddedResource Include="PackingPlan2DView.resx"> 177 <DependentUpon>PackingPlan2DView.cs</DependentUpon> 178 </EmbeddedResource> 179 <EmbeddedResource Include="PackingPlan3DView.resx"> 180 <DependentUpon>PackingPlan3DView.cs</DependentUpon> 181 </EmbeddedResource> 182 </ItemGroup> 183 <ItemGroup> 184 <Page Include="Container3DView.xaml"> 185 <Generator>MSBuild:Compile</Generator> 186 <SubType>Designer</SubType> 187 </Page> 188 <Page Include="Container2DView.xaml"> 189 <Generator>MSBuild:Compile</Generator> 190 <SubType>Designer</SubType> 191 </Page> 192 </ItemGroup> 193 <ItemGroup> 179 194 <ProjectReference Include="..\..\HeuristicLab.Problems.BinPacking.2D\3.3\HeuristicLab.Problems.BinPacking2D-3.3.csproj"> 180 195 <Project>{56dd7f51-3164-4c26-a97a-add6fe4b4e86}</Project> … … 186 201 </ProjectReference> 187 202 <ProjectReference Include="..\..\HeuristicLab.Problems.BinPacking\3.3\HeuristicLab.Problems.BinPacking-3.3.csproj"> 188 <Project>{ F8A55094-3CD5-4034-B0CA-5BD7FFB016D4}</Project>203 <Project>{f8a55094-3cd5-4034-b0ca-5bd7ffb016d4}</Project> 189 204 <Name>HeuristicLab.Problems.BinPacking-3.3</Name> 190 <Private>False</Private>191 205 </ProjectReference> 192 </ItemGroup>193 <ItemGroup>194 <EmbeddedResource Include="PackingPlan2DView.resx">195 <DependentUpon>PackingPlan2DView.cs</DependentUpon>196 </EmbeddedResource>197 <EmbeddedResource Include="PackingPlan3DView.resx">198 <DependentUpon>PackingPlan3DView.cs</DependentUpon>199 </EmbeddedResource>200 </ItemGroup>201 <ItemGroup>202 <Page Include="Container3DView.xaml">203 <Generator>MSBuild:Compile</Generator>204 <SubType>Designer</SubType>205 </Page>206 <Page Include="Container2DView.xaml">207 <Generator>MSBuild:Compile</Generator>208 <SubType>Designer</SubType>209 </Page>210 206 </ItemGroup> 211 207 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs
r14050 r14128 93 93 } 94 94 string binUtilKey = "Overall Bin Utilization"; 95 DoubleValue binUtil = BinUtilizationEvaluator<D, B, I>.CalculateBinUtilization(bestSolution);95 var binUtil = new DoubleValue(BinUtilizationEvaluator<D, B, I>.CalculateBinUtilization(bestSolution)); 96 96 if (!results.ContainsKey(binUtilKey)) 97 97 results.Add(new Result(binUtilKey, binUtil)); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r14048 r14128 40 40 41 41 [Storable] 42 public ObservableDictionary<int, I> ItemMeasures { get; private set; } // TODO: rename d to item42 public ObservableDictionary<int, I> ItemMeasures { get; private set; } // TODO: rename to items 43 43 44 44 [Storable] 45 public B BinMeasures { get; private set; } 45 public B BinMeasures { get; private set; } 46 46 47 47 [Storable] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r14050 r14128 28 28 using HeuristicLab.Data; 29 29 using HeuristicLab.Collections; 30 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;31 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;32 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;33 30 using HeuristicLab.Encodings.IntegerVectorEncoding; 34 31 using HeuristicLab.Problems.BinPacking; 32 using HeuristicLab.Encodings.PermutationEncoding; 35 33 36 34 namespace HeuristicLab.Encodings.PackingEncoding { … … 98 96 } 99 97 98 /* 100 99 public void Pack(MultiComponentVectorEncoding solution, ItemList<I> itemMeasures) { 101 100 var sequenceMatrix = solution.GenerateSequenceMatrix(); … … 197 196 solution.GroupingVector = new IntegerVector(newSolution); 198 197 } 199 public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) { 200 List<int> remainingIDs = new List<int>(solution.PackingSequence); 198 * 199 200 public void Pack(Permutation solution, ItemList<I> itemMeasures) { 201 List<int> remainingIDs = new List<int>(solution); 201 202 while (remainingIDs.Count > 0) { 202 203 var bp = NewBinPacking(); … … 210 211 } 211 212 212 213 */ 213 214 #region Events 214 215 public event EventHandler QualityChanged; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Encoding.cs
r14064 r14128 6 6 using HeuristicLab.Common; 7 7 using HeuristicLab.Core; 8 using HeuristicLab.Encodings.PermutationEncoding; 8 9 using HeuristicLab.Optimization; 9 10 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 13 14 namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence { 14 15 [StorableClass] 15 internal class Encoding : HeuristicLab.Optimization.Encoding<PackingSolutionCreator> {16 public class Encoding : HeuristicLab.Optimization.Encoding<IPackingSolutionCreator> { 16 17 [StorableConstructor] 17 18 private Encoding(bool deserializing) : base(deserializing) { } 18 public Encoding() : base("PackingSequence") { 19 public Encoding() 20 : base("PackingSequence") { 19 21 SolutionCreator = new PackingSequenceRandomCreator(); 20 22 RegisterParameterEvents(); … … 64 66 65 67 public static class IndividualExtensionMethods { 66 public static P ackingSequencePackingSequence(this Individual individual) {68 public static Permutation PackingSequence(this Individual individual) { 67 69 var encoding = individual.GetEncoding<Encoding>(); 68 70 return individual.PackingSequence(encoding.Name); 69 71 } 70 72 71 public static P ackingSequencePackingSequence(this Individual individual, string name) {72 return (P ackingSequence)individual[name];73 public static Permutation PackingSequence(this Individual individual, string name) { 74 return (Permutation)individual[name]; 73 75 } 74 76 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/IPackingSequenceCreator.cs
r14064 r14128 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.PermutationEncoding; 25 26 using HeuristicLab.Optimization; 26 27 using HeuristicLab.Problems.BinPacking; … … 28 29 namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence { 29 30 interface IPackingSequenceCreator : ISolutionCreator, IPackingSequenceOperator { 30 IValueLookupParameter<IntValue> PackingItemsParameter { get; } 31 ILookupParameter<PackingSequence> SolutionParameter { get; } 32 31 ILookupParameter<IntValue> NumberOfPackingItemsParameter { get; } 32 ILookupParameter<Permutation> SolutionParameter { get; } 33 33 } 34 34 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/GroupingMoveHardTabuCriterion.cs
r14046 r14128 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Operators; 27 28 using HeuristicLab.Optimization; … … 37 38 get { return false; } 38 39 } 39 public ILookupParameter<IPackingMove > PackingMoveParameter {40 get { return (ILookupParameter<IPackingMove >)Parameters["PackingMove"]; }40 public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter { 41 get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; } 41 42 } 42 public ILookupParameter<P ackingSequenceEncoding> PackingSequenceParameter {43 get { return (ILookupParameter<P ackingSequenceEncoding>)Parameters["PackingSequence"]; }43 public ILookupParameter<Permutation> PackingSequenceParameter { 44 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 44 45 } 45 46 public ILookupParameter<ItemList<IItem>> TabuListParameter { … … 64 65 public SequenceMoveHardTabuCriterion() 65 66 : base() { 66 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The move to evaluate."));67 Parameters.Add(new LookupParameter<P ackingSequenceEncoding>("PackingSequence", "The solutionto evaluate."));67 Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate.")); 68 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution candidate to evaluate.")); 68 69 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); 69 70 Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list.")); … … 80 81 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 81 82 SequenceMove move = PackingMoveParameter.ActualValue as SequenceMove; 82 PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;83 int length = PackingSequence.PackingSequence.Length;84 83 double moveQuality = MoveQualityParameter.ActualValue.Value; 85 84 bool maximization = MaximizationParameter.ActualValue.Value; 86 85 bool useAspiration = UseAspirationCriterionParameter.Value.Value; 87 bool isTabu = IsMoveTabu(tabuList, move, PackingSequence,moveQuality, maximization, useAspiration);86 bool isTabu = IsMoveTabu(tabuList, move, moveQuality, maximization, useAspiration); 88 87 89 88 MoveTabuParameter.ActualValue = new BoolValue(isTabu); … … 91 90 } 92 91 93 private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, PackingSequenceEncoding PackingSequence,double moveQuality, bool maximization, bool useAspiration) {92 private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, double moveQuality, bool maximization, bool useAspiration) { 94 93 bool isTabu = false; 95 var attributes = tabuList.FindAll(ta => ta.GetType() .Equals(move.GetMoveAttributeType()));94 var attributes = tabuList.FindAll(ta => ta.GetType() == move.GetMoveAttributeType()); 96 95 97 96 foreach (IItem attr in attributes) { … … 102 101 || !maximization && moveQuality >= gvAttr.MoveQuality)) { 103 102 104 isTabu = move.BelongsToAttribute(gvAttr, true); 103 isTabu = move.BelongsToAttribute(gvAttr, true); // only difference to soft tabu criterion 105 104 } 106 105 if (isTabu) break; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/GroupingMoveMaker.cs
r14046 r14128 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Operators; 27 28 using HeuristicLab.Optimization; … … 43 44 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 44 45 } 45 public ILookupParameter<IPackingMove > PackingMoveParameter {46 get { return (ILookupParameter<IPackingMove >)Parameters["PackingMove"]; }46 public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter { 47 get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; } 47 48 } 48 public ILookupParameter<P ackingSequenceEncoding> PackingSequenceParameter {49 get { return (ILookupParameter<P ackingSequenceEncoding>)Parameters["PackingSequence"]; }49 public ILookupParameter<Permutation> PackingSequenceParameter { 50 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 50 51 } 51 52 public ILookupParameter<IPackingPlan> PackingPlanParameter { … … 62 63 : base() { 63 64 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution.")); 64 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The move to evaluate."));65 Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate.")); 65 66 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 66 Parameters.Add(new LookupParameter<P ackingSequenceEncoding>("PackingSequence", "The solution as Sequence vector."));67 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution as Sequence vector.")); 67 68 Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlan", "The currently best performing, decoded bin-packing solution represented as generalized packing-plan.")); 68 69 Parameters.Add(new LookupParameter<IPackingPlan>("PackingPlanAfterMove", "The moved and decoded bin-packing solution represented as generalized packing-plan.")); … … 74 75 75 76 public override IOperation Apply() { 76 IPackingMove move = PackingMoveParameter.ActualValue;77 PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;78 77 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 79 78 DoubleValue quality = QualityParameter.ActualValue; 80 79 81 PackingSequence.PackingSequence = (move.GetSolutionAfterMove() as PackingSequenceEncoding).PackingSequence;82 80 PackingPlanParameter.ActualValue = PackingPlanAfterMoveParameter.ActualValue; 83 81 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/GroupingMoveSoftTabuCriterion.cs
r14046 r14128 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Operators; 27 28 using HeuristicLab.Optimization; … … 38 39 get { return false; } 39 40 } 40 public ILookupParameter<IPackingMove > PackingMoveParameter {41 get { return (ILookupParameter<IPackingMove >)Parameters["PackingMove"]; }41 public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter { 42 get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; } 42 43 } 43 public ILookupParameter<P ackingSequenceEncoding> PackingSequenceParameter {44 get { return (ILookupParameter<P ackingSequenceEncoding>)Parameters["PackingSequence"]; }44 public ILookupParameter<Permutation> PackingSequenceParameter { 45 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 45 46 } 46 47 public ILookupParameter<ItemList<IItem>> TabuListParameter { … … 65 66 public SequenceMoveSoftTabuCriterion() 66 67 : base() { 67 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The move to evaluate."));68 Parameters.Add(new LookupParameter<P ackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));68 Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate.")); 69 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution to evaluate.")); 69 70 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); 70 71 Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list.")); … … 81 82 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 82 83 SequenceMove move = PackingMoveParameter.ActualValue as SequenceMove; 83 PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;84 int length = PackingSequence.PackingSequence.Length;85 84 double moveQuality = MoveQualityParameter.ActualValue.Value; 86 bool maximization = MaximizationParameter.ActualValue.Value; 85 bool maximization = MaximizationParameter.ActualValue.Value; 87 86 bool useAspiration = UseAspirationCriterionParameter.Value.Value; 88 bool isTabu = IsMoveTabu(tabuList, move, PackingSequence,moveQuality, maximization, useAspiration);87 bool isTabu = IsMoveTabu(tabuList, move, moveQuality, maximization, useAspiration); 89 88 90 89 MoveTabuParameter.ActualValue = new BoolValue(isTabu); … … 92 91 } 93 92 94 private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, PackingSequenceEncoding PackingSequence,double moveQuality, bool maximization, bool useAspiration) {93 private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, double moveQuality, bool maximization, bool useAspiration) { 95 94 bool isTabu = false; 96 var attributes = tabuList.FindAll(ta => ta.GetType() .Equals(move.GetMoveAttributeType()));95 var attributes = tabuList.FindAll(ta => ta.GetType() == move.GetMoveAttributeType()); 97 96 98 97 foreach (IItem attr in attributes) { … … 103 102 || !maximization && moveQuality >= gvAttr.MoveQuality)) { 104 103 105 isTabu = move.BelongsToAttribute(gvAttr, false); 104 isTabu = move.BelongsToAttribute(gvAttr, false); // only difference to hard tabu criterion 106 105 } 107 106 if (isTabu) break; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/ExhaustiveInsertionMoveGenerator.cs
r13032 r14128 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 39 40 return new ExhaustiveInsertionMoveGenerator(this, cloner); 40 41 } 41 public static IEnumerable<InsertionMove> Generate(P ackingSequenceEncoding PackingSequence, int nrOfBins) {42 for (int i = 0; i < PackingSequence.PackingSequence.Length - 1; i++)43 for (int j = i + 1; j < PackingSequence.PackingSequence.Length; j++) {42 public static IEnumerable<InsertionMove> Generate(Permutation packingSequence, int nrOfBins) { 43 for (int i = 0; i < packingSequence.Length - 1; i++) 44 for (int j = i + 1; j < packingSequence.Length; j++) { 44 45 if (j != i) 45 yield return new InsertionMove(i, j, PackingSequence);46 yield return new InsertionMove(i, j, packingSequence); 46 47 } 47 48 } 48 49 49 public static InsertionMove[] Apply(P ackingSequenceEncoding PackingSequence) {50 public static InsertionMove[] Apply(Permutation packingSequence) { 50 51 int nrOfBins = 0; 51 foreach (int binNr in PackingSequence.PackingSequence) {52 foreach (int binNr in packingSequence) { 52 53 if (binNr > nrOfBins) 53 54 nrOfBins = binNr; … … 55 56 nrOfBins++; 56 57 57 int totalMoves = ( PackingSequence.PackingSequence.Length * (PackingSequence.PackingSequence.Length - 1)) / 2;58 int totalMoves = (packingSequence.Length * (packingSequence.Length - 1)) / 2; 58 59 InsertionMove[] moves = new InsertionMove[totalMoves]; 59 60 int count = 0; 60 foreach (InsertionMove move in Generate( PackingSequence, nrOfBins)) {61 foreach (InsertionMove move in Generate(packingSequence, nrOfBins)) { 61 62 moves[count++] = move; 62 63 } … … 64 65 } 65 66 66 protected override InsertionMove[] GenerateMoves(P ackingSequenceEncoding PackingSequence) {67 return Apply( PackingSequence);67 protected override InsertionMove[] GenerateMoves(Permutation packingSequence) { 68 return Apply(packingSequence); 68 69 } 69 70 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/InsertionMove.cs
r14046 r14128 32 32 [Item("Insertion Move", "A move on a Sequence vector that is specified by two group-assignment-indexes.")] 33 33 [StorableClass] 34 public class InsertionMove : SequenceMove , IPackingMove{34 public class InsertionMove : SequenceMove { 35 35 [Storable] 36 36 public int Index1 { get; protected set; } … … 45 45 this.Index2 = original.Index2; 46 46 } 47 public InsertionMove(int index1, int index2, P ackingSequenceEncoding PackingSequence)48 : base( PackingSequence) {47 public InsertionMove(int index1, int index2, Permutation packingSequence) 48 : base(packingSequence) { 49 49 Index1 = index1; 50 50 Index2 = index2; … … 55 55 } 56 56 57 public override IPackingSolutionEncoding GetSolutionAfterMove() { 58 PackingSequenceEncoding newSolution = new PackingSequenceEncoding(); 59 60 Permutation original = PackingSequence.PackingSequence; 61 Permutation resultingPermutation = (Permutation)PackingSequence.PackingSequence.Clone(); 57 public override Permutation GetSolutionAfterMove() { 58 Permutation original = PackingSequence; 59 Permutation resultingPermutation = (Permutation)PackingSequence.Clone(); 62 60 int cutIndex, insertIndex, number; 63 61 … … 68 66 int i = 0; // index in new permutation 69 67 int j = 0; // index in old permutation 70 while (i < PackingSequence. PackingSequence.Length) {68 while (i < PackingSequence.Length) { 71 69 if (j == cutIndex) { 72 70 j++; … … 83 81 } 84 82 85 newSolution.PackingSequence = resultingPermutation; 86 return newSolution; 83 return resultingPermutation; 87 84 } 88 85 … … 92 89 93 90 public override SequenceMoveAttribute GetAttribute(double quality) { 94 return new InsertionMoveAttribute(Index1, Index2, PackingSequence .PackingSequence[Index1], PackingSequence.PackingSequence[Index2], quality);91 return new InsertionMoveAttribute(Index1, Index2, PackingSequence[Index1], PackingSequence[Index2], quality); 95 92 } 96 93 … … 103 100 } else 104 101 if (Index1 == attr.Index1 && Index2 == attr.Index2) 105 return true;102 return true; 106 103 } 107 104 return false; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/InsertionMoveGenerator.cs
r14046 r14128 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.PermutationEncoding; 25 26 using HeuristicLab.Operators; 26 27 using HeuristicLab.Optimization; … … 37 38 get { return false; } 38 39 } 39 public ILookupParameter<P ackingSequenceEncoding> PackingSequenceParameter {40 get { return (ILookupParameter<P ackingSequenceEncoding>)Parameters["PackingSequence"]; }40 public ILookupParameter<Permutation> PackingSequenceParameter { 41 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 41 42 } 42 public ILookupParameter<IPackingMove > PackingMoveParameter {43 get { return (LookupParameter<IPackingMove >)Parameters["PackingMove"]; }43 public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter { 44 get { return (LookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; } 44 45 } 45 46 protected ScopeParameter CurrentScopeParameter { … … 52 53 public InsertionMoveGenerator() 53 54 : base() { 54 Parameters.Add(new LookupParameter<P ackingSequenceEncoding>("PackingSequence", "The Sequence vector for which moves should be generated."));55 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The moves that should be generated in subscopes."));55 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The Sequence vector for which moves should be generated.")); 56 Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The moves that should be generated in subscopes.")); 56 57 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 57 58 } 58 59 59 60 public override IOperation Apply() { 60 P ackingSequenceEncodingps = PackingSequenceParameter.ActualValue;61 Permutation ps = PackingSequenceParameter.ActualValue; 61 62 InsertionMove[] moves = GenerateMoves(ps); 62 63 Scope[] moveScopes = new Scope[moves.Length]; … … 69 70 } 70 71 71 protected abstract InsertionMove[] GenerateMoves(P ackingSequenceEncoding PackingSequence);72 protected abstract InsertionMove[] GenerateMoves(Permutation packingSequence); 72 73 } 73 74 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/StochasticInsertionMoveGenerator.cs
r13032 r14128 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.PermutationEncoding; 27 28 using HeuristicLab.Optimization; 28 29 using HeuristicLab.Parameters; … … 58 59 } 59 60 60 public static InsertionMove[] Apply(P ackingSequenceEncoding PackingSequence, IRandom random, int sampleSize) {61 public static InsertionMove[] Apply(Permutation packingSequence, IRandom random, int sampleSize) { 61 62 62 63 int nrOfBins = 0; 63 foreach (int binNr in PackingSequence.PackingSequence) {64 foreach (int binNr in packingSequence) { 64 65 if (binNr > nrOfBins) 65 66 nrOfBins = binNr; … … 67 68 nrOfBins++; 68 69 var generatedMoves = new List<InsertionMove>(); 69 var moves = new List<InsertionMove>(ExhaustiveInsertionMoveGenerator.Generate( PackingSequence, nrOfBins));70 var moves = new List<InsertionMove>(ExhaustiveInsertionMoveGenerator.Generate(packingSequence, nrOfBins)); 70 71 int moveCount = moves.Count; 71 72 for (int i = 0; i < sampleSize; i++) { … … 76 77 } 77 78 78 protected override InsertionMove[] GenerateMoves(P ackingSequenceEncoding SwapSequence) {79 protected override InsertionMove[] GenerateMoves(Permutation packingSequence) { 79 80 IRandom random = RandomParameter.ActualValue; 80 return Apply( SwapSequence, random, SampleSizeParameter.ActualValue.Value);81 return Apply(packingSequence, random, SampleSizeParameter.ActualValue.Value); 81 82 } 82 83 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/SequenceMove.cs
r14046 r14128 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 using HeuristicLab.Problems.BinPacking; 28 29 29 30 namespace HeuristicLab.Encodings.PackingEncoding.PackingSequence { 30 [Item("SequenceMove", "An abstract move for a packing Sequence encoded solution.")]31 [Item("SequenceMove", "An abstract move for a packing sequence encoded solution.")] 31 32 [StorableClass] 32 public abstract class SequenceMove : Item, IPackingMove {33 public abstract class SequenceMove : Item, IPackingMove<Permutation> { 33 34 [Storable] 34 public P ackingSequenceEncodingPackingSequence { get; protected set; }35 public Permutation PackingSequence { get; protected set; } 35 36 36 37 [StorableConstructor] … … 41 42 this.PackingSequence = cloner.Clone(original.PackingSequence); 42 43 } 43 public SequenceMove(P ackingSequenceEncodingpackingSequence)44 public SequenceMove(Permutation packingSequence) 44 45 : base() { 45 46 PackingSequence = packingSequence; 46 47 } 47 48 48 public abstract IPackingSolutionEncodingGetSolutionAfterMove();49 public abstract Permutation GetSolutionAfterMove(); 49 50 public abstract Type GetMoveAttributeType(); 50 51 public abstract SequenceMoveAttribute GetAttribute(double quality); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/SequenceTabuMaker.cs
r14046 r14128 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.PermutationEncoding; 25 26 using HeuristicLab.Optimization.Operators; 26 27 using HeuristicLab.Parameters; … … 32 33 [StorableClass] 33 34 public class SequenceTabuMaker : TabuMaker, IPackingSequenceMoveOperator { 34 public ILookupParameter<IPackingMove > PackingMoveParameter {35 get { return (ILookupParameter<IPackingMove >)Parameters["PackingMove"]; }35 public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter { 36 get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; } 36 37 } 37 public ILookupParameter<P ackingSequenceEncoding> PackingSequenceParameter {38 get { return (ILookupParameter<P ackingSequenceEncoding>)Parameters["PackingSequence"]; }38 public ILookupParameter<Permutation> PackingSequenceParameter { 39 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 39 40 } 40 41 … … 44 45 public SequenceTabuMaker() 45 46 : base() { 46 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The move to evaluate."));47 Parameters.Add(new LookupParameter<P ackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));47 Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate.")); 48 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution to evaluate.")); 48 49 } 49 50 … … 53 54 54 55 protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) { 55 IPackingMove move = PackingMoveParameter.ActualValue; 56 PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue; 56 var move = PackingMoveParameter.ActualValue; 57 57 double baseQuality = moveQuality; 58 58 if (maximization && quality > moveQuality || !maximization && quality < moveQuality) -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/ExhaustiveSwap2MoveGenerator.cs
r13032 r14128 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 39 40 return new ExhaustiveSwap2MoveGenerator(this, cloner); 40 41 } 41 public static IEnumerable<Swap2Move> Generate(P ackingSequenceEncoding PackingSequence, int nrOfBins) {42 for (int i = 0; i < PackingSequence.PackingSequence.Length - 1; i++)43 for (int j = i + 1; j < PackingSequence.PackingSequence.Length; j++) {42 public static IEnumerable<Swap2Move> Generate(Permutation packingSequence, int nrOfBins) { 43 for (int i = 0; i < packingSequence.Length - 1; i++) 44 for (int j = i + 1; j < packingSequence.Length; j++) { 44 45 if (j != i) 45 yield return new Swap2Move(i, j, PackingSequence);46 yield return new Swap2Move(i, j, packingSequence); 46 47 } 47 48 } 48 49 49 public static Swap2Move[] Apply(P ackingSequenceEncoding PackingSequence) {50 public static Swap2Move[] Apply(Permutation packingSequence) { 50 51 int nrOfBins = 0; 51 foreach (int binNr in PackingSequence.PackingSequence) {52 foreach (int binNr in packingSequence) { 52 53 if (binNr > nrOfBins) 53 54 nrOfBins = binNr; … … 55 56 nrOfBins++; 56 57 57 int totalMoves = ( PackingSequence.PackingSequence.Length * (PackingSequence.PackingSequence.Length - 1)) / 2;58 int totalMoves = (packingSequence.Length * (packingSequence.Length - 1)) / 2; 58 59 Swap2Move[] moves = new Swap2Move[totalMoves]; 59 60 int count = 0; 60 foreach (Swap2Move move in Generate( PackingSequence, nrOfBins)) {61 foreach (Swap2Move move in Generate(packingSequence, nrOfBins)) { 61 62 moves[count++] = move; 62 63 } … … 64 65 } 65 66 66 protected override Swap2Move[] GenerateMoves(P ackingSequenceEncoding PackingSequence) {67 return Apply( PackingSequence);67 protected override Swap2Move[] GenerateMoves(Permutation packingSequence) { 68 return Apply(packingSequence); 68 69 } 69 70 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/StochasticSwap2MoveGenerator.cs
r13032 r14128 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.PermutationEncoding; 27 28 using HeuristicLab.Optimization; 28 29 using HeuristicLab.Parameters; … … 58 59 } 59 60 60 public static Swap2Move[] Apply(P ackingSequenceEncoding PackingSequence, IRandom random, int sampleSize) {61 public static Swap2Move[] Apply(Permutation packingSequence, IRandom random, int sampleSize) { 61 62 62 63 int nrOfBins = 0; 63 foreach (int binNr in PackingSequence.PackingSequence) {64 foreach (int binNr in packingSequence) { 64 65 if (binNr > nrOfBins) 65 66 nrOfBins = binNr; … … 67 68 nrOfBins++; 68 69 var generatedMoves = new List<Swap2Move>(); 69 var moves = new List<Swap2Move>(ExhaustiveSwap2MoveGenerator.Generate( PackingSequence, nrOfBins));70 var moves = new List<Swap2Move>(ExhaustiveSwap2MoveGenerator.Generate(packingSequence, nrOfBins)); 70 71 int moveCount = moves.Count; 71 72 for (int i = 0; i < sampleSize; i++) { … … 76 77 } 77 78 78 protected override Swap2Move[] GenerateMoves(P ackingSequenceEncoding SwapSequence) {79 protected override Swap2Move[] GenerateMoves(Permutation packingSequence) { 79 80 IRandom random = RandomParameter.ActualValue; 80 return Apply( SwapSequence, random, SampleSizeParameter.ActualValue.Value);81 return Apply(packingSequence, random, SampleSizeParameter.ActualValue.Value); 81 82 } 82 83 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/Swap2Move.cs
r14046 r14128 32 32 [Item("Swap2 Move", "A move on a Sequence vector that is specified by two group-assignment-indexes.")] 33 33 [StorableClass] 34 public class Swap2Move : SequenceMove, IPackingMove {34 public class Swap2Move : SequenceMove, IPackingMove<Permutation> { 35 35 [Storable] 36 36 public int Index1 { get; protected set; } … … 45 45 this.Index2 = original.Index2; 46 46 } 47 public Swap2Move(int index1, int index2, P ackingSequenceEncoding PackingSequence)48 : base( PackingSequence) {47 public Swap2Move(int index1, int index2, Permutation packingSequence) 48 : base(packingSequence) { 49 49 Index1 = index1; 50 50 Index2 = index2; … … 55 55 } 56 56 57 public override IPackingSolutionEncoding GetSolutionAfterMove() { 58 PackingSequenceEncoding newSolution = new PackingSequenceEncoding(); 59 newSolution.PackingSequence = (Permutation)PackingSequence.PackingSequence.Clone(new Cloner()); 60 newSolution.PackingSequence[Index1] = PackingSequence.PackingSequence[Index2]; 61 newSolution.PackingSequence[Index2] = PackingSequence.PackingSequence[Index1]; 57 public override Permutation GetSolutionAfterMove() { 58 Permutation newSolution = (Permutation)PackingSequence.Clone(new Cloner()); 59 newSolution[Index1] = PackingSequence[Index2]; 60 newSolution[Index2] = PackingSequence[Index1]; 62 61 return newSolution; 63 62 } … … 68 67 69 68 public override SequenceMoveAttribute GetAttribute(double quality) { 70 return new Swap2MoveAttribute(Index1, Index2, PackingSequence .PackingSequence[Index1], PackingSequence.PackingSequence[Index2], quality);69 return new Swap2MoveAttribute(Index1, Index2, PackingSequence[Index1], PackingSequence[Index2], quality); 71 70 } 72 71 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Swap2/Swap2MoveGenerator.cs
r14046 r14128 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.PermutationEncoding; 25 26 using HeuristicLab.Operators; 26 27 using HeuristicLab.Optimization; … … 36 37 get { return false; } 37 38 } 38 public ILookupParameter<P ackingSequenceEncoding> PackingSequenceParameter {39 get { return (ILookupParameter<P ackingSequenceEncoding>)Parameters["PackingSequence"]; }39 public ILookupParameter<Permutation> PackingSequenceParameter { 40 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 40 41 } 41 public ILookupParameter<IPackingMove > PackingMoveParameter {42 get { return (LookupParameter<IPackingMove >)Parameters["PackingMove"]; }42 public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter { 43 get { return (LookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; } 43 44 } 44 45 protected ScopeParameter CurrentScopeParameter { … … 51 52 public Swap2MoveGenerator() 52 53 : base() { 53 Parameters.Add(new LookupParameter<P ackingSequenceEncoding>("PackingSequence", "The Sequence vector for which moves should be generated."));54 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The moves that should be generated in subscopes."));54 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The Sequence vector for which moves should be generated.")); 55 Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The moves that should be generated in subscopes.")); 55 56 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 56 57 } 57 58 58 59 public override IOperation Apply() { 59 P ackingSequenceEncodingps = PackingSequenceParameter.ActualValue;60 Permutation ps = PackingSequenceParameter.ActualValue; 60 61 Swap2Move[] moves = GenerateMoves(ps); 61 62 Scope[] moveScopes = new Scope[moves.Length]; … … 68 69 } 69 70 70 protected abstract Swap2Move[] GenerateMoves(P ackingSequenceEncoding PackingSequence);71 protected abstract Swap2Move[] GenerateMoves(Permutation packingSequence); 71 72 } 72 73 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceCrossover.cs
r14046 r14128 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.PermutationEncoding; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 using HeuristicLab.Problems.BinPacking; … … 29 30 [Item("PackingSequenceCrossover", "An operator which crosses two PackingSequence representations.")] 30 31 [StorableClass] 31 public abstract class PackingSequenceCrossover : PackingSolutionCrossover , IPackingSequenceOperator {32 public abstract class PackingSequenceCrossover : PackingSolutionCrossover<Permutation>, IPackingSequenceOperator { 32 33 33 34 [StorableConstructor] … … 36 37 public PackingSequenceCrossover() 37 38 : base() { 38 39 39 ParentsParameter.ActualName = "PackingSequence"; 40 ChildParameter.ActualName = "PackingSequence"; 40 41 } 41 42 42 public abstract P ackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncodingparent2);43 public abstract Permutation Cross(IRandom random, Permutation parent1, Permutation parent2); 43 44 44 45 public override IOperation Apply() { … … 46 47 47 48 ChildParameter.ActualValue = 48 Cross(RandomParameter.ActualValue, parents[0] as PackingSequenceEncoding, parents[1] as PackingSequenceEncoding);49 Cross(RandomParameter.ActualValue, parents[0], parents[1]); 49 50 50 51 return base.Apply(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceInversionManipulator.cs
r14046 r14128 43 43 } 44 44 45 protected override void Manipulate(IRandom random, P ackingSequenceEncodingindividual) {46 InversionManipulator.Apply(random, individual .PackingSequence);45 protected override void Manipulate(IRandom random, Permutation individual) { 46 InversionManipulator.Apply(random, individual); 47 47 } 48 48 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceManipulator.cs
r14046 r14128 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 using HeuristicLab.Problems.BinPacking; … … 30 31 [Item("PackingSequenceManipulator", "An operator which manipulates a PackingSequence representation.")] 31 32 [StorableClass] 32 public abstract class PackingSequenceManipulator : PackingSolutionManipulator , IPackingSequenceOperator {33 public abstract class PackingSequenceManipulator : PackingSolutionManipulator<Permutation>, IPackingSequenceOperator { 33 34 [StorableConstructor] 34 35 protected PackingSequenceManipulator(bool deserializing) : base(deserializing) { } … … 39 40 } 40 41 41 protected abstract void Manipulate(IRandom random, P ackingSequenceEncodingindividual);42 protected abstract void Manipulate(IRandom random, Permutation individual); 42 43 43 44 public override IOperation Apply() { 44 var solution = EncodedSolutionParameter.ActualValue as PackingSequenceEncoding;45 var solution = EncodedSolutionParameter.ActualValue; 45 46 if (solution == null) throw new InvalidOperationException("PackingSolutionEncoding was not found or is not of type PackingSequenceEncoding."); 46 47 Manipulate(RandomParameter.ActualValue, solution); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceOrderCrossover.cs
r14046 r14128 30 30 [Item("PackingSequence OX", "An operator which crosses two PackingSequence representations using the OX-strategy.")] 31 31 [StorableClass] 32 public class PackingSequenceOrderCrossover : PackingSequenceCrossover , IPackingSequenceOperator{32 public class PackingSequenceOrderCrossover : PackingSequenceCrossover { 33 33 34 34 [StorableConstructor] … … 42 42 } 43 43 44 public override PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2) { 45 PackingSequenceEncoding result = new PackingSequenceEncoding(); 46 result.PackingSequence = OrderCrossover.Apply(random, parent1.PackingSequence, parent2.PackingSequence); 47 return result; 44 public override Permutation Cross(IRandom random, Permutation parent1, Permutation parent2) { 45 return OrderCrossover.Apply(random, parent1, parent2); 48 46 } 49 47 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequencePartiallyMatchedCrossover.cs
r14046 r14128 31 31 [Item("PackingSequence PMX", "An operator which crosses two PackingSequence representations using the OX-strategy.")] 32 32 [StorableClass] 33 public class PackingSequencePartiallyMatchedCrossover : PackingSequenceCrossover , IPackingSequenceOperator{33 public class PackingSequencePartiallyMatchedCrossover : PackingSequenceCrossover { 34 34 35 35 [StorableConstructor] … … 43 43 } 44 44 45 public override PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2) { 46 PackingSequenceEncoding result = new PackingSequenceEncoding(); 47 result.PackingSequence = PartiallyMatchedCrossover.Apply(random, parent1.PackingSequence, parent2.PackingSequence); 48 return result; 45 public override Permutation Cross(IRandom random, Permutation parent1, Permutation parent2) { 46 return PartiallyMatchedCrossover.Apply(random, parent1, parent2); 49 47 } 50 48 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceRandomCreator.cs
r14064 r14128 33 33 [Item("PackingSequenceCreator", "Creator class used to create PackingSequence solutions for bin packing problems.")] 34 34 [StorableClass] 35 public class PackingSequenceRandomCreator : PackingSolutionCreator, I StochasticOperator {35 public class PackingSequenceRandomCreator : PackingSolutionCreator, IPackingSequenceCreator, IStochasticOperator { 36 36 37 37 public ILookupParameter<IRandom> RandomParameter { 38 38 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 39 39 } 40 public I ValueLookupParameter<IntValue>PackingItemsParameter {41 get { return (I ValueLookupParameter<IntValue>)Parameters["PackingItems"]; }40 public ILookupParameter<IntValue> NumberOfPackingItemsParameter { 41 get { return (ILookupParameter<IntValue>)Parameters["NumberOfItems"]; } 42 42 } 43 43 44 public ILookupParameter<P ackingSequence> SolutionParameter {45 get { return (ILookupParameter<P ackingSequence>)Parameters["PackingItems"]; }44 public ILookupParameter<Permutation> SolutionParameter { 45 get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; } 46 46 } 47 47 … … 58 58 : base() { 59 59 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator.")); 60 Parameters.Add(new ValueLookupParameter<IntValue>("PackingItems", "The number of packing-items handled in this problem instance.")); 61 Parameters.Add(new LookupParameter<PackingSequence>("PackingSequence")); 62 63 SolutionParameter.ActualName = "PackingSequence"; 60 Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfPackingItems", "The number of packing-items handled in this problem instance.")); 61 Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The randomly created solution candidate.")); 64 62 } 65 63 66 64 public override IOperation Apply() { 67 Apply( PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);65 Apply(NumberOfPackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue); 68 66 return base.Apply(); 69 67 } 70 68 71 public static PackingSequenceEncoding Apply(int items, IRandom random) { 72 var solution = new PackingSequenceEncoding(); 73 solution.PackingSequence = new Permutation(PermutationTypes.Absolute, items, random); 74 return solution; 69 public static Permutation Apply(int items, IRandom random) { 70 return new Permutation(PermutationTypes.Absolute, items, random); 75 71 } 76 72 protected override IItem CreateSolution() { 77 return Apply( PackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue);73 return Apply(NumberOfPackingItemsParameter.ActualValue.Value, RandomParameter.ActualValue); 78 74 } 79 75 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceScrambleManipulator.cs
r14046 r14128 41 41 } 42 42 43 protected override void Manipulate(IRandom random, P ackingSequenceEncodingindividual) {44 ScrambleManipulator.Apply(random, individual .PackingSequence);43 protected override void Manipulate(IRandom random, Permutation individual) { 44 ScrambleManipulator.Apply(random, individual); 45 45 } 46 46 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSolutionCrossover.cs
r14046 r14128 32 32 [Item("PackingSolutionCrossover", "A bin packing crossover operation.")] 33 33 [StorableClass] 34 public abstract class PackingSolutionCrossover : SingleSuccessorOperator, IPackingSolutionCrossover, IStochasticOperator { 34 public abstract class PackingSolutionCrossover<T> : SingleSuccessorOperator, IPackingSolutionCrossover<T>, IStochasticOperator 35 where T : class, IItem { 35 36 36 public ILookupParameter< IPackingSolutionEncoding> ChildParameter {37 get { return (ILookupParameter< IPackingSolutionEncoding>)Parameters["Child"]; }37 public ILookupParameter<T> ChildParameter { 38 get { return (ILookupParameter<T>)Parameters["Child"]; } 38 39 } 39 public IScopeTreeLookupParameter< IPackingSolutionEncoding> ParentsParameter {40 get { return (IScopeTreeLookupParameter< IPackingSolutionEncoding>)Parameters["Parents"]; }40 public IScopeTreeLookupParameter<T> ParentsParameter { 41 get { return (IScopeTreeLookupParameter<T>)Parameters["Parents"]; } 41 42 } 42 43 public ILookupParameter<IRandom> RandomParameter { … … 46 47 [StorableConstructor] 47 48 protected PackingSolutionCrossover(bool deserializing) : base(deserializing) { } 48 protected PackingSolutionCrossover(PackingSolutionCrossover original, Cloner cloner) : base(original, cloner) { }49 protected PackingSolutionCrossover(PackingSolutionCrossover<T> original, Cloner cloner) : base(original, cloner) { } 49 50 public PackingSolutionCrossover() 50 51 : base() { 51 52 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 52 Parameters.Add(new LookupParameter< IPackingSolutionEncoding>("Child", "The child solution resulting from the crossover."));53 Parameters.Add(new LookupParameter<T>("Child", "The child solution resulting from the crossover.")); 53 54 ChildParameter.ActualName = "EncodedSolution"; 54 Parameters.Add(new ScopeTreeLookupParameter< IPackingSolutionEncoding>("Parents", "The parent solution which should be crossed."));55 Parameters.Add(new ScopeTreeLookupParameter<T>("Parents", "The parent solution which should be crossed.")); 55 56 ParentsParameter.ActualName = "EncodedSolution"; 56 57 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSolutionManipulator.cs
r14046 r14128 32 32 [Item("PackingSolutionManipulator", "A bin packing manipulation operation.")] 33 33 [StorableClass] 34 public abstract class PackingSolutionManipulator : SingleSuccessorOperator, IPackingSolutionManipulator, IStochasticOperator { 34 public abstract class PackingSolutionManipulator<T> : SingleSuccessorOperator, IPackingSolutionManipulator<T>, IStochasticOperator 35 where T : class, IItem { 35 36 36 public ILookupParameter< IPackingSolutionEncoding> EncodedSolutionParameter {37 get { return (ILookupParameter< IPackingSolutionEncoding>)Parameters["EncodedSolution"]; }37 public ILookupParameter<T> EncodedSolutionParameter { 38 get { return (ILookupParameter<T>)Parameters["EncodedSolution"]; } 38 39 } 39 40 … … 44 45 [StorableConstructor] 45 46 protected PackingSolutionManipulator(bool deserializing) : base(deserializing) { } 46 protected PackingSolutionManipulator(PackingSolutionManipulator original, Cloner cloner) : base(original, cloner) { }47 protected PackingSolutionManipulator(PackingSolutionManipulator<T> original, Cloner cloner) : base(original, cloner) { } 47 48 public PackingSolutionManipulator() 48 49 : base() { 49 Parameters.Add(new LookupParameter< IPackingSolutionEncoding>("EncodedSolution", "The bin packing solution to be manipulated."));50 Parameters.Add(new LookupParameter<T>("EncodedSolution", "The bin packing solution to be manipulated.")); 50 51 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 51 52 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/BinUtilizationEvaluator.cs
r14051 r14128 42 42 public BinUtilizationEvaluator() : base() { } 43 43 44 protected override DoubleValue Evaluate() {44 protected override double Evaluate() { 45 45 DoubleValue quality = new DoubleValue(0); 46 46 … … 67 67 } 68 68 69 public static DoubleValue CalculateBinUtilization(PackingPlan<D, B, I> plan) {69 public static double CalculateBinUtilization(PackingPlan<D, B, I> plan) { 70 70 int nrOfBins = plan.NrOfBins; 71 71 double result = 0; … … 97 97 98 98 result = totalUsedSpace / totalUsableSpace; 99 return new DoubleValue(result);99 return result; 100 100 } 101 101 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/EvaluatorBase.cs
r14052 r14128 75 75 } 76 76 77 protected abstract DoubleValue Evaluate();77 protected abstract double Evaluate(); 78 78 public override IOperation Apply() { 79 QualityParameter.ActualValue = Evaluate();79 QualityParameter.ActualValue = new DoubleValue(Evaluate()); 80 80 return base.Apply(); 81 81 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingRatioEvaluator.cs
r14050 r14128 41 41 public PackingRatioEvaluator() : base() { } 42 42 43 protected override DoubleValue Evaluate() {43 protected override double Evaluate() { 44 44 DoubleValue quality = new DoubleValue(0); 45 45 … … 74 74 k.......a constant, k>1. 75 75 */ 76 public static DoubleValue CalculatePackingRatio(PackingPlan<D, B, I> plan) {76 public static double CalculatePackingRatio(PackingPlan<D, B, I> plan) { 77 77 int nrOfBins = plan.NrOfBins; 78 78 double result = 0; … … 90 90 //k = 2 --> (Fi/C)*(Fi/C) 91 91 //result += (((usedSpaceInThisBin) / (usableSpace)) * ((usedSpaceInThisBin) / (usableSpace))) / (i*i + 1); 92 var PD= plan.BinPackings[i].PackingDensity;93 result += ( PD * PD) / (i + 1);92 var pd = plan.BinPackings[i].PackingDensity; 93 result += (pd * pd) / (i + 1); 94 94 } 95 95 96 96 result = result / nrOfBins; 97 return new DoubleValue(result);97 return result; 98 98 } 99 99 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r14064 r14128 160 160 <Compile Include="Analyzers\BestBinPackingSolutionAnalyzer.cs" /> 161 161 <Compile Include="Analyzers\BinPackingAnalyzer.cs" /> 162 <Compile Include="Encodings\GroupingVector\GroupingVectorSwap2Manipulator.cs" />163 <Compile Include="Encodings\GroupingVector\GroupingVectorSinglePointCrossover.cs" />164 <Compile Include="Encodings\GroupingVector\GroupingVectorDiscreteCrossover.cs" />165 <Compile Include="Encodings\GroupingVector\Moves\GroupingMove.cs" />166 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveAttribute.cs" />167 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\ExhaustiveSwapGroupingMoveGenerator.cs" />168 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMove.cs" />169 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMoveAttribute.cs" />170 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\SwapGroupingMoveGenerator.cs" />171 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveMaker.cs" />172 <Compile Include="Encodings\GroupingVector\Moves\GroupingTabuMaker.cs" />173 <Compile Include="Encodings\GroupingVector\Moves\SwapGrouping\StochasticSwapGroupingMoveGenerator.cs" />174 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveSoftTabuCriterion.cs" />175 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ExhaustiveChangeGroupingMoveGenerator.cs" />176 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMove.cs" />177 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMoveAttribute.cs" />178 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\ChangeGroupingMoveGenerator.cs" />179 <Compile Include="Encodings\GroupingVector\Moves\GroupingMoveHardTabuCriterion.cs" />180 <Compile Include="Encodings\GroupingVector\Moves\ChangeGrouping\StochasticChangeGroupingMoveGenerator.cs" />181 <Compile Include="Encodings\GroupingVector\GroupingVectorOnePositionManipulator.cs" />182 <Compile Include="Encodings\GroupingVector\GroupingVectorCrossover.cs" />183 <Compile Include="Encodings\GroupingVector\GroupingVectorEncoding.cs" />184 <Compile Include="Encodings\GroupingVector\GroupingVectorManipulator.cs" />185 <Compile Include="Encodings\GroupingVector\GroupingVectorRandomCreator.cs" />186 <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" />187 <Compile Include="Encodings\MultiComponentVector\BinBasedMultiComponentVectorCrossover.cs" />188 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\ChangePositionMoveAttribute.cs" />189 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Attributes\MCVTripleMoveAttribute.cs" />190 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SwapPositionMoveAttribute.cs" />191 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SingleGroupingMoveAttribute.cs" />192 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveAttribute.cs" />193 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\SingleItemRotationMoveAttribute.cs" />194 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\StochasticMCVTripleMoveGenerator.cs" />195 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\ExhaustiveMCVTripleMoveGenerator.cs" />196 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\ChangePositionMove.cs" />197 <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Moves\MCVTripleMove.cs" />198 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveHardTabuCriterion.cs" />199 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMove.cs" />200 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SwapPositionMove.cs" />201 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SingleItemRotationMove.cs" />202 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\ExhaustiveMultiComponentVectorMoveGenerator.cs" />203 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Moves\SingleGroupingMove.cs" />204 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveGenerator.cs" />205 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveSoftTabuCriterion.cs" />206 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorMoveMaker.cs" />207 <Compile Include="Encodings\MultiComponentVector\Moves\MultiComponentVectorTabuMaker.cs" />208 <Compile Include="Encodings\MultiComponentVector\Moves\Multi\StochasticMultiComponentVectorMoveGenerator.cs" />209 <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorEncoding.cs">210 <SubType>Code</SubType>211 </Compile>212 <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorCrossover.cs" />213 <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorManipulator.cs" />214 <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorRandomCreator.cs" />215 <Compile Include="Encodings\MultiComponentVector\ThreeWayMultiComponentVectorManipulator.cs" />216 162 <Compile Include="Encodings\PackingPlans\BinPacking.cs" /> 217 163 <Compile Include="Encodings\PackingPlans\PackingPlan.cs" /> 218 <Compile Include="Encodings\PackingSequence\Encoding.cs" />219 <Compile Include="Encodings\PackingSequence\IPackingSequenceCreator.cs" />220 <Compile Include="Encodings\PackingSequence\Moves\Insertion\ExhaustiveInsertionMoveGenerator.cs" />221 <Compile Include="Encodings\PackingSequence\Moves\Insertion\StochasticInsertionMoveGenerator.cs" />222 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMove.cs" />223 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveAttribute.cs" />224 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveGenerator.cs" />225 <Compile Include="Encodings\PackingSequence\PackingSequence.cs" />226 <Compile Include="Encodings\PackingSequence\PackingSequenceInversionManipulator.cs" />227 <Compile Include="Encodings\PackingSequence\PackingSequencePartiallyMatchedCrossover.cs" />228 <Compile Include="Encodings\PackingSequence\PackingSequenceOrderCrossover.cs" />229 <Compile Include="Encodings\PackingSequence\Moves\SequenceMove.cs" />230 <Compile Include="Encodings\PackingSequence\Moves\SequenceMoveAttribute.cs" />231 <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveHardTabuCriterion.cs" />232 <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveMaker.cs" />233 <Compile Include="Encodings\PackingSequence\Moves\GroupingMoveSoftTabuCriterion.cs" />234 <Compile Include="Encodings\PackingSequence\Moves\SequenceTabuMaker.cs" />235 <Compile Include="Encodings\PackingSequence\Moves\Swap2\ExhaustiveSwap2MoveGenerator.cs" />236 <Compile Include="Encodings\PackingSequence\Moves\Swap2\StochasticSwap2MoveGenerator.cs" />237 <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2Move.cs" />238 <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2MoveAttribute.cs" />239 <Compile Include="Encodings\PackingSequence\Moves\Swap2\Swap2MoveGenerator.cs" />240 <Compile Include="Encodings\PackingSequence\PackingSequenceCrossover.cs">241 <SubType>Code</SubType>242 </Compile>243 <Compile Include="Encodings\PackingSequence\PackingSequenceEncoding.cs">244 <SubType>Code</SubType>245 </Compile>246 <Compile Include="Encodings\PackingSequence\PackingSequenceManipulator.cs">247 <SubType>Code</SubType>248 </Compile>249 <Compile Include="Encodings\PackingSequence\PackingSequenceRandomCreator.cs" />250 <Compile Include="Encodings\PackingSequence\PackingSequenceScrambleManipulator.cs" />251 164 <Compile Include="Encodings\PackingSolutionCreator.cs" /> 252 165 <Compile Include="Encodings\PackingSolutionCrossover.cs" /> … … 282 195 <Compile Include="Plugin.cs" /> 283 196 <Compile Include="PackingSequenceProblem.cs" /> 284 <Compile Include="Problem.cs" />285 197 <Compile Include="Properties\AssemblyInfo.cs" /> 286 198 </ItemGroup> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingMove.cs
r14046 r14128 23 23 24 24 namespace HeuristicLab.Problems.BinPacking { 25 public interface IPackingMove : IItem {26 IPackingSolutionEncodingGetSolutionAfterMove();25 public interface IPackingMove<out T> : IItem { 26 T GetSolutionAfterMove(); 27 27 } 28 28 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionCreator.cs
r14046 r14128 24 24 25 25 namespace HeuristicLab.Problems.BinPacking { 26 public interface IPackingSolutionCreator : ISolutionCreator {26 public interface IPackingSolutionCreator : ISolutionCreator { 27 27 ILookupParameter<IItem> EncodedSolutionParameter { get; } 28 28 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionCrossover.cs
r14046 r14128 25 25 26 26 namespace HeuristicLab.Problems.BinPacking { 27 public interface IPackingSolutionCrossover : ICrossover, IPackingOperator { 28 ILookupParameter<IPackingSolutionEncoding> ChildParameter { get; } 29 IScopeTreeLookupParameter<IPackingSolutionEncoding> ParentsParameter { get; } 27 public interface IPackingSolutionCrossover<T> : ICrossover, IPackingOperator 28 where T : class, IItem { 29 ILookupParameter<T> ChildParameter { get; } 30 IScopeTreeLookupParameter<T> ParentsParameter { get; } 30 31 } 31 32 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingSolutionManipulator.cs
r14046 r14128 24 24 25 25 namespace HeuristicLab.Problems.BinPacking { 26 public interface IPackingSolutionManipulator : IManipulator, IPackingOperator { 27 ILookupParameter<IPackingSolutionEncoding> EncodedSolutionParameter { get; } 26 public interface IPackingSolutionManipulator<T> : IManipulator, IPackingOperator 27 where T : class, IItem { 28 ILookupParameter<T> EncodedSolutionParameter { get; } 28 29 } 29 30 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingMoveEvaluator.cs
r14050 r14128 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.Encodings.PackingEncoding; 26 using HeuristicLab.Encodings.PermutationEncoding; 26 27 using HeuristicLab.Operators; 27 28 using HeuristicLab.Optimization; … … 32 33 [Item("PackingMoveEvaluator", "A base class for operators which evaluate Packing-Solution moves.")] 33 34 [StorableClass] 34 public abstract class PackingMoveEvaluator<D, B, I > : SingleSuccessorOperator, IPackingMoveEvaluator, IMoveOperator35 public abstract class PackingMoveEvaluator<D, B, I, M> : SingleSuccessorOperator, IPackingMoveEvaluator 35 36 where D : class, IPackingPosition 36 37 where B : PackingShape<D> 37 where I : PackingShape<D>, IPackingItem { 38 where I : PackingShape<D>, IPackingItem 39 where M : IItem { 38 40 public override bool CanChangeName { 39 41 get { return false; } … … 61 63 get { return (ScopeParameter)Parameters["CurrentScope"]; } 62 64 } 63 public ILookupParameter<IPackingMove > PackingMoveParameter {64 get { return (ILookupParameter<IPackingMove >)Parameters["PackingMove"]; }65 public ILookupParameter<IPackingMove<M>> PackingMoveParameter { 66 get { return (ILookupParameter<IPackingMove<M>>)Parameters["PackingMove"]; } 65 67 } 66 68 67 69 [StorableConstructor] 68 70 protected PackingMoveEvaluator(bool deserializing) : base(deserializing) { } 69 protected PackingMoveEvaluator(PackingMoveEvaluator<D, B, I > original, Cloner cloner) : base(original, cloner) { }71 protected PackingMoveEvaluator(PackingMoveEvaluator<D, B, I, M> original, Cloner cloner) : base(original, cloner) { } 70 72 protected PackingMoveEvaluator() 71 73 : base() { … … 77 79 Parameters.Add(new ValueLookupParameter<IEvaluator>("PackingPlanEvaluator", "The actual packing plan evaluation operator.")); 78 80 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the decoded solution should be added to.")); 79 Parameters.Add(new LookupParameter<IPackingMove >("PackingMove", "The move to evaluate."));81 Parameters.Add(new LookupParameter<IPackingMove<M>>("PackingMove", "The move to evaluate.")); 80 82 } 81 83 … … 83 85 84 86 public override IOperation Apply() { 85 IPackingMove move = PackingMoveParameter.ActualValue;86 IPackingSolutionEncodingnewSolution = move.GetSolutionAfterMove();87 IPackingMove<M> move = PackingMoveParameter.ActualValue; 88 var newSolution = move.GetSolutionAfterMove(); 87 89 CurrentScopeParameter.ActualValue.Variables.Add(new Variable("MovedSolution", newSolution)); 88 90 … … 93 95 CurrentScopeParameter.ActualValue.Variables.Add(new Variable("PackingPlanAfterMove", packingPlan)); 94 96 95 DoubleValuequality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan);97 var quality = PackingRatioEvaluator<D, B, I>.CalculatePackingRatio(packingPlan); 96 98 97 double moveQuality = quality .Value;99 double moveQuality = quality; 98 100 99 101 if (MoveQualityParameter.ActualValue == null) MoveQualityParameter.ActualValue = new DoubleValue(moveQuality); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingSequenceProblem.cs
r14064 r14128 23 23 24 24 using System; 25 using System.CodeDom; 25 26 using System.Linq; 27 using System.Text; 26 28 using HeuristicLab.Common; 27 29 using HeuristicLab.Core; 28 30 using HeuristicLab.Data; 29 using HeuristicLab.Encodings.P ackingEncoding.PackingSequence;31 using HeuristicLab.Encodings.PermutationEncoding; 30 32 using HeuristicLab.Optimization; 31 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 using HeuristicLab.Problems.BinPacking; 32 35 33 namespace HeuristicLab.Problems.BinPacking 2d{36 namespace HeuristicLab.Problems.BinPacking { 34 37 [StorableClass] 35 abstract class PackingSequenceProblem : SingleObjectiveBasicProblem<Encoding> { 38 public abstract class PackingSequenceProblem<TSolution, TEncoding> : SingleObjectiveBasicProblem<TEncoding> 39 where TSolution : class, IItem 40 where TEncoding : class, IEncoding { 36 41 37 42 // persistence … … 43 48 44 49 // cloning 45 protected PackingSequenceProblem(PackingSequenceProblem original, Cloner cloner)50 protected PackingSequenceProblem(PackingSequenceProblem<TSolution, TEncoding> original, Cloner cloner) 46 51 : base(original, cloner) { 47 52 } … … 53 58 } 54 59 55 public sealed override double Evaluate(Individual individual, IRandom random) { 56 return Evaluate(individual.PackingSequence(), random); 57 } 58 public abstract double Evaluate(PackingSequence sequence, IRandom random); 59 60 public virtual void Analyze(PackingSequence[] trees, double[] qualities, ResultCollection results, 60 public virtual void Analyze(TSolution[] solutions, double[] qualities, ResultCollection results, 61 61 IRandom random) { 62 62 if (!results.ContainsKey("Best Solution Quality")) { … … 64 64 } 65 65 if (!results.ContainsKey("Best Solution")) { 66 results.Add(new Result("Best Solution", typeof( PackingSequence)));66 results.Add(new Result("Best Solution", typeof(TSolution))); 67 67 } 68 68 … … 72 72 IsBetter(bestQuality, ((DoubleValue)results["Best Solution Quality"].Value).Value)) { 73 73 var bestIdx = Array.IndexOf(qualities, bestQuality); 74 var bestClone = (IItem) trees[bestIdx].Clone();74 var bestClone = (IItem)solutions[bestIdx].Clone(); 75 75 results["Best Solution"].Value = bestClone; 76 76 results["Best Solution Quality"].Value = new DoubleValue(bestQuality); 77 77 } 78 78 } 79 80 public sealed override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {81 Analyze(individuals.Select(ind => ind.PackingSequence()).ToArray(), qualities, results, random);82 }83 79 } 84 80 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem.cs
r14054 r14128 26 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;29 28 using HeuristicLab.PluginInfrastructure; 30 29 using System.Linq; 31 30 using System; 32 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;33 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;34 31 using HeuristicLab.Encodings.PackingEncoding; 35 32 … … 97 94 } 98 95 99 protected Problem(IDecodingEvaluator e) : this(e, new MultiComponentVectorRandomCreator()) { } 100 101 protected Problem(IDecodingEvaluator e, IPackingSolutionCreator c) : base(e, c) { 96 protected Problem(IDecodingEvaluator e) : this(e, new PackingSequenceRandomCreator()) { } 97 98 protected Problem(IDecodingEvaluator e, IPackingSolutionCreator c) 99 : base(e, c) { 102 100 Parameters.Add(new OptionalValueParameter<PackingPlan<D, B, I>>("BestKnownSolution", "The best known solution of this bin-packing instance.")); 103 101 Parameters.Add(new ValueParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data defining the measures of the different items that need to be packed.", new ItemList<I>())); … … 109 107 Parameters.Add(new ConstrainedValueParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The operator that decodes the representation and creates a packing plan.")); 110 108 this.Maximization.Value = true; 111 InitializeProblemInstance(); 109 InitializeProblemInstance(); // TODO 112 110 InitializeOperators(); 113 111 InitializeEventHandlers(); … … 163 161 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPackingSequenceOperator>()); 164 162 InitializeDecoder(); 165 } else if (SolutionCreator.GetType() == typeof(GroupingVectorRandomCreator)) {163 } /* else if (SolutionCreator.GetType() == typeof(GroupingVectorRandomCreator)) { 166 164 Operators.AddRange(ApplicationManager.Manager.GetInstances<IGroupingVectorOperator>()); 167 165 InitializeDecoder(); … … 169 167 Operators.AddRange(ApplicationManager.Manager.GetInstances<IMultiComponentVectorOperator>()); 170 168 InitializeDecoder(); 171 } 169 } */ 172 170 } 173 171 private void ParameterizeOperators() { … … 193 191 PackingPlanEvaluator.PackingPlanParameter.Hidden = false; 194 192 } 193 /* 195 194 196 195 foreach (var op in Operators.OfType<IPackingSolutionManipulator>()) { … … 205 204 op.ParentsParameter.Hidden = true; 206 205 } 207 206 */ 208 207 foreach (var op in Operators.OfType<BestBinPackingSolutionAnalyzer<D, B, I>>()) { 209 208 op.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName;
Note: See TracChangeset
for help on using the changeset viewer.