- Timestamp:
- 09/14/12 18:58:15 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 7 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/GP-MoveOperators/HeuristicLab.Problems.QuadraticAssignment
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.QuadraticAssignment merged: 8246,8338,8553,8600
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj
r8085 r8660 125 125 <Compile Include="Interfaces\IQAPEvaluator.cs" /> 126 126 <Compile Include="Interfaces\IQAPMoveEvaluator.cs" /> 127 <Compile Include="LocalImprovement\QAPExhaustiveInsertionLocalImprovement.cs" /> 128 <Compile Include="LocalImprovement\QAPStochasticScrambleLocalImprovement.cs" /> 127 129 <Compile Include="LocalImprovement\QAPExhaustiveSwap2LocalImprovement.cs" /> 130 <Compile Include="LocalImprovement\QAPExhaustiveInversionLocalImprovement.cs" /> 128 131 <Compile Include="QAPAssignment.cs" /> 129 132 <Compile Include="QAPPermutationProximityCalculator.cs" /> … … 210 213 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 211 214 <PropertyGroup> 212 <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)215 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 213 216 set ProjectDir=$(ProjectDir) 214 217 set SolutionDir=$(SolutionDir) … … 216 219 217 220 call PreBuildEvent.cmd</PreBuildEvent> 221 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 222 export ProjectDir=$(ProjectDir) 223 export SolutionDir=$(SolutionDir) 224 225 $SolutionDir/PreBuildEvent.sh 226 </PreBuildEvent> 218 227 </PropertyGroup> 219 228 <PropertyGroup> -
branches/GP-MoveOperators/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs
r8085 r8660 21 21 22 22 using System; 23 using System.Threading; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 44 45 get { return problem; } 45 46 set { problem = (QuadraticAssignmentProblem)value; } 47 } 48 49 public ILookupParameter<IntValue> LocalIterationsParameter { 50 get { return (ILookupParameter<IntValue>)Parameters["LocalIterations"]; } 46 51 } 47 52 … … 86 91 public QAPExhaustiveSwap2LocalImprovement() 87 92 : base() { 88 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum amount of iterations that should be performed (note that this operator will abort earlier when a local optimum is reached.", new IntValue(10000))); 93 Parameters.Add(new LookupParameter<IntValue>("LocalIterations", "The number of iterations that have already been performed.")); 94 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum amount of iterations that should be performed (note that this operator will abort earlier when a local optimum is reached).", new IntValue(10000))); 89 95 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The amount of evaluated solutions (here a move is counted only as 4/n evaluated solutions with n being the length of the permutation).")); 90 96 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection where to store results.")); … … 100 106 } 101 107 102 public static double Improve(Permutation assignment, double quality, DoubleMatrix weights, DoubleMatrix distances, bool maximization, int maxIterations, out double evaluatedSolutions) { 103 evaluatedSolutions = 0.0; 108 // BackwardsCompatibility3.3 109 #region Backwards compatible code, remove with 3.4 110 [StorableHook(HookType.AfterDeserialization)] 111 private void AfterDeserialization() { 112 if (!Parameters.ContainsKey("LocalIterations")) 113 Parameters.Add(new LookupParameter<IntValue>("LocalIterations", "The number of iterations that have already been performed.")); 114 } 115 #endregion 116 117 public static void Improve(Permutation assignment, DoubleMatrix weights, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, CancellationToken cancellation) { 104 118 double evalSolPerMove = 4.0 / assignment.Length; 105 119 106 for (int i = 0; i < maxIterations; i++) {120 for (int i = localIterations.Value; i < maxIterations; i++) { 107 121 Swap2Move bestMove = null; 108 122 double bestQuality = 0; // we have to make an improvement, so 0 is the baseline 123 double evaluations = 0.0; 109 124 foreach (Swap2Move move in ExhaustiveSwap2MoveGenerator.Generate(assignment)) { 110 125 double moveQuality = QAPSwap2MoveEvaluator.Apply(assignment, move, weights, distances); 111 evaluat edSolutions += evalSolPerMove;126 evaluations += evalSolPerMove; 112 127 if (maximization && moveQuality > bestQuality 113 128 || !maximization && moveQuality < bestQuality) { … … 116 131 } 117 132 } 133 evaluatedSolutions.Value += (int)Math.Ceiling(evaluations); 118 134 if (bestMove == null) break; 119 135 Swap2Manipulator.Apply(assignment, bestMove.Index1, bestMove.Index2); 120 quality += bestQuality; 136 quality.Value += bestQuality; 137 localIterations.Value++; 138 cancellation.ThrowIfCancellationRequested(); 121 139 } 122 return quality;123 140 } 124 141 125 142 public override IOperation Apply() { 126 int maxIterations = MaximumIterationsParameter.ActualValue.Value; 127 Permutation assignment = AssignmentParameter.ActualValue; 128 bool maximization = MaximizationParameter.ActualValue.Value; 129 DoubleMatrix weights = WeightsParameter.ActualValue; 130 DoubleMatrix distances = DistancesParameter.ActualValue; 131 double quality = QualityParameter.ActualValue.Value; 143 var maxIterations = MaximumIterationsParameter.ActualValue.Value; 144 var assignment = AssignmentParameter.ActualValue; 145 var maximization = MaximizationParameter.ActualValue.Value; 146 var weights = WeightsParameter.ActualValue; 147 var distances = DistancesParameter.ActualValue; 148 var quality = QualityParameter.ActualValue; 149 var localIterations = LocalIterationsParameter.ActualValue; 150 var evaluations = EvaluatedSolutionsParameter.ActualValue; 151 if (localIterations == null) { 152 localIterations = new IntValue(0); 153 LocalIterationsParameter.ActualValue = localIterations; 154 } 132 155 133 double evaluations; 134 QualityParameter.ActualValue.Value = Improve(assignment, quality, weights, distances, maximization, maxIterations, out evaluations); 135 EvaluatedSolutionsParameter.ActualValue.Value += (int)Math.Ceiling(evaluations); 156 Improve(assignment, weights, distances, quality, localIterations, evaluations, maximization, maxIterations, CancellationToken); 136 157 return base.Apply(); 137 158 } -
branches/GP-MoveOperators/HeuristicLab.Problems.QuadraticAssignment/3.3/Plugin.cs.frame
r8085 r8660 23 23 24 24 namespace HeuristicLab.Problems.QuadraticAssignment { 25 [Plugin("HeuristicLab.Problems.QuadraticAssignment", "3.3. 6.$WCREV$")]25 [Plugin("HeuristicLab.Problems.QuadraticAssignment", "3.3.7.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.QuadraticAssignment-3.3.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/GP-MoveOperators/HeuristicLab.Problems.QuadraticAssignment/3.3/Properties/AssemblyInfo.cs.frame
r7259 r8660 55 55 // [assembly: AssemblyVersion("1.0.*")] 56 56 [assembly: AssemblyVersion("3.3.0.0")] 57 [assembly: AssemblyFileVersion("3.3. 6.$WCREV$")]57 [assembly: AssemblyFileVersion("3.3.7.$WCREV$")] -
branches/GP-MoveOperators/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r8085 r8660 412 412 Description = data.Description; 413 413 Load(weights, distances); 414 if (data.BestKnownQuality.HasValue) BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value); 414 415 EvaluateAndLoadAssignment(data.BestKnownAssignment); 415 416 OnReset(); … … 426 427 Description = data.Description; 427 428 Load(weights, distances); 429 if (data.BestKnownQuality.HasValue) BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value); 428 430 EvaluateAndLoadAssignment(data.BestKnownTour); 429 431 OnReset();
Note: See TracChangeset
for help on using the changeset viewer.