Changeset 15069


Ignore:
Timestamp:
06/27/17 13:45:50 (7 weeks ago)
Author:
abeham
Message:

#2706:

  • Added or updated similarity calculators and population similarity analysis for several problems (BinPacking, LAP, Orienteering, Parameter optimization, PTSP, QAP, TF, TSP, VRP)
  • Made TSPSimilarityCalculator obsolete since it's essentially the same as the one in the permutation plugin
  • Made QAPPopulationDiversityAnalyzer obsolete as it is replaced by the newer PopulationSimilarityAnalyzer
  • Removed genotype specific similarity code in QAPPermutationProximityCalculator (again identical to the permutation plugin)
  • Changed QAPSimilarityCalculator to perform phenotype similarity instead of genotype similarity (has not been previously used)
Location:
trunk/sources
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/IntegerVectorEncoding/IntegerVectorProblem.cs

    r14162 r15069  
    2424using System.Collections.Generic;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.IntegerVectorEncoding;
    2930using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3133
     
    5254      Encoding = new IntegerVectorEncoding(EncodedSolutionName, Items.Count, min: 0, max: LowerBound + 1); // NOTE: assumes that all items can be packed into LowerBound+1 bins
    5355      AddOperators();
     56      Parameterize();
    5457      RegisterEventHandlers();
    5558    }
     
    6366    }
    6467
     68    protected override void OnEncodingChanged() {
     69      base.OnEncodingChanged();
     70      Parameterize();
     71    }
    6572
    6673    private void AddOperators() {
    67 
    6874      // move operators are not yet supported (TODO)
    6975      Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator);
    7076      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    7177      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     78      Operators.Add(new HammingSimilarityCalculator());
     79      Operators.Add(new EuclideanSimilarityCalculator());
     80      Operators.Add(new QualitySimilarityCalculator());
     81      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7282
    73       Encoding.ConfigureOperators(Operators.OfType<IOperator>()); // gkronber: not strictly necessary (only when customer ops are added)
     83      Encoding.ConfigureOperators(Operators.OfType<IOperator>());
    7484    }
    7585
    7686    private void RegisterEventHandlers() {
    7787      // update encoding length when number of items is changed
    78       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
    79       LowerBoundParameter.Value.ValueChanged += (sender, args) => {
    80         for (int i = 0; i < Encoding.Bounds.Rows; i++) {
    81           Encoding.Bounds[i, 1] = LowerBound + 1;
    82         }
    83       };
     88      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     89      LowerBoundParameter.Value.ValueChanged += (sender, args) => Parameterize();
    8490    }
    8591
     
    96102      return result;
    97103    }
     104
     105    private void Parameterize() {
     106      Encoding.Length = Items.Count;
     107      for (int i = 0; i < Encoding.Bounds.Rows; i++) {
     108        Encoding.Bounds[i, 1] = LowerBound + 1;
     109      }
     110      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     111        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.IntegerVectorParameter.ActualName;
     112        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     113      }
     114    }
    98115    #endregion
    99116  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/PermutationEncoding/PermutationProblem.cs

    r14162 r15069  
    2323
    2424using System.Linq;
    25 using System.Windows.Forms;
     25using HeuristicLab.Analysis;
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Encodings.PermutationEncoding;
    2929using HeuristicLab.Optimization;
     30using HeuristicLab.Optimization.Operators;
    3031using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3132
     
    5152      Encoding = new PermutationEncoding(EncodedSolutionName, Items.Count, PermutationTypes.Absolute);
    5253      AddOperators();
     54      Parameterize();
    5355      RegisterEventHandlers();
    5456    }
     
    6264    }
    6365
     66    protected override void OnEncodingChanged() {
     67      base.OnEncodingChanged();
     68      Parameterize();
     69    }
    6470
    6571    private void AddOperators() {
     
    7076      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    7177      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     78      Operators.Add(new HammingSimilarityCalculator());
     79      Operators.Add(new QualitySimilarityCalculator());
     80      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7281
    7382      Encoding.ConfigureOperators(Operators.OfType<IOperator>());
     
    8392    private void RegisterEventHandlers() {
    8493      // update encoding length when number of items is changed
    85       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
     94      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     95    }
     96
     97    private void Parameterize() {
     98      Encoding.Length = Items.Count;
     99      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     100        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.PermutationParameter.ActualName;
     101        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     102      }
    86103    }
    87104  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/IntegerVectorEncoding/IntegerVectorProblem.cs

    r14167 r15069  
    2424using System.Collections.Generic;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.IntegerVectorEncoding;
    2930using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3133
     
    5153      Encoding = new IntegerVectorEncoding(EncodedSolutionName, Items.Count, min: 0, max: LowerBound + 1); // NOTE: assumes that all items can be packed into LowerBound+1 bins
    5254      AddOperators();
     55      Parameterize();
    5356      RegisterEventHandlers();
    5457    }
     
    6265    }
    6366
     67    protected override void OnEncodingChanged() {
     68      base.OnEncodingChanged();
     69      Parameterize();
     70    }
    6471
    6572    private void AddOperators() {
    66 
    6773      // move operators are not yet supported (TODO)
    6874      Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator);
    6975      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    7076      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     77      Operators.Add(new HammingSimilarityCalculator());
     78      Operators.Add(new EuclideanSimilarityCalculator());
     79      Operators.Add(new QualitySimilarityCalculator());
     80      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7181
    7282      Encoding.ConfigureOperators(Operators.OfType<IOperator>()); // gkronber: not strictly necessary (only when customer ops are added)
     
    7585    private void RegisterEventHandlers() {
    7686      // update encoding length when number of items is changed
    77       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
    78       LowerBoundParameter.Value.ValueChanged += (sender, args) => {
    79         for (int i = 0; i < Encoding.Bounds.Rows; i++) {
    80           Encoding.Bounds[i, 1] = LowerBound + 1;
    81         }
    82       };
     87      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     88      LowerBoundParameter.Value.ValueChanged += (sender, args) => Parameterize();
    8389    }
    8490
    8591    #region helpers
    86 
    8792    public static List<List<int>> GenerateSequenceMatrix(IntegerVector intVec) {
    8893      List<List<int>> result = new List<List<int>>();
     
    95100      return result;
    96101    }
     102
     103    private void Parameterize() {
     104      Encoding.Length = Items.Count;
     105      for (int i = 0; i < Encoding.Bounds.Rows; i++) {
     106        Encoding.Bounds[i, 1] = LowerBound + 1;
     107      }
     108      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     109        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.IntegerVectorParameter.ActualName;
     110        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     111      }
     112    }
    97113    #endregion
    98114  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/PermutationEncoding/PermutationProblem.cs

    r14167 r15069  
    2323
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.PermutationEncoding;
    2829using HeuristicLab.Optimization;
     30using HeuristicLab.Optimization.Operators;
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3032
     
    4951      Encoding = new PermutationEncoding(EncodedSolutionName, Items.Count, PermutationTypes.Absolute);
    5052      AddOperators();
     53      Parameterize();
    5154      RegisterEventHandlers();
    5255    }
     
    6063    }
    6164
     65    protected override void OnEncodingChanged() {
     66      base.OnEncodingChanged();
     67      Parameterize();
     68    }
    6269
    6370    private void AddOperators() {
     
    6875      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    6976      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     77      Operators.Add(new HammingSimilarityCalculator());
     78      Operators.Add(new QualitySimilarityCalculator());
     79      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7080
    7181      Encoding.ConfigureOperators(Operators.OfType<IOperator>());
     
    8292    private void RegisterEventHandlers() {
    8393      // update encoding length when number of items is changed
    84       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
     94      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     95    }
     96
     97    private void Parameterize() {
     98      Encoding.Length = Items.Count;
     99      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     100        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.PermutationParameter.ActualName;
     101        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     102      }
    85103    }
    86104  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r14273 r15069  
    150150  <ItemGroup />
    151151  <ItemGroup>
     152    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     153      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     154      <Name>HeuristicLab.Analysis-3.3</Name>
     155      <Private>False</Private>
     156    </ProjectReference>
    152157    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    153158      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     
    183188      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    184189      <Name>HeuristicLab.Operators-3.3</Name>
     190      <Private>False</Private>
     191    </ProjectReference>
     192    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     193      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     194      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    185195      <Private>False</Private>
    186196    </ProjectReference>
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs.frame

    r14174 r15069  
    2828  [Plugin("HeuristicLab.Problems.BinPacking", "3.3.14.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3637  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3738  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     39  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3840  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3941  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/HeuristicLab.Problems.LinearAssignment-3.3.csproj

    r11623 r15069  
    175175      <Private>False</Private>
    176176    </ProjectReference>
     177    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     178      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     179      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
     180      <Private>False</Private>
     181    </ProjectReference>
    177182    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    178183      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
  • trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/LinearAssignmentProblem.cs

    r14185 r15069  
    2323using System.Drawing;
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Encodings.PermutationEncoding;
    2930using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    3032using HeuristicLab.Parameters;
    3133using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    178180      Operators.RemoveAll(x => x is IMoveOperator);
    179181      Operators.Add(bestLAPSolutionAnalyzer);
     182
     183      Operators.Add(new HammingSimilarityCalculator());
     184      Operators.Add(new QualitySimilarityCalculator());
     185      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    180186    }
    181187
     
    207213      }
    208214
     215      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     216        similarityCalculator.SolutionVariableName = SolutionCreator.PermutationParameter.ActualName;
     217        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     218      }
     219
    209220      bestLAPSolutionAnalyzer.AssignmentParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    210221      bestLAPSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
  • trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/Plugin.cs.frame

    r14195 r15069  
    3434  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3535  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     36  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3637  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3738  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • trunk/sources/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj

    r13008 r15069  
    112112      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
    113113      <Name>HeuristicLab.Analysis-3.3</Name>
     114      <Private>False</Private>
    114115    </ProjectReference>
    115116    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    116117      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    117118      <Name>HeuristicLab.Collections-3.3</Name>
     119      <Private>False</Private>
    118120    </ProjectReference>
    119121    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    120122      <Project>{0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}</Project>
    121123      <Name>HeuristicLab.Common.Resources-3.3</Name>
     124      <Private>False</Private>
    122125    </ProjectReference>
    123126    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
     
    134137      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    135138      <Name>HeuristicLab.Data-3.3</Name>
     139      <Private>False</Private>
    136140    </ProjectReference>
    137141    <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">
    138142      <Project>{DDFB14DD-2A85-493C-A52D-E69729BBAEB0}</Project>
    139143      <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>
     144      <Private>False</Private>
    140145    </ProjectReference>
    141146    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    142147      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    143148      <Name>HeuristicLab.Operators-3.3</Name>
     149      <Private>False</Private>
     150    </ProjectReference>
     151    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     152      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     153      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
     154      <Private>False</Private>
    144155    </ProjectReference>
    145156    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    146157      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    147158      <Name>HeuristicLab.Optimization-3.3</Name>
     159      <Private>False</Private>
    148160    </ProjectReference>
    149161    <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    150162      <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    151163      <Name>HeuristicLab.Parameters-3.3</Name>
     164      <Private>False</Private>
    152165    </ProjectReference>
    153166    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    154167      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    155168      <Name>HeuristicLab.Persistence-3.3</Name>
     169      <Private>False</Private>
    156170    </ProjectReference>
    157171    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    158172      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    159173      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
     174      <Private>False</Private>
    160175    </ProjectReference>
    161176    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
    162177      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
    163178      <Name>HeuristicLab.Problems.Instances-3.3</Name>
     179      <Private>False</Private>
    164180    </ProjectReference>
    165181    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     
    171187      <Project>{21977CC3-1757-4B3B-87BD-FF817AAA900F}</Project>
    172188      <Name>HeuristicLab.Scripting-3.3</Name>
     189      <Private>False</Private>
    173190    </ProjectReference>
    174191  </ItemGroup>
  • trunk/sources/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs

    r14185 r15069  
    2323using System.IO;
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Encodings.IntegerVectorEncoding;
    2930using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    3032using HeuristicLab.Parameters;
    3133using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    272274      Operators.Add(new OrienteeringLocalImprovementOperator());
    273275      Operators.Add(new OrienteeringShakingOperator());
     276      Operators.Add(new QualitySimilarityCalculator());
     277      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     278
    274279      ParameterizeOperators();
    275280    }
     
    292297        op.TerminalPointParameter.ActualName = TerminalPointParameter.Name;
    293298        op.PointVisitingCostsParameter.ActualName = PointVisitingCostsParameter.Name;
     299      }
     300      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     301        similarityCalculator.SolutionVariableName = SolutionCreator.IntegerVectorParameter.ActualName;
     302        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
    294303      }
    295304    }
  • trunk/sources/HeuristicLab.Problems.Orienteering/3.3/Plugin.cs.frame

    r14195 r15069  
    2828  [Plugin("HeuristicLab.Problems.Orienteering", "3.3.14.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.Orienteering-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3637  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3738  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     39  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3840  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3941  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • trunk/sources/HeuristicLab.Problems.PTSP/3.3/HeuristicLab.Problems.PTSP-3.3.csproj

    r13484 r15069  
    7474  </PropertyGroup>
    7575  <ItemGroup>
     76    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     77      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     78      <Name>HeuristicLab.Analysis-3.3</Name>
     79      <Private>False</Private>
     80    </ProjectReference>
    7681    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    7782      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     
    107112      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    108113      <Name>HeuristicLab.Operators-3.3</Name>
     114      <Private>False</Private>
     115    </ProjectReference>
     116    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     117      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     118      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    109119      <Private>False</Private>
    110120    </ProjectReference>
  • trunk/sources/HeuristicLab.Problems.PTSP/3.3/PTSP.cs

    r14185 r15069  
    2222using System;
    2323using System.Linq;
     24using HeuristicLab.Analysis;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2728using HeuristicLab.Encodings.PermutationEncoding;
    2829using HeuristicLab.Optimization;
     30using HeuristicLab.Optimization.Operators;
    2931using HeuristicLab.Parameters;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    119121      Probabilities = new DoubleArray(Enumerable.Range(0, coordinates.Rows).Select(x => 0.5).ToArray());
    120122
     123      InitializeOperators();
     124      Parameterize();
    121125      RegisterEventHandlers();
     126    }
     127
     128    private void InitializeOperators() {
     129      Operators.Add(new HammingSimilarityCalculator());
     130      Operators.Add(new QualitySimilarityCalculator());
     131      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    122132    }
    123133
     
    125135    private void AfterDeserialization() {
    126136      RegisterEventHandlers();
     137    }
     138
     139    protected override void OnEncodingChanged() {
     140      base.OnEncodingChanged();
     141      Encoding.Length = Coordinates.Rows;
     142      Parameterize();
    127143    }
    128144
     
    236252      return Coordinates != null ? Coordinates.Rows : DistanceMatrix.Rows;
    237253    }
     254
     255    private void Parameterize() {
     256      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     257        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.PermutationParameter.ActualName;
     258        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     259      }
     260    }
    238261  }
    239262}
  • trunk/sources/HeuristicLab.Problems.PTSP/3.3/Plugin.cs.frame

    r14195 r15069  
    2525  [Plugin("HeuristicLab.Problems.PTSP", "Provides an implementation of the probabilistic traveling salesman problem (PTSP)", "3.3.14.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.PTSP-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    2728  [PluginDependency("HeuristicLab.Collections", "3.3")]
    2829  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3334  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3435  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     36  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3537  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3638  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • trunk/sources/HeuristicLab.Problems.ParameterOptimization/3.3/HeuristicLab.Problems.ParameterOptimization-3.3.csproj

    r11623 r15069  
    104104  </ItemGroup>
    105105  <ItemGroup>
     106    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     107      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     108      <Name>HeuristicLab.Analysis-3.3</Name>
     109      <Private>False</Private>
     110    </ProjectReference>
    106111    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    107112      <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project>
    108113      <Name>HeuristicLab.Collections-3.3</Name>
     114      <Private>False</Private>
    109115    </ProjectReference>
    110116    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
     
    131137      <Project>{23da7ff4-d5b8-41b6-aa96-f0561d24f3ee}</Project>
    132138      <Name>HeuristicLab.Operators-3.3</Name>
     139      <Private>False</Private>
     140    </ProjectReference>
     141    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     142      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     143      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    133144      <Private>False</Private>
    134145    </ProjectReference>
  • trunk/sources/HeuristicLab.Problems.ParameterOptimization/3.3/ParameterOptimizationProblem.cs

    r14185 r15069  
    2222using System;
    2323using System.Linq;
     24using HeuristicLab.Analysis;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2728using HeuristicLab.Encodings.RealVectorEncoding;
    2829using HeuristicLab.Optimization;
     30using HeuristicLab.Optimization.Operators;
    2931using HeuristicLab.Parameters;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    113115      Operators.Add(new BestSolutionAnalyzer());
    114116      Operators.Add(new BestSolutionsAnalyzer());
     117
     118      Operators.Add(new HammingSimilarityCalculator());
     119      Operators.Add(new EuclideanSimilarityCalculator());
     120      Operators.Add(new QualitySimilarityCalculator());
     121      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     122
    115123      UpdateParameters();
    116124      UpdateStrategyVectorBounds();
     
    147155      foreach (var op in Operators.OfType<IRealVectorManipulator>())
    148156        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
     157
     158      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     159        similarityCalculator.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
     160        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     161      }
    149162    }
    150163
  • trunk/sources/HeuristicLab.Problems.ParameterOptimization/3.3/Plugin.cs.frame

    r14195 r15069  
    2828  [Plugin("HeuristicLab.Problems.ParameterOptimization", "3.3.14.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.ParameterOptimization-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3536  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3637  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     38  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3739  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3840  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPPopulationDiversityAnalyzer.cs

    r14185 r15069  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Analysis;
    2324using HeuristicLab.Common;
     
    2728using HeuristicLab.Parameters;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.PluginInfrastructure;
    2931
    3032namespace HeuristicLab.Problems.QuadraticAssignment {
     
    3436  [Item("QAPPopulationDiversityAnalyzer", "An operator for analyzing the diversity of solutions of Quadratic Assignment Problems regarding their structural identity (number of equal facilty->location assignments).")]
    3537  [StorableClass]
     38  [Obsolete("Use the PopulationSimilarityAnalyzer in the HeuristicLab.Analysis plugin instead.")]
     39  [NonDiscoverableType]
    3640#pragma warning disable 0612
    37   public sealed class QAPPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<Permutation> {
     41  internal sealed class QAPPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<Permutation> {
    3842#pragma warning restore 0612
    3943    public IValueParameter<BoolValue> UsePhenotypeSimilarityParameter {
     
    8589          if (phenotypeSimilarity)
    8690            similarities[i, j] = QAPPermutationProximityCalculator.CalculatePhenotypeSimilarity(solutions[i], solutions[j], weights, distances);
    87           else similarities[i, j] = QAPPermutationProximityCalculator.CalculateGenotypeSimilarity(solutions[i], solutions[j]);
     91          else similarities[i, j] = HammingSimilarityCalculator.CalculateSimilarity(solutions[i], solutions[j]);
    8892          similarities[j, i] = similarities[i, j];
    8993        }
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPPermutationProximityCalculator.cs

    r14185 r15069  
    2626namespace HeuristicLab.Problems.QuadraticAssignment {
    2727  public static class QAPPermutationProximityCalculator {
    28 
    29     public static double CalculateGenotypeSimilarity(Permutation a, Permutation b) {
    30       int similar = 0;
    31       for (int i = 0; i < a.Length; i++) {
    32         if (a[i] == b[i]) similar++;
    33       }
    34       return similar / (double)a.Length;
    35     }
    36 
    37     public static double CalculateGenotypeDistance(Permutation a, Permutation b) {
    38       return 1.0 - CalculateGenotypeSimilarity(a, b);
    39     }
    4028
    4129    public static double CalculatePhenotypeSimilarity(Permutation a, Permutation b, DoubleMatrix weights, DoubleMatrix distances) {
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPSimilarityCalculator.cs

    r14185 r15069  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Optimization.Operators;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
    2830namespace HeuristicLab.Problems.QuadraticAssignment {
     
    3436  /// </remarks>
    3537  [Item("QAPSimilarityCalculator", "An operator that performs similarity calculation between two quadratic assignment solutions. The operator calculates the similarity based on the number of edges the two solutions have in common.")]
     38  [StorableClass]
    3639  public sealed class QAPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3740    protected override bool IsCommutative { get { return true; } }
    3841
     42    [Storable]
     43    public DoubleMatrix Weights { get; set; }
     44    [Storable]
     45    public DoubleMatrix Distances { get; set; }
     46
    3947    private QAPSimilarityCalculator(bool deserializing) : base(deserializing) { }
    40     private QAPSimilarityCalculator(QAPSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
     48    private QAPSimilarityCalculator(QAPSimilarityCalculator original, Cloner cloner)
     49      : base(original, cloner) {
     50      Weights = cloner.Clone(original.Weights);
     51      Distances = cloner.Clone(original.Distances);
     52    }
    4153    public QAPSimilarityCalculator() : base() { }
    4254
     
    4557    }
    4658
    47     public static double CalculateSimilarity(Permutation left, Permutation right) {
     59    public static double CalculateSimilarity(Permutation left, Permutation right, DoubleMatrix weights, DoubleMatrix distances) {
    4860      if (left == null || right == null)
    4961        throw new ArgumentException("Cannot calculate similarity because one of the provided solutions or both are null.");
     
    5264      if (object.ReferenceEquals(left, right)) return 1.0;
    5365
    54       return QAPPermutationProximityCalculator.CalculateGenotypeSimilarity(left, right);
     66      return QAPPermutationProximityCalculator.CalculatePhenotypeSimilarity(left, right, weights, distances);
    5567    }
    5668
     
    5971      var sol2 = rightSolution.Variables[SolutionVariableName].Value as Permutation;
    6072
    61       return CalculateSimilarity(sol1, sol2);
     73      return CalculateSimilarity(sol1, sol2, Weights, Distances);
    6274    }
    6375  }
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r14185 r15069  
    2424using System.Drawing;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    2930using HeuristicLab.Encodings.PermutationEncoding;
    3031using HeuristicLab.Optimization;
     32using HeuristicLab.Optimization.Operators;
    3133using HeuristicLab.Parameters;
    3234using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    301303      Operators.Add(new BestQAPSolutionAnalyzer());
    302304      Operators.Add(new QAPAlleleFrequencyAnalyzer());
    303       Operators.Add(new QAPPopulationDiversityAnalyzer());
    304305
    305306      Operators.Add(new QAPExhaustiveInsertionLocalImprovement());
     
    308309      Operators.Add(new QAPExhaustiveSwap2LocalImprovement());
    309310
     311      Operators.Add(new HammingSimilarityCalculator());
    310312      Operators.Add(new QAPSimilarityCalculator());
     313      Operators.Add(new QualitySimilarityCalculator());
     314      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     315
    311316      ParameterizeAnalyzers();
    312317      ParameterizeOperators();
     
    393398      }
    394399
    395       QAPSimilarityCalculator similarityCalculator = Operators.OfType<QAPSimilarityCalculator>().SingleOrDefault();
    396       if (similarityCalculator != null) {
     400      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    397401        similarityCalculator.SolutionVariableName = SolutionCreator.PermutationParameter.ActualName;
    398402        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     403        var qapsimcalc = similarityCalculator as QAPSimilarityCalculator;
     404        if (qapsimcalc != null) {
     405          qapsimcalc.Weights = Weights;
     406          qapsimcalc.Distances = Distances;
     407        }
    399408      }
    400409    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r14185 r15069  
    261261      Operators.Add(new SingleObjectiveTestFunctionPathRelinker());
    262262      Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator());
     263      Operators.Add(new HammingSimilarityCalculator());
     264      Operators.Add(new EuclideanSimilarityCalculator());
    263265      Operators.Add(new QualitySimilarityCalculator());
    264       Operators.Add(new NoSimilarityCalculator());
    265266
    266267      Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/SimilarityCalculators/TSPSimilarityCalculator.cs

    r14185 r15069  
    2525using HeuristicLab.Encodings.PermutationEncoding;
    2626using HeuristicLab.Optimization.Operators;
     27using HeuristicLab.PluginInfrastructure;
    2728
    2829namespace HeuristicLab.Problems.TravelingSalesman {
     
    3435  /// </remarks>
    3536  [Item("TSPSimilarityCalculator", "An operator that performs similarity calculation between two traveling salesman solutions. The operator calculates the similarity based on the number of edges the two solutions have in common.")]
    36   public sealed class TSPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     37  [Obsolete("This operator is similar to the Hamming similarity calculator in the Encodings.PermutationEncoding namespace")]
     38  [NonDiscoverableType]
     39  internal sealed class TSPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3740    protected override bool IsCommutative { get { return true; } }
    3841
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r14185 r15069  
    233233      Operators.Add(new TSPPathRelinker());
    234234      Operators.Add(new TSPSimultaneousPathRelinker());
    235       Operators.Add(new TSPSimilarityCalculator());
     235
     236      Operators.Add(new HammingSimilarityCalculator());
    236237      Operators.Add(new QualitySimilarityCalculator());
    237       Operators.Add(new NoSimilarityCalculator());
     238      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    238239
    239240      Operators.Add(new BestTSPSolutionAnalyzer());
    240241      Operators.Add(new TSPAlleleFrequencyAnalyzer());
    241       Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    242242      ParameterizeAnalyzers();
    243243      var operators = new HashSet<IPermutationOperator>(new IPermutationOperator[] {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r14481 r15069  
    254254        Operators.Add(new VRPSimilarityCalculator());
    255255        Operators.Add(new QualitySimilarityCalculator());
    256         Operators.Add(new NoSimilarityCalculator());
    257256        Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    258257
Note: See TracChangeset for help on using the changeset viewer.