#region License Information /* HeuristicLab * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Encodings.RealVectorEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.TestFunctions { /// /// Base class for a test function evaluator. /// [Item("Single-Objective Function", "Base class for single objective functions.")] [StorableClass] public abstract class SingleObjectiveTestFunction : ParameterizedNamedItem, ISingleObjectiveTestFunction { /// /// These operators should not change their name through the GUI /// public override bool CanChangeName { get { return false; } } /// /// Returns whether the actual function constitutes a maximization or minimization problem. /// public abstract bool Maximization { get; } /// /// Gets the lower and upper bound of the function. /// public abstract DoubleMatrix Bounds { get; } /// /// Gets the optimum function value. /// public abstract double BestKnownQuality { get; } /// /// Gets the minimum problem size. /// public abstract int MinimumProblemSize { get; } /// /// Gets the maximum problem size. /// public abstract int MaximumProblemSize { get; } [StorableConstructor] protected SingleObjectiveTestFunction(bool deserializing) : base(deserializing) { } protected SingleObjectiveTestFunction(SingleObjectiveTestFunction original, Cloner cloner) : base(original, cloner) { } protected SingleObjectiveTestFunction() : base() { } public virtual double Evaluate2D(double x, double y) { return Evaluate(new RealVector(new double[] { x, y })); } /// /// Evaluates the test function for a specific . /// /// N-dimensional point for which the test function should be evaluated. /// The result value of the function at the given point. public abstract double Evaluate(RealVector point); /// /// Gets the best known solution for this function. /// public abstract RealVector GetBestKnownSolution(int dimension); } }