Changeset 6416
- Timestamp:
- 06/15/11 23:11:41 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 7 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj
r5809 r6416 221 221 </BootstrapperPackage> 222 222 </ItemGroup> 223 <ItemGroup> 224 <EmbeddedResource Include="StringConvertibleArrayView.resx"> 225 <DependentUpon>StringConvertibleArrayView.cs</DependentUpon> 226 </EmbeddedResource> 227 </ItemGroup> 223 228 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 224 229 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
branches/QAPAlgorithms/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.Designer.cs
r5445 r6416 116 116 #endregion 117 117 118 pr ivate System.Windows.Forms.Label lengthLabel;119 pr ivate System.Windows.Forms.TextBox lengthTextBox;120 pr ivate System.Windows.Forms.DataGridView dataGridView;121 pr ivateSystem.Windows.Forms.ErrorProvider errorProvider;118 protected System.Windows.Forms.DataGridView dataGridView; 119 protected System.Windows.Forms.Label lengthLabel; 120 protected System.Windows.Forms.TextBox lengthTextBox; 121 protected System.Windows.Forms.ErrorProvider errorProvider; 122 122 123 123 } -
branches/QAPAlgorithms/HeuristicLab.Encodings.PermutationEncoding.Views/3.3/HeuristicLab.Encodings.PermutationEncoding.Views-3.3.csproj
r5163 r6416 12 12 <AssemblyName>HeuristicLab.Encodings.PermutationEncoding.Views-3.3</AssemblyName> 13 13 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 14 <TargetFrameworkProfile></TargetFrameworkProfile> 14 <TargetFrameworkProfile> 15 </TargetFrameworkProfile> 15 16 <FileAlignment>512</FileAlignment> 16 17 <SignAssembly>true</SignAssembly> … … 92 93 </PropertyGroup> 93 94 <ItemGroup> 95 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" /> 96 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" /> 97 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" /> 98 <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86" /> 94 99 <Reference Include="System" /> 95 100 <Reference Include="System.Core"> … … 98 103 <Reference Include="System.Drawing" /> 99 104 <Reference Include="System.Windows.Forms" /> 105 <Reference Include="System.Windows.Forms.DataVisualization" /> 100 106 <Reference Include="System.Xml.Linq"> 101 107 <RequiredTargetFramework>3.5</RequiredTargetFramework> … … 115 121 </Compile> 116 122 <Compile Include="HeuristicLabEncodingsPermutationEncodingViewsPlugin.cs" /> 123 <Compile Include="PermutationView.cs"> 124 <SubType>UserControl</SubType> 125 </Compile> 126 <Compile Include="PermutationView.Designer.cs"> 127 <DependentUpon>PermutationView.cs</DependentUpon> 128 </Compile> 117 129 <Compile Include="Properties\AssemblyInfo.cs" /> 118 130 </ItemGroup> … … 135 147 <Name>HeuristicLab.Core-3.3</Name> 136 148 </ProjectReference> 149 <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj"> 150 <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project> 151 <Name>HeuristicLab.Data.Views-3.3</Name> 152 </ProjectReference> 137 153 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> 138 154 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project> … … 150 166 <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project> 151 167 <Name>HeuristicLab.MainForm-3.3</Name> 168 </ProjectReference> 169 <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj"> 170 <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project> 171 <Name>HeuristicLab.Optimization.Views-3.3</Name> 152 172 </ProjectReference> 153 173 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> … … 172 192 <Install>true</Install> 173 193 </BootstrapperPackage> 194 </ItemGroup> 195 <ItemGroup> 196 <EmbeddedResource Include="PermutationView.resx"> 197 <DependentUpon>PermutationView.cs</DependentUpon> 198 </EmbeddedResource> 174 199 </ItemGroup> 175 200 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/QAPAlgorithms/HeuristicLab.Encodings.PermutationEncoding.Views/3.3/HeuristicLabEncodingsPermutationEncodingViewsPlugin.cs.frame
r6099 r6416 31 31 [PluginDependency("HeuristicLab.Core.Views", "3.3")] 32 32 [PluginDependency("HeuristicLab.Data", "3.3")] 33 [PluginDependency("HeuristicLab.Data.Views", "3.3")] 33 34 [PluginDependency("HeuristicLab.Encodings.PermutationEncoding", "3.3")] 34 35 [PluginDependency("HeuristicLab.MainForm", "3.3")] -
branches/QAPAlgorithms/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r5445 r6416 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 36 37 public PermutationTypes PermutationType { 37 38 get { return permutationType; } 39 set { 40 bool changed = (permutationType != value); 41 permutationType = value; 42 if (changed) OnPermutationTypeChanged(); 43 } 38 44 } 39 45 … … 45 51 } 46 52 public Permutation() : this(PermutationTypes.RelativeUndirected) { } 47 public Permutation(PermutationTypes type) : base() { 53 public Permutation(PermutationTypes type) 54 : base() { 48 55 permutationType = type; 49 56 } … … 58 65 Randomize(random); 59 66 } 60 public Permutation(PermutationTypes type, int[] elements) : base(elements) { 67 public Permutation(PermutationTypes type, int[] elements) 68 : base(elements) { 61 69 permutationType = type; 62 70 } 63 public Permutation(PermutationTypes type, IntArray elements) : this(type, elements.Length) { 71 public Permutation(PermutationTypes type, IntArray elements) 72 : this(type, elements.Length) { 64 73 for (int i = 0; i < array.Length; i++) 65 74 array[i] = elements[i]; … … 111 120 return this[position]; 112 121 } 122 123 public event EventHandler PermutationTypeChanged; 124 125 protected virtual void OnPermutationTypeChanged() { 126 var handler = PermutationTypeChanged; 127 if (handler != null) handler(this, EventArgs.Empty); 128 } 113 129 } 114 130 } -
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/HeuristicLab.Problems.QuadraticAssignment.Algorithms-3.3.csproj
r6351 r6416 107 107 </ItemGroup> 108 108 <ItemGroup> 109 <Compile Include="QAPRandomizedRobustTabooSeachOperator.cs" /> 110 <Compile Include="RandomizedRobustTabooSearch.cs" /> 109 111 <Compile Include="QAPRobustTabooSeachOperator.cs" /> 110 112 <Compile Include="RobustTabooSearch.cs" /> -
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/QAPRobustTabooSeachOperator.cs
r6351 r6416 165 165 if (bestMove == null) return base.Apply(); 166 166 167 shortTermMemory[bestMove.Index1, solution[bestMove.Index 2]] = iteration;168 shortTermMemory[bestMove.Index2, solution[bestMove.Index 1]] = iteration;167 shortTermMemory[bestMove.Index1, solution[bestMove.Index1]] = iteration; 168 shortTermMemory[bestMove.Index2, solution[bestMove.Index2]] = iteration; 169 169 Swap2Manipulator.Apply(solution, bestMove.Index1, bestMove.Index2); 170 170 quality.Value += bestMoveQuality; -
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs
r6342 r6416 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Analysis; 23 24 using HeuristicLab.Common; … … 56 57 57 58 protected override Allele[] CalculateAlleles(Permutation solution) { 58 Allele[] alleles = new Allele[solution.Length]; 59 Allele[] alleles = new Allele[solution.Length * solution.Length]; 60 Dictionary<string, int> allelesDict = new Dictionary<string, int>(); 59 61 DoubleMatrix weights = WeightsParameter.ActualValue; 60 62 DoubleMatrix distances = DistancesParameter.ActualValue; 61 int source, target;62 63 double impact; 63 64 64 for (int i = 0; i < solution.Length; i++) { 65 source = i; 66 target = solution[i]; 67 impact = 0; 68 for (int j = 0; j < solution.Length; j++) 69 impact += weights[source, j] * distances[target, solution[j]]; 70 alleles[i] = new Allele(source.ToString() + "->" + target.ToString(), impact); 65 for (int x = 0; x < solution.Length; x++) { 66 for (int y = 0; y < solution.Length; y++) { 67 string allele = weights[x, y].ToString() + ">" + distances[solution[x], solution[y]].ToString(); 68 int repetition = 1; 69 if (allelesDict.ContainsKey(allele)) repetition += allelesDict[allele]; 70 allelesDict[allele] = repetition; 71 impact = weights[x, y] * distances[solution[x], solution[y]]; 72 alleles[x * solution.Length + y] = new Allele(allele + "/" + repetition, impact); 73 } 71 74 } 72 75 -
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPPopulationDiversityAnalyzer.cs
r6342 r6416 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 25 26 using HeuristicLab.Encodings.PermutationEncoding; 27 using HeuristicLab.Parameters; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 33 35 [StorableClass] 34 36 public sealed class QAPPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<Permutation> { 37 public IValueParameter<BoolValue> UsePhenotypeSimilarityParameter { 38 get { return (IValueParameter<BoolValue>)Parameters["UsePhenotypeSimilarity"]; } 39 } 40 public ILookupParameter<DoubleMatrix> WeightsParameter { 41 get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; } 42 } 43 public ILookupParameter<DoubleMatrix> DistancesParameter { 44 get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; } 45 } 46 35 47 [StorableConstructor] 36 48 private QAPPopulationDiversityAnalyzer(bool deserializing) : base(deserializing) { } 37 49 private QAPPopulationDiversityAnalyzer(QAPPopulationDiversityAnalyzer original, Cloner cloner) : base(original, cloner) { } 38 public QAPPopulationDiversityAnalyzer() : base() { } 50 public QAPPopulationDiversityAnalyzer() 51 : base() { 52 Parameters.Add(new ValueParameter<BoolValue>("UsePhenotypeSimilarity", "True if the similarity should be measured a level closer to the phenotype (the number of similar assignments of individual weights to distances). Set to false if the number of equal assignments (facility to location) should be counted.", new BoolValue(false))); 53 Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights matrix.")); 54 Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances matrix.")); 55 } 39 56 40 57 public override IDeepCloneable Clone(Cloner cloner) { … … 42 59 } 43 60 61 [StorableHook(HookType.AfterDeserialization)] 62 private void AfterDeserialization() { 63 // BackwardsCompatibility3.3 64 #region Backwards compatible code, remove with 3.4 65 if (!Parameters.ContainsKey("UsePhenotypeSimilarity")) 66 Parameters.Add(new ValueParameter<BoolValue>("UsePhenotypeSimilarity", "True if the similarity should be measured a level closer to the phenotype (the number of similar assignments of individual weights to distances). Set to false if the number of equal assignments (facility to location) should be counted.", new BoolValue(false))); 67 if (!Parameters.ContainsKey("Weights")) 68 Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights matrix.")); 69 if (!Parameters.ContainsKey("Distances")) 70 Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances matrix.")); 71 #endregion 72 } 73 44 74 protected override double[,] CalculateSimilarities(Permutation[] solutions) { 75 DoubleMatrix weights = WeightsParameter.ActualValue, distances = DistancesParameter.ActualValue; 76 bool phenotypeSimilarity = UsePhenotypeSimilarityParameter.Value.Value; 45 77 int count = solutions.Length; 46 78 double[,] similarities = new double[count, count]; … … 49 81 similarities[i, i] = 1; 50 82 for (int j = i + 1; j < count; j++) { 51 similarities[i, j] = CalculateSimilarity(solutions[i], solutions[j]); 83 if (phenotypeSimilarity) 84 similarities[i, j] = QAPPermutationProximityCalculator.CalculatePhenotypeSimilarity(solutions[i], solutions[j], weights, distances); 85 else similarities[i, j] = QAPPermutationProximityCalculator.CalculateGenotypeSimilarity(solutions[i], solutions[j]); 52 86 similarities[j, i] = similarities[i, j]; 53 87 } … … 55 89 return similarities; 56 90 } 57 58 private double CalculateSimilarity(Permutation assignment1, Permutation assignment2) {59 int identicalAssignments = 0;60 for (int i = 0; i < assignment1.Length; i++) {61 if (assignment1[i] == assignment2[i])62 identicalAssignments++;63 }64 return ((double)identicalAssignments) / assignment1.Length;65 }66 91 } 67 92 } -
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj
r6342 r6416 124 124 <Compile Include="Parsers\QAPLIBParser.cs" /> 125 125 <Compile Include="QAPAssignment.cs" /> 126 <Compile Include="QAPPermutationProximityCalculator.cs" /> 126 127 <Compile Include="QuadraticAssignmentProblem.cs" /> 127 128 <EmbeddedResource Include="Data\bur26a.dat" /> -
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r6342 r6416 390 390 Distances = new DoubleMatrix(parser.Distances); 391 391 Weights = new DoubleMatrix(parser.Weights); 392 Name = "Quadratic Assignment Problem (loaded instance " + instance + ")";393 Description = "Loaded embedded problem data of instance " + instance + ".";392 Name = instance; 393 Description = "Loaded embedded QAPLIB problem data of instance " + instance + "."; 394 394 OnReset(); 395 395 }
Note: See TracChangeset
for help on using the changeset viewer.