Changeset 15492
- Timestamp:
- 12/04/17 23:19:44 (7 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 1 deleted
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/GeneralizedQAP.sln
r15491 r15492 9 9 EndProject 10 10 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.GRASP-3.3", "HeuristicLab.Algorithms.GRASP\3.3\HeuristicLab.Algorithms.GRASP-3.3.csproj", "{53AB48BF-532F-417D-B98B-745105BB447A}" 11 EndProject12 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3", "HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common\3.3\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3.csproj", "{DA367BE5-4F53-4243-933B-32AAB86189D5}"13 11 EndProject 14 12 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{68C6C157-08DA-414F-9256-CCCA13038399}" … … 66 64 {53AB48BF-532F-417D-B98B-745105BB447A}.Release|x86.ActiveCfg = Release|Any CPU 67 65 {53AB48BF-532F-417D-B98B-745105BB447A}.Release|x86.Build.0 = Release|Any CPU 68 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU69 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Debug|Any CPU.Build.0 = Debug|Any CPU70 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Debug|x64.ActiveCfg = Debug|Any CPU71 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Debug|x64.Build.0 = Debug|Any CPU72 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Debug|x86.ActiveCfg = Debug|Any CPU73 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Debug|x86.Build.0 = Debug|Any CPU74 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Release|Any CPU.ActiveCfg = Release|Any CPU75 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Release|Any CPU.Build.0 = Release|Any CPU76 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Release|x64.ActiveCfg = Release|Any CPU77 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Release|x64.Build.0 = Release|Any CPU78 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Release|x86.ActiveCfg = Release|Any CPU79 {DA367BE5-4F53-4243-933B-32AAB86189D5}.Release|x86.Build.0 = Release|Any CPU80 66 {68C6C157-08DA-414F-9256-CCCA13038399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 81 67 {68C6C157-08DA-414F-9256-CCCA13038399}.Debug|Any CPU.Build.0 = Debug|Any CPU -
branches/GeneralizedQAP/HeuristicLab.Algorithms.GRASP/3.3/GRASPWithPathRelinking.cs
r15490 r15492 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 32 using HeuristicLab.PluginInfrastructure; 33 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;34 33 using HeuristicLab.Random; 35 34 -
branches/GeneralizedQAP/HeuristicLab.Algorithms.GRASP/3.3/GRASPWithPathRelinkingMainLoop.cs
r15490 r15492 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Common; … … 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;33 33 using HeuristicLab.Selection; 34 34 … … 196 196 197 197 private void Parameterize() { 198 var operators = OperatorGraph.InitialOperator.Walk().ToArray();198 var operators = Walk(OperatorGraph).ToArray(); 199 199 200 200 foreach (var solutionsCreator in operators.OfType<SolutionsCreator>()) { 201 201 solutionsCreator.SolutionCreatorParameter.ActualName = SolutionCreatorParameter.Name; 202 202 solutionsCreator.EvaluatorParameter.ActualName = EvaluatorParameter.Name; 203 } 204 } 205 206 /// <summary> 207 /// Walks an operator graph in that it jumps from one operator to all its operator parameters and yields each operator it touches. 208 /// Cycles are detected and not walked twice. 209 /// </summary> 210 /// <param name="graph">The operator graph that should be walked.</param> 211 /// <returns>An enumeration of all the operators that could be found.</returns> 212 private IEnumerable<IOperator> Walk(OperatorGraph graph) { 213 var open = new Stack<IOperator>(); 214 var visited = new HashSet<IOperator>(); 215 open.Push(graph.InitialOperator); 216 217 while (open.Any()) { 218 IOperator current = open.Pop(); 219 if (visited.Contains(current)) continue; 220 visited.Add(current); 221 yield return current; 222 223 foreach (var parameter in current.Parameters.OfType<IValueParameter>()) { 224 if (typeof(IOperator).IsAssignableFrom(parameter.DataType)) { 225 if (parameter.Value != null) 226 open.Push((IOperator)parameter.Value); 227 } 228 } 229 var algOp = current as AlgorithmOperator; 230 if (algOp != null && algOp.OperatorGraph.InitialOperator != null) { 231 open.Push(algOp.OperatorGraph.InitialOperator); 232 } 203 233 } 204 234 } -
branches/GeneralizedQAP/HeuristicLab.Algorithms.GRASP/3.3/HeuristicLab.Algorithms.GRASP-3.3.csproj
r15490 r15492 110 110 <Private>False</Private> 111 111 </ProjectReference> 112 <ProjectReference Include="..\..\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common\3.3\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3.csproj">113 <Project>{DA367BE5-4F53-4243-933B-32AAB86189D5}</Project>114 <Name>HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3</Name>115 <Private>False</Private>116 </ProjectReference>117 112 </ItemGroup> 118 113 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/GeneralizedQAP/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEqualityComparer.cs
r15162 r15492 45 45 } 46 46 } 47 48 public static IEnumerable<int> GetDifferingIndices(IntegerVector a, IntegerVector b) { 49 if (a == null || b == null) throw new ArgumentNullException("arguments must not be null"); 50 for (int i = 0; i < a.Length; i++) 51 if (a[i] != b[i]) yield return i; 52 } 47 53 } 48 54 } -
branches/GeneralizedQAP/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r15490 r15492 156 156 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> 157 157 <Compile Include="Interfaces\IMultiObjectiveOperator.cs" /> 158 <Compile Include="Interfaces\IPopulationReducer.cs" /> 158 159 <Compile Include="MultiObjective\DominationCalculator.cs" /> 159 160 <Compile Include="Results\IResultParameter.cs" /> -
branches/GeneralizedQAP/HeuristicLab.Optimization/3.3/Interfaces/IPopulationReducer.cs
r15454 r15492 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Data; 24 using HeuristicLab.Optimization;25 24 26 namespace HeuristicLab. Problems.GeneralizedQuadraticAssignment.Common {25 namespace HeuristicLab.Optimization { 27 26 public interface IPopulationReducer : IReducer { 28 27 ILookupParameter<IntValue> MinimumPopulationSizeParameter { get; } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj
r15491 r15492 186 186 <Private>False</Private> 187 187 </ProjectReference> 188 <ProjectReference Include="..\..\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common\3.3\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3.csproj">189 <Project>{DA367BE5-4F53-4243-933B-32AAB86189D5}</Project>190 <Name>HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3</Name>191 <Private>False</Private>192 </ProjectReference>193 188 </ItemGroup> 194 189 <ItemGroup /> -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/GQAPPathRelinking.cs
r15490 r15492 137 137 var fix = new HashSet<int>(); 138 138 var nonFix = new HashSet<int>(Enumerable.Range(0, demands.Length)); 139 var phi = new HashSet<int>(( pi_prime.GetDifferingIndices(target)));139 var phi = new HashSet<int>((IntegerVectorEqualityComparer.GetDifferingIndices(pi_prime, target))); 140 140 141 141 while (phi.Any()) { … … 176 176 bool contains = false; 177 177 foreach (var b in B) { 178 if (! solution.Assignment.GetDifferingIndices(b.Assignment).Any()) {178 if (!IntegerVectorEqualityComparer.GetDifferingIndices(solution.Assignment, b.Assignment).Any()) { 179 179 contains = true; 180 180 break; … … 189 189 if (maximization.Value) pi = B.SampleProportional(random, 1, B.Select(x => x.Quality.Value), false).First(); 190 190 else pi = B.SampleProportional(random, 1, B.Select(x => 1.0 / x.Quality.Value), false).First(); 191 var diff = pi.Assignment.GetDifferingIndices(target);191 var diff = IntegerVectorEqualityComparer.GetDifferingIndices(pi.Assignment, target); 192 192 var I = phi.Except(diff); 193 193 var i = I.SampleRandom(random); … … 203 203 } 204 204 } else return result; 205 phi = new HashSet<int>( pi_prime.GetDifferingIndices(target));205 phi = new HashSet<int>(IntegerVectorEqualityComparer.GetDifferingIndices(pi_prime, target)); 206 206 } 207 207 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/PopulationReducers/GQAPQualitySimilarityReducer.cs
r15490 r15492 27 27 using HeuristicLab.Encodings.IntegerVectorEncoding; 28 28 using HeuristicLab.Operators; 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;32 32 33 33 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Operators { -
branches/GeneralizedQAP/UnitTests/UnitTests.csproj
r15490 r15492 115 115 <Name>HeuristicLab.Optimization-3.3</Name> 116 116 </ProjectReference> 117 <ProjectReference Include="..\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common\3.3\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3.csproj">118 <Project>{DA367BE5-4F53-4243-933B-32AAB86189D5}</Project>119 <Name>HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3</Name>120 </ProjectReference>121 117 <ProjectReference Include="..\HeuristicLab.Problems.GeneralizedQuadraticAssignment\3.3\HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj"> 122 118 <Project>{C739E6D2-5680-4804-A810-8017DA0C238F}</Project>
Note: See TracChangeset
for help on using the changeset viewer.