Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12126


Ignore:
Timestamp:
03/04/15 15:22:21 (10 years ago)
Author:
jkarder
Message:

#2332:

  • fixed SolutionSimilarityCalculator.Equals
  • problems now wire all of their ISolutionSimilarityCalculators
Location:
trunk/sources
Files:
4 edited

Legend:

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

    r12085 r12126  
    111111      if (x == null || y == null) return false;
    112112
    113       var q1 = x.Variables[QualityVariableName];
    114       var q2 = x.Variables[QualityVariableName];
     113      var q1 = x.Variables[QualityVariableName].Value;
     114      var q2 = y.Variables[QualityVariableName].Value;
    115115
    116116      return CheckQualityEquality(q1, q2) && CalculateSolutionSimilarity(x, y).IsAlmost(1.0);
     
    133133        }
    134134      }
    135       return 0; // throw exception?
     135      return 0;
    136136    }
    137137
     
    147147
    148148      if (da1 != null && da2 != null)
    149         return da1.SequenceEqual(da2);
     149        return !da1.Zip(da2, Tuple.Create).Any(x => !x.Item1.IsAlmost(x.Item2));
    150150
    151151      throw new ArgumentException("Could not determine quality equality.");
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r12102 r12126  
    252252      Operators.Add(new KnapsackSimultaneousPathRelinker());
    253253      Operators.Add(new KnapsackSimilarityCalculator());
    254       Operators.Add(new QualitySimilarityCalculator { QualityVariableName = SolutionCreator.BinaryVectorParameter.ActualName });
     254      Operators.Add(new QualitySimilarityCalculator());
    255255      Operators.Add(new NoSimilarityCalculator());
    256256
     
    310310        op.ParentsParameter.Hidden = true;
    311311      }
    312       foreach (KnapsackSimilarityCalculator op in Operators.OfType<KnapsackSimilarityCalculator>()) {
     312      foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) {
    313313        op.SolutionVariableName = SolutionCreator.BinaryVectorParameter.ActualName;
    314314        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r12102 r12126  
    261261      Operators.Add(new SingleObjectiveTestFunctionPathRelinker());
    262262      Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator());
    263       Operators.Add(new QualitySimilarityCalculator { QualityVariableName = SolutionCreator.RealVectorParameter.ActualName });
     263      Operators.Add(new QualitySimilarityCalculator());
    264264      Operators.Add(new NoSimilarityCalculator());
    265265
     
    385385        op.ParentsParameter.Hidden = true;
    386386      }
    387       foreach (var op in Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>()) {
     387      foreach (var op in Operators.OfType<ISolutionSimilarityCalculator>()) {
    388388        op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
    389389        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
    390         op.Bounds = Bounds;
     390        var calc = op as SingleObjectiveTestFunctionSimilarityCalculator;
     391        if (calc != null) calc.Bounds = Bounds;
    391392      }
    392393    }
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r12102 r12126  
    234234      Operators.Add(new TSPSimultaneousPathRelinker());
    235235      Operators.Add(new TSPSimilarityCalculator());
    236       Operators.Add(new QualitySimilarityCalculator { QualityVariableName = SolutionCreator.PermutationParameter.ActualName });
     236      Operators.Add(new QualitySimilarityCalculator());
    237237      Operators.Add(new NoSimilarityCalculator());
    238238
     
    359359        op.ParentsParameter.Hidden = true;
    360360      }
    361       foreach (TSPSimilarityCalculator op in Operators.OfType<TSPSimilarityCalculator>()) {
     361      foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) {
    362362        op.SolutionVariableName = SolutionCreator.PermutationParameter.ActualName;
    363363        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
Note: See TracChangeset for help on using the changeset viewer.