Changeset 15541 for branches/2864_PermutationProblems/HeuristicLab.Problems.LinearOrdering/3.3/Evaluators
- Timestamp:
- 12/19/17 11:10:14 (7 years ago)
- Location:
- branches/2864_PermutationProblems/HeuristicLab.Problems.LinearOrdering/3.3/Evaluators
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2864_PermutationProblems/HeuristicLab.Problems.LinearOrdering/3.3/Evaluators/LOPEvaluator.cs
r15521 r15541 36 36 public abstract class LOPEvaluator : InstrumentedOperator, ILOPEvaluator 37 37 { 38 public override bool CanChangeName { 38 public override bool CanChangeName 39 { 39 40 get { return false; } 40 41 } 41 42 42 public ILookupParameter<DoubleValue> QualityParameter { 43 public ILookupParameter<DoubleValue> QualityParameter 44 { 43 45 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } 44 46 } -
branches/2864_PermutationProblems/HeuristicLab.Problems.LinearOrdering/3.3/Evaluators/MatrixTriangulationEvaluator.cs
r15521 r15541 31 31 { 32 32 /// <summary> 33 /// A base class for operators which evaluate LOP solutions given in Matrix representation.33 /// A base class for operators which evaluates LOP solutions given in Matrix representation. 34 34 /// </summary> 35 35 [Item("MatrixTriangulationEvaluator", "A base class for operators which evaluate LOP solutions given in Matrix representation.")] … … 37 37 public abstract class MatrixTriangulationEvaluator : LOPEvaluator, IMatrixTriangulationEvaluator 38 38 { 39 private object locker = new object();40 41 39 public ILookupParameter<Permutation> PermutationParameter { get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } } 42 40 public ILookupParameter<DoubleMatrix> MatrixParameter { get { return (ILookupParameter<DoubleMatrix>)Parameters["Matrix"]; } } 43 41 public ILookupParameter<Permutation> BestKnownSolutionParameter { get { return (ILookupParameter<Permutation>)Parameters["BestKnownSolution"]; } } 44 42 public ILookupParameter<DoubleValue> BestKnownQualityParameter { get { return (ILookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } } 43 45 44 [StorableConstructor] 46 45 protected MatrixTriangulationEvaluator(bool deserializing) : base(deserializing) { } … … 49 48 : base() 50 49 { 51 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated."));50 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The LOP solution given in path representation which should be evaluated.")); 52 51 Parameters.Add(new LookupParameter<DoubleMatrix>("Matrix", "The matrix which contains the distances between the cities.")); 53 52 Parameters.Add(new LookupParameter<Permutation>("BestKnownSolution", "The currently best known solution.")); … … 58 57 private void AfterDeserialization() 59 58 { 60 // BackwardsCompatibility3.3 61 #region Backwards compatible code (remove with 3.4) 62 LookupParameter<DoubleMatrix> oldDistanceMatrixParameter = Parameters["Matrix"] as LookupParameter<DoubleMatrix>; 63 if (oldDistanceMatrixParameter != null) 64 { 65 Parameters.Remove(oldDistanceMatrixParameter); 66 Parameters.Add(new LookupParameter<DoubleMatrix>("Matrix", "The matrix which contains the distances between the cities.")); 67 MatrixParameter.ActualName = oldDistanceMatrixParameter.ActualName; 68 } 69 #endregion 59 70 60 } 71 61 72 62 public static double Apply(MatrixTriangulationEvaluator evaluator, DoubleMatrix matrix, Permutation permut) 73 63 { 74 double length = evaluator.CalculateUpperTriangle(matrix, permut); 75 return length; 64 return evaluator.CalculateUpperTriangle(matrix, permut); 76 65 } 77 66 … … 80 69 Permutation p = PermutationParameter.ActualValue; 81 70 DoubleMatrix c = MatrixParameter.ActualValue; 82 if (c == null) throw new InvalidOperationException("No coordinates weregiven.");71 if (c == null) throw new InvalidOperationException("No matrix was given."); 83 72 84 73 double upperTriangle = CalculateUpperTriangle(c, p);
Note: See TracChangeset
for help on using the changeset viewer.