Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12070 for trunk/sources


Ignore:
Timestamp:
02/25/15 10:59:20 (10 years ago)
Author:
jkarder
Message:

#2332: added SolutionSimilarityCalculator.IsCommutative

Location:
trunk/sources
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/NoSimilarityCalculator.cs

    r12012 r12070  
    3232  [Item("NoSimilarityCalculator", "An item that performs similarity calculation between two solutions. The item always considers two solutions to be distinct.")]
    3333  public sealed class NoSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     34    protected override bool IsCommutative { get { return true; } }
     35
    3436    private NoSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3537    private NoSimilarityCalculator(NoSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/QualitySimilarityCalculator.cs

    r12012 r12070  
    3434  [Item("QualitySimilarityCalculator", "An item that performs similarity calculation between two solutions. The item only considers the qualities of the two solutions.")]
    3535  public sealed class QualitySimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     36    protected override bool IsCommutative { get { return true; } }
     37
    3638    private QualitySimilarityCalculator(bool deserializing) : base(deserializing) { }
    3739    private QualitySimilarityCalculator(QualitySimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/SolutionSimilarityCalculator.cs

    r12012 r12070  
    3333  [StorableClass]
    3434  public abstract class SolutionSimilarityCalculator : Item, ISolutionSimilarityCalculator {
     35    protected abstract bool IsCommutative { get; }
     36
    3537    [StorableConstructor]
    3638    protected SolutionSimilarityCalculator(bool deserializing) : base(deserializing) { }
     
    7173      for (int i = 0; i < individuals.Count; i++) similarityMatrix[i] = new double[individuals.Count];
    7274
    73       for (int i = 0; i < individuals.Count; i++) {
    74         for (int j = i; j < individuals.Count; j++) {
    75           similarityMatrix[i][j] = similarityMatrix[j][i] = CalculateSolutionSimilarity(individuals[i], individuals[j]);
     75      if (IsCommutative) {
     76        for (int i = 0; i < individuals.Count; i++) {
     77          for (int j = i; j < individuals.Count; j++) {
     78            similarityMatrix[i][j] = similarityMatrix[j][i] = CalculateSolutionSimilarity(individuals[i], individuals[j]);
     79          }
     80        }
     81      } else {
     82        for (int i = 0; i < individuals.Count; i++) {
     83          for (int j = i; j < individuals.Count; j++) {
     84            similarityMatrix[i][j] = CalculateSolutionSimilarity(individuals[i], individuals[j]);
     85            if (i == j) continue;
     86            similarityMatrix[j][i] = CalculateSolutionSimilarity(individuals[j], individuals[i]);
     87          }
    7688        }
    7789      }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs

    r11978 r12070  
    3636  public class SymbolicExpressionTreeBottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3737    private readonly HashSet<string> commutativeSymbols = new HashSet<string> { "Addition", "Multiplication", "Average", "And", "Or", "Xor" };
     38
     39    protected override bool IsCommutative { get { return true; } }
     40
    3841    public SymbolicExpressionTreeBottomUpSimilarityCalculator() { }
    3942
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator.cs

    r12012 r12070  
    3131  [Item("SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator", "A similarity calculator based on the size of the maximum common subtree between two trees")]
    3232  public class SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     33    protected override bool IsCommutative { get { return true; } }
     34
    3335    [Storable]
    3436    private readonly SymbolicExpressionTreeNodeEqualityComparer comparer;
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/SimilarityCalculators/KnapsackSimilarityCalculator.cs

    r12012 r12070  
    3535  [Item("KnapsackSimilarityCalculator", "An operator that performs similarity calculation between two knapsack solutions. The operator calculates the similarity based on the number of elements the two solutions have in common.")]
    3636  public sealed class KnapsackSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     37    protected override bool IsCommutative { get { return true; } }
     38
    3739    private KnapsackSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3840    private KnapsackSimilarityCalculator(KnapsackSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPSimilarityCalculator.cs

    r12012 r12070  
    3535  [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.")]
    3636  public sealed class QAPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     37    protected override bool IsCommutative { get { return true; } }
     38
    3739    private QAPSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3840    private QAPSimilarityCalculator(QAPSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs

    r12012 r12070  
    3838  [StorableClass]
    3939  public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    40     #region Properties
     40    protected override bool IsCommutative { get { return true; } }
     41
    4142    [Storable]
    4243    public DoubleMatrix Bounds { get; set; }
    43     #endregion
    4444
    4545    [StorableConstructor]
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/SimilarityCalculators/TSPSimilarityCalculator.cs

    r12012 r12070  
    3535  [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.")]
    3636  public sealed class TSPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     37    protected override bool IsCommutative { get { return true; } }
     38
    3739    private TSPSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3840    private TSPSimilarityCalculator(TSPSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/SimilarityCalculators/VRPSimilarityCalculator.cs

    r12012 r12070  
    4040  [StorableClass]
    4141  public sealed class VRPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    42     #region Properties
     42    protected override bool IsCommutative { get { return true; } }
     43
    4344    [Storable]
    4445    public IVRPProblemInstance ProblemInstance { get; set; }
    45     #endregion
    4646
    4747    private VRPSimilarityCalculator(bool deserializing) : base(deserializing) { }
Note: See TracChangeset for help on using the changeset viewer.