#region License Information /* HeuristicLab * Copyright (C) 2002-2016 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 System; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Algorithms.DataAnalysis { [StorableClass] [Item("InverseMultiquadraticKernel", "A kernel function that uses the inverse multiquadratic function")] public class InverseMultiquadraticKernel : KernelBase { #region HLConstructors & Boilerplate [StorableConstructor] protected InverseMultiquadraticKernel(bool deserializing) : base(deserializing) { } [StorableHook(HookType.AfterDeserialization)] private void AfterDeserialization() { } protected InverseMultiquadraticKernel(InverseMultiquadraticKernel original, Cloner cloner) : base(original, cloner) { } public InverseMultiquadraticKernel() { Parameters.Add(new FixedValueParameter(BetaParameterName, "The beta in the kernelfunction sqrt(1+||x-c||^2/beta)", new DoubleValue(2))); } public override IDeepCloneable Clone(Cloner cloner) { return new InverseMultiquadraticKernel(this, cloner); } #endregion protected override double Get(double norm) { if (Math.Abs(Beta) < double.Epsilon) return 0; return 1 / Math.Sqrt(1 + norm * norm / Beta); } protected override double GetGradient(double norm) { if (Math.Abs(Beta) < double.Epsilon) return double.NaN; norm *= norm; return norm / (2 * Beta * Beta * Math.Pow((norm + Beta) / Beta, 1.5)); } } }