Changeset 6801
- Timestamp:
- 09/20/11 07:51:42 (13 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/Plugin.cs.frame
r6628 r6801 28 28 [PluginDependency("HeuristicLab.Collections", "3.3")] 29 29 [PluginDependency("HeuristicLab.Common", "3.3")] 30 [PluginDependency("HeuristicLab.Common.Resources", "3.3")]31 30 [PluginDependency("HeuristicLab.Core", "3.3")] 32 31 [PluginDependency("HeuristicLab.Data", "3.3")] -
branches/GeneralizedQAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/Plugin.cs.frame
r6548 r6801 26 26 [PluginFile("HeuristicLab.Problems.QuadraticAssignment.Views-3.3.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Analysis", "3.3")] 28 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 29 [PluginDependency("HeuristicLab.Common", "3.3")] 29 30 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] … … 34 35 [PluginDependency("HeuristicLab.MainForm", "3.3")] 35 36 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 37 [PluginDependency("HeuristicLab.Optimization", "3.3")] 36 38 [PluginDependency("HeuristicLab.Problems.QuadraticAssignment", "3.3")] 37 39 public class HeuristicLabProblemsQuadraticAssignmentViewsPlugin : PluginBase { -
branches/GeneralizedQAP/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj
r6733 r6801 111 111 <Compile Include="Analyzers\QAPAlleleFrequencyAnalyzer.cs" /> 112 112 <Compile Include="Analyzers\QAPPopulationDiversityAnalyzer.cs" /> 113 <Compile Include="Evaluators\AffinitySwapMoveEvaluator.cs" /> 113 114 <Compile Include="Evaluators\QAPScrambleMoveEvaluator.cs" /> 114 115 <Compile Include="Evaluators\QAPSwap2MoveEvaluator.cs" /> … … 119 120 <SubType>Code</SubType> 120 121 </Compile> 122 <Compile Include="Interfaces\IAffinitySwapMoveOperator.cs" /> 121 123 <Compile Include="Interfaces\IQAPEvaluator.cs" /> 122 124 <Compile Include="Interfaces\IQAPMoveEvaluator.cs" /> 123 125 <Compile Include="LocalImprovement\QAPExhaustiveSwap2LocalImprovement.cs" /> 126 <Compile Include="Moves\AffinitySwapMove.cs" /> 127 <Compile Include="Moves\StochasticAffinitySwapMoveGenerator.cs" /> 128 <Compile Include="Moves\AffinitySwapMoveMaker.cs" /> 124 129 <Compile Include="Parsers\QAPLIBSolutionParser.cs" /> 125 130 <Compile Include="Parsers\QAPLIBParser.cs" /> … … 449 454 <EmbeddedResource Include="Data\sko49.sln" /> 450 455 </ItemGroup> 456 <ItemGroup /> 451 457 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 452 458 <PropertyGroup> -
branches/GeneralizedQAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r6628 r6801 268 268 Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator); 269 269 Operators.AddRange(ApplicationManager.Manager.GetInstances<IQAPMoveEvaluator>()); 270 Operators.AddRange(ApplicationManager.Manager.GetInstances<IAffinitySwapMoveOperator>().Where(x => !(x is IQAPMoveEvaluator))); 270 271 Operators.Add(new BestQAPSolutionAnalyzer()); 271 272 Operators.Add(new QAPAlleleFrequencyAnalyzer()); … … 326 327 op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 327 328 } 329 foreach (IAffinitySwapMoveOperator op in Operators.OfType<IAffinitySwapMoveOperator>()) { 330 op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 331 op.WeightsParameter.ActualName = WeightsParameter.Name; 332 op.DistancesParameter.ActualName = DistancesParameter.Name; 333 } 328 334 if (Operators.OfType<IMoveGenerator>().Any()) { 329 335 string inversionMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationInversionMoveOperator>().First().InversionMoveParameter.ActualName; … … 336 342 foreach (IPermutationSwap2MoveOperator op in Operators.OfType<IPermutationSwap2MoveOperator>()) { 337 343 op.Swap2MoveParameter.ActualName = swapMove; 344 } 345 string affinitySwapMove = Operators.OfType<IMoveGenerator>().OfType<IAffinitySwapMoveOperator>().First().AffinitySwapMoveParameter.ActualName; 346 foreach (IAffinitySwapMoveOperator op in Operators.OfType<IAffinitySwapMoveOperator>()) { 347 op.AffinitySwapMoveParameter.ActualName = affinitySwapMove; 338 348 } 339 349 } -
branches/GeneralizedQAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPMoveEvaluatorTest.cs
r6685 r6801 87 87 [TestMethod] 88 88 public void Swap2MoveEvaluatorFastEvaluationTest() { 89 90 89 for (int i = 0; i < 500; i++) { 91 90 Swap2Move lastMove = new Swap2Move(random.Next(ProblemSize), random.Next(ProblemSize)); … … 257 256 } 258 257 258 [TestMethod] 259 public void AffinitySwapMoveEvaluatorTest() { 260 for (int i = 0; i < 500; i++) { 261 int index1, index2, index3, index4; 262 do { 263 index1 = random.Next(ProblemSize); 264 index2 = random.Next(ProblemSize); 265 index3 = random.Next(ProblemSize); 266 index4 = random.Next(ProblemSize); 267 } while (!(index1 != index2 && index1 != index3 && index1 != index4 && index2 != index3 && index2 != index4 && index3 != index4)); 268 AffinitySwapMove affinityMove = new AffinitySwapMove(); 269 affinityMove.AddSwap(index1, index2); 270 affinityMove.AddSwap(index3, index4); 271 Assert.IsTrue(affinityMove.GetSwapLocation(index1) == index2 272 && affinityMove.GetSwapLocation(index2) == index1 273 && affinityMove.GetSwapLocation(index3) == index4 274 && affinityMove.GetSwapLocation(index4) == index3); 275 276 // SYMMETRIC MATRICES 277 double before = QAPEvaluator.Apply(assignment, symmetricWeights, symmetricDistances); 278 Permutation clone = (Permutation)assignment.Clone(); 279 Swap2Manipulator.Apply(assignment, index1, index2); 280 Swap2Manipulator.Apply(assignment, index3, index4); 281 double after = QAPEvaluator.Apply(assignment, symmetricWeights, symmetricDistances); 282 double move = AffinitySwapMoveEvaluator.Apply(clone, affinityMove, symmetricWeights, symmetricDistances); 283 Assert.IsTrue(move.IsAlmost(after - before), "Failed on symmetric matrices"); 284 285 // ASYMMETRIC MATRICES 286 before = QAPEvaluator.Apply(assignment, asymmetricWeights, asymmetricDistances); 287 clone = (Permutation)assignment.Clone(); 288 Swap2Manipulator.Apply(assignment, index1, index2); 289 Swap2Manipulator.Apply(assignment, index3, index4); 290 after = QAPEvaluator.Apply(assignment, asymmetricWeights, asymmetricDistances); 291 move = AffinitySwapMoveEvaluator.Apply(clone, affinityMove, asymmetricWeights, asymmetricDistances); 292 Assert.IsTrue(move.IsAlmost(after - before), "Failed on asymmetric matrices"); 293 294 // NON-ZERO DIAGONAL ASSYMETRIC MATRICES 295 before = QAPEvaluator.Apply(assignment, nonZeroDiagonalWeights, nonZeroDiagonalDistances); 296 clone = (Permutation)assignment.Clone(); 297 Swap2Manipulator.Apply(assignment, index1, index2); 298 Swap2Manipulator.Apply(assignment, index3, index4); 299 after = QAPEvaluator.Apply(assignment, nonZeroDiagonalWeights, nonZeroDiagonalDistances); 300 move = AffinitySwapMoveEvaluator.Apply(clone, affinityMove, nonZeroDiagonalWeights, nonZeroDiagonalDistances); 301 Assert.IsTrue(move.IsAlmost(after - before), "Failed on non-zero diagonal matrices"); 302 } 303 } 304 259 305 } 260 306 }
Note: See TracChangeset
for help on using the changeset viewer.