Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9345 for trunk


Ignore:
Timestamp:
04/08/13 18:57:53 (12 years ago)
Author:
jkarder
Message:

#2029:

  • added EvaluateFunction to ISingleObjectiveTestFunctionProblemEvaluator and adapted evaluators
  • fixed SingleObjectiveTestFunctionImprovementOperator
Location:
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/AckleyEvaluator.cs

    r7259 r9345  
    109109    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    110110    /// <returns>The result value of the Ackley function at the given point.</returns>
    111     protected override double EvaluateFunction(RealVector point) {
     111    public override double EvaluateFunction(RealVector point) {
    112112      return Apply(point);
    113113    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/BealeEvaluator.cs

    r7259 r9345  
    9898    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    9999    /// <returns>The result value of the Beale function at the given point.</returns>
    100     protected override double EvaluateFunction(RealVector point) {
     100    public override double EvaluateFunction(RealVector point) {
    101101      return Apply(point);
    102102    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/BoothEvaluator.cs

    r7259 r9345  
    9494    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    9595    /// <returns>The result value of the Booth function at the given point.</returns>
    96     protected override double EvaluateFunction(RealVector point) {
     96    public override double EvaluateFunction(RealVector point) {
    9797      return Apply(point);
    9898    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/GriewankEvaluator.cs

    r7259 r9345  
    133133    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    134134    /// <returns>The result value of the Griewank function at the given point.</returns>
    135     protected override double EvaluateFunction(RealVector point) {
     135    public override double EvaluateFunction(RealVector point) {
    136136      if (point.Length > 100)
    137137        return Apply(point);
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/LevyEvaluator.cs

    r7259 r9345  
    111111    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    112112    /// <returns>The result value of the Levy function at the given point.</returns>
    113     protected override double EvaluateFunction(RealVector point) {
     113    public override double EvaluateFunction(RealVector point) {
    114114      return Apply(point);
    115115    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/MatyasEvaluator.cs

    r7259 r9345  
    9393    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    9494    /// <returns>The result value of the Matyas function at the given point.</returns>
    95     protected override double EvaluateFunction(RealVector point) {
     95    public override double EvaluateFunction(RealVector point) {
    9696      return Apply(point);
    9797    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/MultinormalEvaluator.cs

    r8587 r9345  
    161161    }
    162162
    163     public double Evaluate(RealVector point) {
    164       return EvaluateFunction(point);
    165     }
    166 
    167     protected override double EvaluateFunction(RealVector point) {
     163    public override double EvaluateFunction(RealVector point) {
    168164      double value = 0;
    169165      if (centers.Count == 0) {
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RandomEvaluator.cs

    r9294 r9345  
    8686    }
    8787
    88     public override double Evaluate2D(double x, double y) {
    89       var random = new System.Random();
    90       return random.NextDouble();
    91     }
    92 
    93     protected override double EvaluateFunction(RealVector point) {
    94       return RandomParameter.ActualValue.NextDouble();
     88    public override double EvaluateFunction(RealVector point) {
     89      return ExecutionContext == null ? new System.Random().NextDouble() : RandomParameter.ActualValue.NextDouble();
    9590    }
    9691  }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RastriginEvaluator.cs

    r7259 r9345  
    119119    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    120120    /// <returns>The result value of the Rastrigin function at the given point.</returns>
    121     protected override double EvaluateFunction(RealVector point) {
     121    public override double EvaluateFunction(RealVector point) {
    122122      return Apply(point, A.Value);
    123123    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RosenbrockEvaluator.cs

    r7259 r9345  
    105105    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    106106    /// <returns>The result value of the Rosenbrock function at the given point.</returns>
    107     protected override double EvaluateFunction(RealVector point) {
     107    public override double EvaluateFunction(RealVector point) {
    108108      return Apply(point);
    109109    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SchwefelEvaluator.cs

    r7259 r9345  
    9696    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    9797    /// <returns>The result value of the Schwefel function at the given point.</returns>
    98     protected override double EvaluateFunction(RealVector point) {
     98    public override double EvaluateFunction(RealVector point) {
    9999      return Apply(point);
    100100    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SingleObjectiveTestFunctionProblemEvaluator.cs

    r7259 r9345  
    9292      return EvaluateFunction(new RealVector(new double[] { x, y }));
    9393    }
    94     /// <summary>
    95     /// Gets the best known solution for this function.
    96     /// </summary>
    97     public abstract RealVector GetBestKnownSolution(int dimension);
    9894
    9995    /// <summary>
     
    10298    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    10399    /// <returns>The result value of the function at the given point.</returns>
    104     protected abstract double EvaluateFunction(RealVector point);
     100    public abstract double EvaluateFunction(RealVector point);
     101
     102    /// <summary>
     103    /// Gets the best known solution for this function.
     104    /// </summary>
     105    public abstract RealVector GetBestKnownSolution(int dimension);
    105106  }
    106107}
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SphereEvaluator.cs

    r7259 r9345  
    132132    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    133133    /// <returns>The result value of the Sphere function at the given point.</returns>
    134     protected override double EvaluateFunction(RealVector point) {
     134    public override double EvaluateFunction(RealVector point) {
    135135      return Apply(point, C.Value, Alpha.Value);
    136136    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SumSquaresEvaluator.cs

    r7259 r9345  
    9696    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    9797    /// <returns>The result value of the Sum Squares function at the given point.</returns>
    98     protected override double EvaluateFunction(RealVector point) {
     98    public override double EvaluateFunction(RealVector point) {
    9999      return Apply(point);
    100100    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/ZakharovEvaluator.cs

    r7259 r9345  
    100100    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    101101    /// <returns>The result value of the Zakharov function at the given point.</returns>
    102     protected override double EvaluateFunction(RealVector point) {
     102    public override double EvaluateFunction(RealVector point) {
    103103      return Apply(point);
    104104    }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Improvers/SingleObjectiveTestFunctionImprovementOperator.cs

    r8987 r9345  
    2121
    2222using System;
    23 using System.Reflection;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    126125        throw new ArgumentException("Cannot improve solution because it has the wrong type.");
    127126
    128       MethodInfo evaluationMethod = Evaluator.GetType().GetMethod("EvaluateFunction",
    129                                                                   BindingFlags.Instance | BindingFlags.NonPublic,
    130                                                                   null,
    131                                                                   new[] { typeof(RealVector) },
    132                                                                   null);
    133       Func<RealVector, double> functionEvaluator = x => (double)evaluationMethod.Invoke(Evaluator, new object[] { x });
    134       double bestSolQuality = functionEvaluator(bestSol);
     127      double bestSolQuality = Evaluator.EvaluateFunction(bestSol);
    135128
    136129      // create perturbed solutions
     
    146139      for (int i = 0; i < ImprovementAttempts.Value; i++) {
    147140        // order according to their objective function value
    148         Array.Sort(simplex, (x, y) => functionEvaluator(x).CompareTo(functionEvaluator(y)));
     141        Array.Sort(simplex, (x, y) => Evaluator.EvaluateFunction(x).CompareTo(Evaluator.EvaluateFunction(y)));
    149142
    150143        // calculate centroid
     
    160153        for (int j = 0; j < reflectionPoint.Length; j++)
    161154          reflectionPoint[j] = centroid[j] + Alpha.Value * (centroid[j] - simplex[simplex.Length - 1][j]);
    162         double reflectionPointQuality = functionEvaluator(reflectionPoint);
    163         if (functionEvaluator(simplex[0]) <= reflectionPointQuality
    164             && reflectionPointQuality < functionEvaluator(simplex[simplex.Length - 2]))
     155        double reflectionPointQuality = Evaluator.EvaluateFunction(reflectionPoint);
     156        if (Evaluator.EvaluateFunction(simplex[0]) <= reflectionPointQuality
     157            && reflectionPointQuality < Evaluator.EvaluateFunction(simplex[simplex.Length - 2]))
    165158          simplex[simplex.Length - 1] = reflectionPoint;
    166159
    167160        // expansion
    168         if (reflectionPointQuality < functionEvaluator(simplex[0])) {
     161        if (reflectionPointQuality < Evaluator.EvaluateFunction(simplex[0])) {
    169162          RealVector expansionPoint = new RealVector(bestSol.Length);
    170163          for (int j = 0; j < expansionPoint.Length; j++)
    171164            expansionPoint[j] = centroid[j] + Beta.Value * (reflectionPoint[j] - centroid[j]);
    172           simplex[simplex.Length - 1] = functionEvaluator(expansionPoint) < reflectionPointQuality ? expansionPoint : reflectionPoint;
     165          simplex[simplex.Length - 1] = Evaluator.EvaluateFunction(expansionPoint) < reflectionPointQuality ? expansionPoint : reflectionPoint;
    173166        }
    174167
    175168        // contraction
    176         if (functionEvaluator(simplex[simplex.Length - 2]) <= reflectionPointQuality
    177             && reflectionPointQuality < functionEvaluator(simplex[simplex.Length - 1])) {
     169        if (Evaluator.EvaluateFunction(simplex[simplex.Length - 2]) <= reflectionPointQuality
     170            && reflectionPointQuality < Evaluator.EvaluateFunction(simplex[simplex.Length - 1])) {
    178171          RealVector outsideContractionPoint = new RealVector(bestSol.Length);
    179172          for (int j = 0; j < outsideContractionPoint.Length; j++)
    180173            outsideContractionPoint[j] = centroid[j] + Gamma.Value * (reflectionPoint[j] - centroid[j]);
    181           if (functionEvaluator(outsideContractionPoint) <= reflectionPointQuality) {
     174          if (Evaluator.EvaluateFunction(outsideContractionPoint) <= reflectionPointQuality) {
    182175            simplex[simplex.Length - 1] = outsideContractionPoint;
    183             if (functionEvaluator(reflectionPoint) >= functionEvaluator(simplex[simplex.Length - 1])) {
     176            if (Evaluator.EvaluateFunction(reflectionPoint) >= Evaluator.EvaluateFunction(simplex[simplex.Length - 1])) {
    184177              RealVector insideContractionPoint = new RealVector(bestSol.Length);
    185178              for (int j = 0; j < insideContractionPoint.Length; j++)
    186179                insideContractionPoint[j] = centroid[j] - Gamma.Value * (reflectionPoint[j] - centroid[j]);
    187               if (functionEvaluator(insideContractionPoint) < functionEvaluator(simplex[simplex.Length - 1])) simplex[simplex.Length - 1] = insideContractionPoint;
     180              if (Evaluator.EvaluateFunction(insideContractionPoint) < Evaluator.EvaluateFunction(simplex[simplex.Length - 1])) simplex[simplex.Length - 1] = insideContractionPoint;
    188181            }
    189182          }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Interfaces/ISingleObjectiveTestFunctionProblemEvaluator.cs

    r7259 r9345  
    3939
    4040    double Evaluate2D(double x, double y);
     41    double EvaluateFunction(RealVector point);
    4142    RealVector GetBestKnownSolution(int dimension);
    4243  }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/MoveEvaluators/MultinormalAdditiveMoveEvaluator.cs

    r7259 r9345  
    5555      var eval = EvaluatorParameter.ActualValue as MultinormalEvaluator;
    5656      if (eval != null)
    57         return eval.Evaluate(wrapper);
     57        return eval.EvaluateFunction(wrapper);
    5858      throw new InvalidOperationException("evaluator is not a multinormal evaluator");
    5959    }
Note: See TracChangeset for help on using the changeset viewer.