source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/TestFunctions/CustomEvaluator.cs @ 9346

Last change on this file since 9346 was 9346, checked in by jkarder, 6 years ago

#1696: adapted CustomEvaluator to changes of r9345

File size: 2.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.RealVectorEncoding;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.TestFunctions.Evaluators {
30  [Item("CustomEvaluator", "Evaluates a custom test fuction.")]
31  [StorableClass]
32  public class CustomEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
33
34
35    [StorableConstructor]
36    protected CustomEvaluator(bool deserializing) : base(deserializing) { }
37    protected CustomEvaluator(CustomEvaluator original, Cloner cloner) : base(original, cloner) { }
38    public CustomEvaluator() { }
39
40    public override IDeepCloneable Clone(Cloner cloner) {
41      return new CustomEvaluator(this, cloner);
42    }
43
44    public override bool Maximization {
45      get { return false; }
46    }
47
48    public override DoubleMatrix Bounds {
49      get { return new DoubleMatrix(new double[,] { { 0, 5 } }); }
50    }
51
52    public override double BestKnownQuality {
53      get {
54        return -1;
55      }
56    }
57
58    public override int MinimumProblemSize { get { return 1; } }
59
60    public override int MaximumProblemSize { get { return 2; } }
61
62    public override RealVector GetBestKnownSolution(int dimension) {
63      return new RealVector(dimension);
64    }
65
66    public override double EvaluateFunction(RealVector point) {
67      if (point[0] < 0 || point[1] < 0)
68        return 0;
69      return Math.Sin(Math.Pow(point[0], point[1]));
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.