Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/Build.cmd
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/Build.cmd	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/Build.cmd	(revision 14386)
@@ -0,0 +1,104 @@
+@ECHO OFF
+
+SET CLEANBEFOREBUILD=
+
+SET SELECTED=
+SET CONFIGURATION=
+SET PLATFORM=
+
+IF "%~1"=="" GOTO :prompt_solution
+
+SET SELECTED=%1
+IF NOT EXIST %SELECTED% (
+  ECHO Solution file %SELECTED% could not be found.
+  GOTO :end
+)
+ECHO Building solution %SELECTED% ...
+GOTO :config_selection
+
+:prompt_solution
+SET /A COUNT=0
+FOR /F "tokens=*" %%A IN ('dir /B *.sln') DO (
+  CALL :forloopbody "%%A"
+)
+
+IF "%COUNT%"=="1" (
+  SET SELECTED=%SOLUTIONS.1%
+  ECHO Building %SOLUTIONS.1% as it is the only solution that was found ...
+  GOTO :config_selection
+)
+
+ECHO Found the following solutions:
+FOR /F "tokens=2* delims=.=" %%A IN ('SET SOLUTIONS.') DO ECHO %%A = %%B
+ECHO.
+SET /P SOLUTIONINDEX=Which solution to build? Type the number: 
+
+SET SELECTED=""
+FOR /F "tokens=2* delims=.=" %%A IN ('SET SOLUTIONS.') DO (
+  IF "%%A"=="%SOLUTIONINDEX%" SET SELECTED=%%B
+)
+
+IF %SELECTED%=="" GOTO :eof
+
+:config_selection
+IF "%~2"==""  GOTO :prompt_config
+
+SET CONFIGURATION=%~2
+ECHO Building configuration %CONFIGURATION% ...
+GOTO :platform_selection
+
+:prompt_config
+SET /P CONFIGURATION=Which configuration to build [Release]: 
+IF "%CONFIGURATION%"=="" SET CONFIGURATION=Release
+
+:platform_selection
+IF "%~3"=="" GOTO :prompt_platform
+  
+SET PLATFORM=%~3
+ECHO Building platform %PLATFORM% ...
+GOTO :clean
+
+:prompt_platform
+SET /P PLATFORM=Which platform to build [Any CPU]: 
+IF "%PLATFORM%"=="" SET PLATFORM=Any CPU
+
+:clean
+IF "%~4"=="" GOTO :prompt_clean
+
+SET CLEANBEFOREBUILD=%~4
+GOTO :main
+
+:prompt_clean
+SET /P CLEANBEFOREBUILD=Would you like to clean before building [n]: 
+IF "%CLEANBEFOREBUILD%"=="" SET CLEANBEFOREBUILD=n
+
+:main
+REM First find the path to the msbuild.exe by performing a registry query
+FOR /F "tokens=1,3 delims=	 " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0"') DO (
+  IF "%%A"=="MSBuildToolsPath" SET MSBUILDPATH=%%B)
+
+REM Then execute msbuild to clean and build the solution
+REM Disable that msbuild creates a cache file of the solution
+SET MSBuildUseNoSolutionCache=1
+REM Run msbuild to clean and then build
+IF "%CLEANBEFOREBUILD%" NEQ "n" (
+  ECHO Cleaning ...
+  %MSBUILDPATH%msbuild.exe %SELECTED% /target:Clean /p:Configuration="%CONFIGURATION%",Platform="%PLATFORM%" /m:2 /nologo /verbosity:q /clp:ErrorsOnly
+)
+ECHO Building ...
+%MSBUILDPATH%msbuild.exe %SELECTED% /target:Build /p:Configuration="%CONFIGURATION%",Platform="%PLATFORM%" /m:2 /nologo /verbosity:q /clp:ErrorsOnly
+
+ECHO.
+ECHO DONE.
+
+:end
+
+PAUSE
+
+GOTO :eof
+
+REM This workaround is necessary so that COUNT gets reevaluated
+:forloopbody
+SET /A COUNT+=1
+SET SOLUTIONS.%COUNT%=%1
+GOTO :eof
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 14385)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 14386)
@@ -43,5 +43,5 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>$(SolutionDir)\bin\</OutputPath>
+    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
@@ -107,11 +107,78 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath>
-      <Private>False</Private>
-    </Reference>
-    <Reference Include="LibSVM-3.12, Version=3.12.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <HintPath>..\..\bin\LibSVM-3.12.dll</HintPath>
-      <Private>False</Private>
+    <Reference Include="ALGLIB-3.7.0">
+      <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Algorithms.GradientDescent-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.GradientDescent-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Analysis-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Collections-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common.Resources-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Core-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Data-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Operators-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Optimization-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Parameters-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Persistence-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.Instances-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Random-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Selection-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="LibSVM-3.12">
+      <HintPath>..\..\..\..\trunk\sources\bin\LibSVM-3.12.dll</HintPath>
     </Reference>
     <Reference Include="System" />
@@ -301,4 +368,22 @@
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RadialBasisFunctions\Distances\AngularDistance.cs" />
+    <Compile Include="RadialBasisFunctions\Distances\DistanceBase.cs" />
+    <Compile Include="RadialBasisFunctions\Distances\EuclidianDistance.cs" />
+    <Compile Include="RadialBasisFunctions\Distances\ManhattenDistance.cs" />
+    <Compile Include="RadialBasisFunctions\Interfaces\IDistance.cs" />
+    <Compile Include="RadialBasisFunctions\Interfaces\IKernelFunction.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\CicularKernel.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\GaussianKernel.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\InverseMultiquadraticKernel .cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\KernelBase.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\LaplacianKernel.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\MultiquadraticKernel.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\PolysplineKernel.cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\ThinPlatePolysplineKernel.cs" />
+    <Compile Include="RadialBasisFunctions\MatrixUtilities.cs" />
+    <Compile Include="RadialBasisFunctions\RadialBasisFunctionModel.cs" />
+    <Compile Include="RadialBasisFunctions\RadialBasisFunctionRegressionSolution.cs" />
+    <Compile Include="RadialBasisFunctions\RadialBasisRegression.cs" />
     <Compile Include="RandomForest\RandomForestClassificationSolution.cs" />
     <Compile Include="RandomForest\RandomForestClassification.cs" />
@@ -320,118 +405,4 @@
     </Compile>
     <Compile Include="TimeSeries\AutoregressiveModeling.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\HeuristicLab.Algorithms.GradientDescent\3.3\HeuristicLab.Algorithms.GradientDescent-3.3.csproj">
-      <Project>{1256B945-EEA9-4BE4-9880-76B5B113F089}</Project>
-      <Name>HeuristicLab.Algorithms.GradientDescent-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm\3.3\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.csproj">
-      <Project>{F409DD9E-1E9C-4EB1-AA3A-9F6E987C6E58}</Project>
-      <Name>HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
-      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
-      <Name>HeuristicLab.Analysis-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
-      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
-      <Name>HeuristicLab.Collections-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
-      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
-      <Name>HeuristicLab.Common.Resources-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
-      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
-      <Name>HeuristicLab.Common-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
-      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
-      <Name>HeuristicLab.Core-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
-      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
-      <Name>HeuristicLab.Data-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
-      <Project>{BB6D334A-4BB6-4674-9883-31A6EBB32CAB}</Project>
-      <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
-      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
-      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
-      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
-      <Name>HeuristicLab.Operators-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
-      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
-      <Name>HeuristicLab.Optimization-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
-      <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
-      <Name>HeuristicLab.Parameters-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
-      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
-      <Name>HeuristicLab.Persistence-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
-      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
-      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj">
-      <Project>{05BAE4E1-A9FA-4644-AA77-42558720159E}</Project>
-      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj">
-      <Project>{5AC82412-911B-4FA2-A013-EDC5E3F3FCC2}</Project>
-      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.csproj">
-      <Project>{07486E68-1517-4B9D-A58D-A38E99AE71AB}</Project>
-      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
-      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
-      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
-      <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
-      <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
-      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
-      <Name>HeuristicLab.Problems.Instances-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
-      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
-      <Name>HeuristicLab.Random-3.3</Name>
-      <Private>False</Private>
-    </ProjectReference>
-    <ProjectReference Include="..\..\HeuristicLab.Selection\3.3\HeuristicLab.Selection-3.3.csproj">
-      <Project>{2C36CD4F-E5F5-43A4-801A-201EA895FE17}</Project>
-      <Name>HeuristicLab.Selection-3.3</Name>
-    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/PreBuildEvent.cmd
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/PreBuildEvent.cmd	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/PreBuildEvent.cmd	(revision 14386)
@@ -0,0 +1,11 @@
+IF EXIST "%ProjectDir%\Properties\AssemblyInfo.cs.frame" SubWCRev "%ProjectDir%\" "%ProjectDir%\Properties\AssemblyInfo.cs.frame" "%ProjectDir%\Properties\AssemblyInfo.cs"
+IF %ERRORLEVEL% NEQ 0 GOTO Error_Handling
+IF EXIST "%ProjectDir%\Plugin.cs.frame" SubWCRev "%ProjectDir%\" "%ProjectDir%\Plugin.cs.frame" "%ProjectDir%\Plugin.cs"
+IF %ERRORLEVEL% NEQ 0 GOTO Error_Handling
+GOTO Done
+
+:Error_Handling
+ECHO There was an error while running subwcrev. Please verify that the *.cs.frame files have been correctly converted to *.cs files, otherwise HeuristicLab won't build. 
+exit 0
+
+:Done
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/AngularDistance.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/AngularDistance.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/AngularDistance.cs	(revision 14386)
@@ -0,0 +1,68 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item("AngularDistance", "The Angluar Distance as defined as a normalized distance measure dependent on the angle between two vectors.\nIt is designed for vectors with all positive coordinates")]
+  public class AngularDistance : DistanceBase<IEnumerable<double>> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected AngularDistance(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected AngularDistance(AngularDistance original, Cloner cloner)
+      : base(original, cloner) { }
+    public AngularDistance() { }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new AngularDistance(this, cloner);
+    }
+    #endregion
+
+    #region statics
+    public static double GetDistance(double[] point1, double[] point2) {
+      if (point1.Length != point2.Length) throw new ArgumentException("Angluar distance not defined on vectors of different length");
+      var innerProduct = point1.Zip(point2, (x, y) => x * y).Sum();
+      return Math.Acos(innerProduct / (Norm(point1) * Norm(point2))) / Math.PI;
+    }
+    public static double GetDistance(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
+      return GetDistance(a.ToArray(), b.ToArray());     //no shortcut evaluation for Angular Distance
+    }
+    #endregion
+    public override double Get(IEnumerable<double> a, IEnumerable<double> b) {
+      return GetDistance(a.ToArray(), b.ToArray());
+    }
+    public override double Get(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
+      return GetDistance(a, b, threshold);
+    }
+
+    private static double Norm(IEnumerable<double> point) {
+      return Math.Sqrt(point.Sum(d => d * d));
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/DistanceBase.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/DistanceBase.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/DistanceBase.cs	(revision 14386)
@@ -0,0 +1,62 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  public abstract class DistanceBase<T> : Item, IDistance<T> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected DistanceBase(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected DistanceBase(DistanceBase<T> original, Cloner cloner)
+      : base(original, cloner) { }
+    protected DistanceBase() { }
+    #endregion
+
+    public abstract double Get(T a, T b);
+    public abstract double Get(T a, T b, double threshold);
+
+    public IComparer<T> GetDistanceComparer(T item) {
+      return new DistanceComparer(item, this);
+    }
+
+    private class DistanceComparer : IComparer<T> {
+      private readonly T item;
+      private readonly IDistance<T> dist;
+
+      public DistanceComparer(T item, IDistance<T> dist) {
+        this.dist = dist;
+        this.item = item;
+      }
+
+      public int Compare(T x, T y) {
+        return dist.Get(x, item).CompareTo(dist.Get(y, item));
+      }
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/EuclidianDistance.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/EuclidianDistance.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/EuclidianDistance.cs	(revision 14386)
@@ -0,0 +1,73 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item("EuclidianNorm", "A norm function that uses Euclidean distance")]
+  public class EuclidianDistance : DistanceBase<IEnumerable<double>> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected EuclidianDistance(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected EuclidianDistance(EuclidianDistance original, Cloner cloner)
+      : base(original, cloner) { }
+    public EuclidianDistance() { }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new EuclidianDistance(this, cloner);
+    }
+    #endregion
+
+    #region statics
+    public static double GetDistance(double[] point1, double[] point2) {
+      if (point1.Length != point2.Length) throw new ArgumentException("Euclidean distance not defined on vectors of different length");
+      return Math.Sqrt(point1.Zip(point2, (a1, b1) => (a1 - b1) * (a1 - b1)).Sum());
+    }
+    public static double GetDistance(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
+      double sum = 0;
+      var it1 = a.GetEnumerator();
+      var it2 = b.GetEnumerator();
+      while (sum > threshold * threshold && it1.MoveNext() && it2.MoveNext()) {
+        var d = it1.Current - it2.Current;
+        sum += d * d;
+      }
+      it1.Dispose();
+      it2.Dispose();
+      return sum;
+    }
+    #endregion
+
+    public override double Get(IEnumerable<double> a, IEnumerable<double> b) {
+      return GetDistance(a.ToArray(), b.ToArray());
+    }
+    public override double Get(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
+      return GetDistance(a, b, threshold);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/ManhattenDistance.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/ManhattenDistance.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/ManhattenDistance.cs	(revision 14386)
@@ -0,0 +1,74 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item("ManhattenDistance", "A distance function that uses Block distance")]
+  public class ManhattenDistance : DistanceBase<IEnumerable<double>> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected ManhattenDistance(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected ManhattenDistance(ManhattenDistance original, Cloner cloner)
+      : base(original, cloner) { }
+    public ManhattenDistance() { }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new ManhattenDistance(this, cloner);
+    }
+    #endregion
+
+    public static double GetDistance(double[] point1, double[] point2) {
+      if (point1.Length != point2.Length) throw new ArgumentException("Manhatten distance not defined on vectors of different length");
+      return point1.Zip(point2, (a1, b1) => Math.Abs(a1 - b1)).Sum();
+    }
+
+    public static double GetDistance(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
+      double sum = 0;
+      var it1 = a.GetEnumerator();
+      var it2 = b.GetEnumerator();
+      while (sum > threshold && it1.MoveNext() && it2.MoveNext()) {
+        sum += Math.Abs(it1.Current - it2.Current);
+      }
+      it1.Dispose();
+      it2.Dispose();
+      return sum;
+    }
+
+    public override double Get(IEnumerable<double> a, IEnumerable<double> b) {
+      return GetDistance(a.ToArray(), b.ToArray());
+    }
+
+    public override double Get(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
+      return GetDistance(a, b, threshold);
+    }
+
+
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IDistance.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IDistance.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IDistance.cs	(revision 14386)
@@ -0,0 +1,49 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Collections.Generic;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  public interface IDistance<in T> : IItem {
+    /// <summary>
+    /// Calculates a distance measure between two aribitrary Vectors. The distance value d is 
+    /// 1.) positive  d(x,y)>0
+    /// 2.) symmetric d(x,y) = d(y,x)
+    /// 3.) zero-reflexive d(x,x) =0;
+    /// </summary>
+    /// <param name="a">an array representing point x</param>
+    /// <param name="b">>an array representing point y</param>
+    /// <returns>d(x,y)</returns>
+    double Get(T a, T b);
+    /// <summary>
+    /// Calculates the correct kernel measure if it is smaller than threshold, but any value greater then threshold if the correct distance is greater.
+    /// This is for performace only
+    /// </summary>
+    /// <param name="a"></param>
+    /// <param name="b"></param>
+    /// <param name="threshold"></param>
+    /// <returns></returns>
+    double Get(T a, T b, double threshold);
+
+    IComparer<T> GetDistanceComparer(T item);
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IKernelFunction.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IKernelFunction.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IKernelFunction.cs	(revision 14386)
@@ -0,0 +1,41 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  public interface IKernelFunction<in T> : ICovarianceFunction {
+    /// <summary>
+    /// Calculates a kernel measure between two aribitrary Vectors. The distance value d is 
+    /// 1.) positive  d(x,y)>0
+    /// 2.) symmetric d(x,y) = d(y,x)
+    /// 3.) only dependent on the norm ||x-y|| (Radial Basis criterium)
+    /// </summary>
+    /// <param name="a">an array representing point x</param>
+    /// <param name="b">>an array representing point y</param>
+    /// <returns>d(x,y)</returns>
+    double Get(T a, T b);
+
+
+    IFixedValueParameter<DoubleValue> BetaParameter { get; }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs	(revision 14386)
@@ -0,0 +1,60 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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("CircularKernel", "A circular kernel function")]
+  public class CircularKernel<T> : KernelBase<T> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected CircularKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected CircularKernel(CircularKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    public CircularKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction 2*pi*(acos(-d)-d*(1-n²)^(0.5)) where n = ||x-c|| and d = n/beta", new DoubleValue(2)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new CircularKernel<T>(this, cloner);
+    }
+    #endregion
+
+    protected override double Get(double norm) {
+      if (norm >= Beta || Math.Abs(Beta) < double.Epsilon) return 0;
+      var d = norm / Beta;
+      return Math.Acos(-d) - d * Math.Sqrt(1 - d * d) - Math.PI / 2;
+    }
+
+    protected override double GetGradient(double norm) {
+      if (Beta <= 0) return double.NaN;
+      if (Beta < norm) return 0;
+      return 2 * norm * Math.Sqrt(Beta * Beta - norm * norm) / (Beta * Beta * Beta);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs	(revision 14386)
@@ -0,0 +1,59 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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("GaussianKernel", "A kernel function that uses Gaussian function")]
+  public class GaussianKernel<T> : KernelBase<T> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected GaussianKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected GaussianKernel(GaussianKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    public GaussianKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction exp(-||x-c||/beta²)", new DoubleValue(2)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new GaussianKernel<T>(this, cloner);
+    }
+    #endregion
+
+    protected override double Get(double norm) {
+      if (Math.Abs(Beta) < double.Epsilon) return 0;
+      return Math.Abs(norm) < double.Epsilon ? 1 : Math.Exp(-norm * norm / (Beta * Beta));
+    }
+
+    protected override double GetGradient(double norm) {
+      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
+      norm *= norm;
+      return 2 * norm * Math.Exp(-norm / (Beta * Beta)) / (Beta * Beta * Beta);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel .cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel .cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel .cs	(revision 14386)
@@ -0,0 +1,58 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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<T> : KernelBase<T> {
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected InverseMultiquadraticKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected InverseMultiquadraticKernel(InverseMultiquadraticKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    public InverseMultiquadraticKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction sqrt(1+||x-c||^2/beta)", new DoubleValue(2)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new InverseMultiquadraticKernel<T>(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));
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs	(revision 14386)
@@ -0,0 +1,168 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  public abstract class KernelBase<T> : ParameterizedNamedItem, IKernelFunction<T> {
+
+    #region Parameternames
+    private const string DistanceParameterName = "Distance";
+    protected const string BetaParameterName = "Beta";
+    #endregion
+    #region Parameterproperties
+    public ValueParameter<IDistance<T>> DistanceParameter
+    {
+      get { return Parameters[DistanceParameterName] as ValueParameter<IDistance<T>>; }
+    }
+
+    public IFixedValueParameter<DoubleValue> BetaParameter
+    {
+      get { return Parameters[BetaParameterName] as FixedValueParameter<DoubleValue>; }
+    }
+
+    #endregion
+    #region Properties
+    public IDistance<T> Distance
+    {
+      get { return DistanceParameter.Value; }
+    }
+
+    public double Beta
+    {
+      get { return BetaParameter.Value.Value; }
+    }
+
+    #endregion
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected KernelBase(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+
+    protected KernelBase(KernelBase<T> original, Cloner cloner)
+      : base(original, cloner) { }
+
+    protected KernelBase() {
+      Parameters.Add(new ValueParameter<IDistance<T>>(DistanceParameterName, "The distance function used for kernel calculation"));
+      DistanceParameter.Value = new EuclidianDistance() as IDistance<T>;
+    }
+    #endregion
+
+    public double Get(T a, T b) {
+      return Get(Distance.Get(a, b));
+    }
+
+    protected abstract double Get(double norm);
+
+    public int GetNumberOfParameters(int numberOfVariables) {
+      return 1;
+    }
+
+    public void SetParameter(double[] p) {
+      if (p != null && p.Length == 1) BetaParameter.Value.Value = p[0];
+    }
+
+    public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) {
+      if (p == null || p.Length != 1) throw new ArgumentException("Illegal parametrization");
+      var myClone = (KernelBase<T>)Clone(new Cloner());
+      myClone.BetaParameter.Value.Value = p[0];
+      var cov = new ParameterizedCovarianceFunction {
+        Covariance = (x, i, j) => myClone.Get(GetNorm(x, x, i, j, columnIndices)),
+        CrossCovariance = (x, xt, i, j) => myClone.Get(GetNorm(x, xt, i, j, columnIndices)),
+        CovarianceGradient = (x, i, j) => new List<double> { myClone.GetGradient(GetNorm(x, x, i, j, columnIndices)) }
+      };
+      return cov;
+    }
+
+    protected abstract double GetGradient(double norm);
+
+    protected double GetNorm(double[,] x, double[,] xt, int i, int j, int[] columnIndices) {
+      var dist = Distance as IDistance<IEnumerable<double>>;
+      if (dist == null) throw new ArgumentException("The Distance needs to apply to double-Vectors");
+      var r1 = new IndexedEnumerable(x, i, columnIndices);
+      var r2 = new IndexedEnumerable(xt, j, columnIndices);
+      return dist.Get(r1, r2);
+    }
+    internal class IndexedEnumerable : IEnumerable<double> {
+      private readonly double[,] data;
+      private readonly int row;
+      private readonly int[] columnIndices;
+
+      public IndexedEnumerable(double[,] data, int row, int[] columnIndices) {
+        this.data = data;
+        this.row = row;
+        this.columnIndices = columnIndices;
+      }
+
+      public IEnumerator<double> GetEnumerator() {
+        return new IndexedEnumerator(data, row, columnIndices);
+      }
+
+      IEnumerator IEnumerable.GetEnumerator() {
+        return new IndexedEnumerator(data, row, columnIndices);
+      }
+    }
+    internal class IndexedEnumerator : IEnumerator<double> {
+      private readonly IEnumerator<int> column;
+      private readonly double[,] data;
+      private readonly int row;
+
+      public IndexedEnumerator(double[,] data, int row, int[] columnIndices) {
+        this.data = data;
+        this.row = row;
+        column = ((IEnumerable<int>)columnIndices).GetEnumerator();
+      }
+
+      public double Current
+      {
+        get { return data[row, column.Current]; }
+      }
+
+      object IEnumerator.Current
+      {
+        get
+        {
+          return data[row, column.Current];
+        }
+      }
+
+      public void Dispose() { }
+
+      public bool MoveNext() {
+        return column.MoveNext();
+      }
+
+      public void Reset() {
+        column.Reset();
+      }
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs	(revision 14386)
@@ -0,0 +1,57 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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("LaplacianKernel", "A kernel function that uses an exponential function.\nIt is equvalent to the Gaussiankernel but less suseptible to improper values of beta")]
+  public class LaplacianKernel<T> : KernelBase<T> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected LaplacianKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected LaplacianKernel(LaplacianKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    public LaplacianKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction exp(-||x-c||/beta)", new DoubleValue(2)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new LaplacianKernel<T>(this, cloner);
+    }
+    #endregion
+
+    protected override double Get(double norm) {
+      return Math.Abs(Beta) < double.Epsilon ? 0 : Math.Exp(-norm / Beta);
+    }
+
+    protected override double GetGradient(double norm) {
+      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
+      return norm * Math.Exp(-norm / Beta) / (Beta * Beta);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs	(revision 14386)
@@ -0,0 +1,59 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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("MultiquadraticKernel", "A kernel function that uses the multiquadratic function")]
+  public class MultiquadraticKernel<T> : KernelBase<T> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected MultiquadraticKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected MultiquadraticKernel(MultiquadraticKernel<T> original, Cloner cloner)
+                : base(original, cloner) { }
+
+    public MultiquadraticKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction sqrt(1+||x-c||²/beta)", new DoubleValue(2)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new MultiquadraticKernel<T>(this, cloner);
+    }
+    #endregion
+    protected override double Get(double norm) {
+      return Math.Abs(Beta) < double.Epsilon ? 0 : 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.Sqrt((norm + Beta) / Beta));
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs	(revision 14386)
@@ -0,0 +1,57 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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("PolysplineKernel", "A kernel function that uses the multiquadratic function")]
+  public class PolysplineKernel<T> : KernelBase<T> {
+
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected PolysplineKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected PolysplineKernel(PolysplineKernel<T> original, Cloner cloner)
+                : base(original, cloner) { }
+    public PolysplineKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The Beta in the kernelfunction ||x-c||^Beta", new DoubleValue(1.5)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new PolysplineKernel<T>(this, cloner);
+    }
+    #endregion
+
+    protected override double Get(double norm) {
+      return Math.Pow(norm, Beta);
+    }
+
+    protected override double GetGradient(double norm) {
+      return Math.Pow(norm, Beta) * Math.Log(Beta);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs	(revision 14386)
@@ -0,0 +1,61 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#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("ThinPlatePolysplineKernel", "A kernel function that uses the ThinPlatePolyspline function")]
+  public class ThinPlatePolysplineKernel<T> : KernelBase<T> {
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected ThinPlatePolysplineKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected ThinPlatePolysplineKernel(ThinPlatePolysplineKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    public ThinPlatePolysplineKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The Beta in the kernelfunction ||x-c||^(2*Beta)*log(||x-c||^Beta)", new DoubleValue(1)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new ThinPlatePolysplineKernel<T>(this, cloner);
+    }
+    #endregion
+
+    protected override double Get(double norm) {
+      if (Math.Pow(norm, Beta) <= 0) return 0;
+      return Math.Pow(norm, Beta * 2) * Math.Log(1 + Math.Pow(norm, Beta));
+    }
+
+    protected override double GetGradient(double norm) {
+      if (Math.Pow(norm, Beta) <= 0) return double.NaN;
+      var ax = Math.Pow(norm, Beta);
+      var a2x = ax * ax;
+      var a3x = a2x * ax;
+      var loga = Math.Log(norm);
+      return 2 * a2x * loga * Math.Log(ax + 1) + a3x * loga / (ax + 1);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/MatrixUtilities.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/MatrixUtilities.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/MatrixUtilities.cs	(revision 14386)
@@ -0,0 +1,239 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  internal static class MatrixUtilities {
+
+    public static T[,] To2D<T>(T[][] source) {
+      try {
+        var firstDim = source.Length;
+        var secondDim = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular
+        var result = new T[firstDim, secondDim];
+        for (var i = 0; i < firstDim; ++i)
+          for (var j = 0; j < secondDim; ++j)
+            result[i, j] = source[i][j];
+        return result;
+      }
+      catch (InvalidOperationException) {
+        throw new InvalidOperationException("The given jagged array is not rectangular.");
+      }
+    }
+
+    public static DoubleMatrix SortRows(this DoubleMatrix x, int c1) {
+      var sortable = new List<double[]>();
+      for (var i = 0; i < x.Rows; i++)
+        sortable.Add(SelectRow(x, i).ToArray());
+      return new DoubleMatrix(To2D(sortable.OrderBy(p => p[c1]).ToArray()));
+    }
+    public static DoubleMatrix Ones(int rows, int cols) {
+      var val = new double[rows, cols];
+      for (var i = 0; i < rows; i++)
+        for (var j = 0; j < cols; j++)
+          val[i, j] = 1;
+      return new DoubleMatrix(val);
+    }
+    public static DoubleMatrix Identity(int rows, int cols) {
+      var val = new double[rows, cols];
+      for (var i = 0; i < Math.Min(rows, cols); i++)
+        val[i, i] = 1;
+      return new DoubleMatrix(val);
+    }
+    public static DoubleMatrix Elementwise(this DoubleMatrix m, Func<double, double> func) {
+      var val = new double[m.Rows, m.Columns];
+      for (var i = 0; i < m.Rows; i++)
+        for (var j = 0; j < m.Columns; j++)
+          val[i, j] = func.Invoke(m[i, j]);
+      return new DoubleMatrix(val);
+    }
+    public static DoubleMatrix Elementwise(this DoubleMatrix m, DoubleMatrix m1, Func<double, double, double> func) {
+      if (m.Rows != m1.Rows || m.Columns != m1.Columns) throw new ArgumentException("Matrices are of different sizes");
+      var val = new double[m.Rows, m.Columns];
+      for (var i = 0; i < m.Rows; i++)
+        for (var j = 0; j < m.Columns; j++)
+          val[i, j] = func.Invoke(m[i, j], m1[i, j]);
+      return new DoubleMatrix(val);
+    }
+    public static DoubleMatrix Elementwise(this DoubleMatrix m, DoubleMatrix m1, DoubleMatrix m2, Func<double, double, double, double> func) {
+      if (m.Rows != m1.Rows || m.Columns != m1.Columns || m1.Rows != m2.Rows || m1.Columns != m2.Columns) throw new ArgumentException("Matrices are of different sizes");
+      var val = new double[m.Rows, m.Columns];
+      for (var i = 0; i < m.Rows; i++)
+        for (var j = 0; j < m.Columns; j++)
+          val[i, j] = func.Invoke(m[i, j], m1[i, j], m2[i, j]);
+      return new DoubleMatrix(val);
+    }
+    public static DoubleMatrix SelectRow(this DoubleMatrix m, int row) {
+      var m1 = new DoubleMatrix(1, m.Columns);
+      for (var i = 0; i < m.Columns; i++) m1[0, i] = m[row, i];
+      return m1;
+    }
+    public static DoubleMatrix SelectColumn(this DoubleMatrix m, int col) {
+      var m1 = new DoubleMatrix(m.Rows, 1);
+      for (var i = 0; i < m.Rows; i++) m1[i, 0] = m[i, col];
+      return m1;
+    }
+    public static DoubleMatrix RowBind(this DoubleMatrix m1, DoubleMatrix m2) {
+      if (m1.Columns != m2.Columns) throw new ArgumentException("Matrices need to have the same number of columns for RowBind");
+      var m = new DoubleMatrix(m1.Rows + m2.Rows, m1.Columns);
+      for (var i = 0; i < m1.Rows; i++)
+        for (var j = 0; j < m.Columns; j++)
+          m[i, j] = m1[i, j];
+      for (var i = 0; i < m2.Rows; i++)
+        for (var j = 0; j < m.Columns; j++)
+          m[i + m1.Rows, j] = m2[i, j];
+      return m;
+
+    }
+    public static DoubleMatrix ColumnBind(this DoubleMatrix m1, DoubleMatrix m2) {
+      if (m1.Rows != m2.Rows) throw new ArgumentException("Matrices need to have the same number of rows for ColumnBind");
+      var m = new DoubleMatrix(m1.Rows, m1.Columns + m1.Columns);
+      for (var i = 0; i < m1.Rows; i++) {
+        for (var j = 0; j < m1.Columns; j++)
+          m[i, j] = m1[i, j];
+        for (var j = 0; j < m2.Columns; j++)
+          m[i, j + m1.Columns] = m2[i, j];
+      }
+      return m;
+    }
+    public static DoubleMatrix Select(this DoubleMatrix m, int[] rows, int[] cols) {
+      var res = new DoubleMatrix(rows.Length, cols.Length);
+      for (var i = 0; i < res.Rows; i++) {
+        for (var j = 0; j < res.Columns; j++)
+          res[i, j] = m[rows[i], cols[j]];
+      }
+      return res;
+    }
+    public static DoubleMatrix Select(this DoubleMatrix m, int[] rows) {
+      return Select(m, rows, GetIndexVector(m.Columns));
+    }
+    public static int[] GetIndexVector(int size) {
+      var res = new int[size];
+      for (var i = 0; i < size; i++)
+        res[i] = i;
+      return res;
+    }
+    public static DoubleMatrix Transpose(this DoubleMatrix m) {
+      var res = new DoubleMatrix(m.Columns, m.Rows);
+      for (var i = 0; i < res.Rows; i++)
+        for (var j = 0; j < res.Columns; j++)
+          res[i, j] = m[j, i];
+      return res;
+    }
+    public static DoubleMatrix ToRow(IEnumerable<double> values) {
+      var arr = values.ToArray();
+      var res = new DoubleMatrix(1, arr.Length);
+      for (var i = 0; i < arr.Length; i++) res[0, i] = arr[i];
+      return res;
+    }
+    public static double[] Min(this DoubleMatrix m, int dim) {
+      if (dim != 0 && dim != 1) throw new ArgumentException("Can only find the minimum along rows or colums");
+      var res = new double[dim == 0 ? m.Rows : m.Columns];
+      for (var i = 0; i < res.Length; i++)
+        res[i] = (dim == 0 ? SelectRow(m, i) : SelectColumn(m, i)).Min();
+      return res;
+    }
+    public static double[] Max(this DoubleMatrix m, int dim) {
+      if (dim != 0 && dim != 1) throw new ArgumentException("Can only find the minimum along rows or colums");
+      var res = new double[dim == 0 ? m.Rows : m.Columns];
+      for (var i = 0; i < res.Length; i++)
+        res[i] = (dim == 0 ? SelectRow(m, i) : SelectColumn(m, i)).Max();
+      return res;
+    }
+    public static double[] GetElementVector(int size) {
+      var res = new double[size];
+      for (var d = 1; d <= size; d++) {
+        res[d - 1] = d;
+      }
+      return res;
+    }
+    public static double[] GetRange(double min, double max, int length) {
+      if (length < 2 || min > max) throw new ArgumentException("can not create range of length: " + length + " from " + min + " to " + max);
+      var res = new double[length];
+      var step = (max - min) / (length - 1);
+      res[0] = min;
+      for (var i = 1; i < length; i++)
+        res[i] = step + res[i - 1];
+      return res;
+    }
+    public static int[] GetRange(int min, int max) {
+      if (min > max) throw new ArgumentException("can not create range from " + min + " to " + max);
+      var res = new int[max - min + 1];
+      var i = 0;
+      for (var v = min; v <= max; v++)
+        res[i++] = v;
+      return res;
+    }
+    public static bool IsEqualTo(this DoubleMatrix m1, DoubleMatrix m2) {
+      if (m1.Rows != m2.Rows) return false;
+      if (m1.Columns != m2.Columns) return false;
+      return m1.SequenceEqual(m2);
+    }
+    public static DoubleMatrix ToColumnVector(this IEnumerable<double> values) {
+      var arr = values.ToArray();
+      var res = new DoubleMatrix(arr.Length, 1);
+      for (var i = 0; i < arr.Length; i++)
+        res[i, 0] = arr[i];
+      return res;
+    }
+    public static DoubleMatrix ToMatrix<T>(this IEnumerable<T> rows) where T : IEnumerable<double> {
+      return new DoubleMatrix(To2D(rows.Select(x => x.ToArray()).ToArray())); //not the fastest way to do it
+
+    }
+
+    /// <summary>
+    /// m need to be symmetric positive definit
+    /// </summary>
+    /// <param name="m"></param>
+    /// <returns></returns>
+    public static DoubleMatrix Invert(this DoubleMatrix m) {
+      int info;
+      alglib.matinvreport report;
+      var upper = m.CloneAsMatrix();
+      alglib.rmatrixinverse(ref upper, out info, out report);
+      if (info != 1) throw new ArgumentException("Could not invert matrix. Is ist quadratic symmetric positive definite?");
+      return new DoubleMatrix(upper);
+    }
+    public static DoubleMatrix Mul(this DoubleMatrix left, DoubleMatrix right) {
+      if (left.Columns != right.Rows) throw new ArgumentException("Dims dont match");
+      var res = new double[left.Rows, right.Columns];
+      alglib.rmatrixgemm(left.Rows, right.Columns, left.Columns, 1, left.CloneAsMatrix(), 0, 0, 0, right.CloneAsMatrix(), 0, 0, 0, 0, ref res, 0, 0);
+      return new DoubleMatrix(res);
+    }
+    public static DoubleMatrix Solve(this DoubleMatrix a, DoubleMatrix b) {
+      if (b.Columns != 1 || a.Rows != b.Rows) throw new ArgumentException("This system can not be solved due to dimensions");
+      var b1 = b.ToArray();
+      double[] x;
+      int info;
+      alglib.densesolverlsreport denseSolveRep;//what is this used for? In HeuristicLab.Algorithms.DataAnalysis.GaussianProcessSurrogate is a use-case similar to this one. What do you normally do with the rep?
+      alglib.rmatrixsolvels(a.CloneAsMatrix(), a.Rows, a.Columns, b1, 0.0, out info, out denseSolveRep, out x);
+      if (info != 1) {
+        throw new ArgumentException("This system can not be solved due to content or numerics");
+      }
+
+      return x.ToColumnVector();
+    }
+
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionModel.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionModel.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionModel.cs	(revision 14386)
@@ -0,0 +1,142 @@
+#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  /// <summary>
+  /// Represents a Radial Basis Function regression model.
+  /// </summary>
+  [StorableClass]
+  [Item("RBFModel", "Represents a Gaussian process posterior.")]
+  public sealed class RadialBasisFunctionModel : RegressionModel, IConfidenceRegressionModel {
+    public override IEnumerable<string> VariablesUsedForPrediction
+    {
+      get { return allowedInputVariables; }
+    }
+
+    [Storable]
+    private string[] allowedInputVariables;
+    public string[] AllowedInputVariables
+    {
+      get { return allowedInputVariables; }
+    }
+
+    [Storable]
+    private double[] alpha;
+    [Storable]
+    private IDataset trainingDataset; // it is better to store the original training dataset completely because this is more efficient in persistence
+    [Storable]
+    private int[] trainingRows;
+    [Storable]
+    private IKernelFunction<double[]> kernel;
+    [Storable]
+    private DoubleMatrix gramInvert;
+
+
+    [StorableConstructor]
+    private RadialBasisFunctionModel(bool deserializing) : base(deserializing) { }
+    private RadialBasisFunctionModel(RadialBasisFunctionModel original, Cloner cloner)
+      : base(original, cloner) {
+      // shallow copies of arrays because they cannot be modified
+      trainingRows = original.trainingRows;
+      allowedInputVariables = original.allowedInputVariables;
+      alpha = original.alpha;
+      trainingDataset = original.trainingDataset;
+      kernel = original.kernel;
+    }
+    public RadialBasisFunctionModel(IDataset dataset, string targetVariable, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows, IKernelFunction<double[]> kernel)
+      : base(targetVariable) {
+      name = ItemName;
+      description = ItemDescription;
+      this.allowedInputVariables = allowedInputVariables.ToArray();
+      trainingRows = rows.ToArray();
+      trainingDataset = dataset;
+      this.kernel = (IKernelFunction<double[]>)kernel.Clone();
+      try {
+        var data = ExtractData(dataset, trainingRows);
+        var qualities = dataset.GetDoubleValues(targetVariable, trainingRows).ToArray();
+        int info;
+        alglib.densesolverlsreport denseSolveRep;
+        var gr = BuildGramMatrix(data);
+        alglib.rmatrixsolvels(gr, data.Length + 1, data.Length + 1, qualities.Concat(new[] { 0.0 }).ToArray(), 0.0, out info, out denseSolveRep, out alpha);
+        if (info != 1) throw new ArgumentException("Could not create Model.");
+        gramInvert = new DoubleMatrix(gr).Invert();
+      }
+      catch (alglib.alglibexception ae) {
+        // wrap exception so that calling code doesn't have to know about alglib implementation
+        throw new ArgumentException("There was a problem in the calculation of the RBF process model", ae);
+      }
+    }
+    private double[][] ExtractData(IDataset dataset, IEnumerable<int> rows) {
+      return rows.Select(r => allowedInputVariables.Select(v => dataset.GetDoubleValue(v, r)).ToArray()).ToArray();
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RadialBasisFunctionModel(this, cloner);
+    }
+
+    #region IRegressionModel Members
+    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
+      var solutions = ExtractData(dataset, rows);
+      var data = ExtractData(trainingDataset, trainingRows);
+      return solutions.Select(solution => alpha.Zip(data, (a, d) => a * kernel.Get(solution, d)).Sum() + 1 * alpha[alpha.Length - 1]).ToArray();
+    }
+    public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
+      return new RadialBasisFunctionRegressionSolution(this, new RegressionProblemData(problemData));
+    }
+    #endregion
+
+    public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) {
+      var data = ExtractData(trainingDataset, trainingRows);
+      return ExtractData(dataset, rows).Select(x => GetVariance(x, data));
+    }
+    public double LeaveOneOutCrossValidationRootMeanSquaredError() {
+      return Math.Sqrt(alpha.Select((t, i) => t / gramInvert[i, i]).Sum(d => d * d) / gramInvert.Rows);
+    }
+
+    #region helpers
+    private double[,] BuildGramMatrix(double[][] data) {
+      var size = data.Length + 1;
+      var gram = new double[size, size];
+      for (var i = 0; i < size; i++)
+        for (var j = i; j < size; j++) {
+          if (j == size - 1 && i == size - 1) gram[i, j] = 0;
+          else if (j == size - 1 || i == size - 1) gram[j, i] = gram[i, j] = 1;
+          else gram[j, i] = gram[i, j] = kernel.Get(data[i], data[j]); //symmteric Matrix --> half of the work
+        }
+      return gram;
+    }
+    private double GetVariance(double[] solution, IEnumerable<double[]> data) {
+      var phiT = data.Select(x => kernel.Get(x, solution)).Concat(new[] { 1.0 }).ToColumnVector();
+      var res = phiT.Transpose().Mul(gramInvert.Mul(phiT))[0, 0];
+      return res > 0 ? res : 0;
+    }
+    #endregion
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionRegressionSolution.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionRegressionSolution.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionRegressionSolution.cs	(revision 14386)
@@ -0,0 +1,49 @@
+#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Algorithms.DataAnalysis;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  /// <summary>
+  /// Represents a Radial Basis Function regression solution for a regression problem which can be visualized in the GUI.
+  /// </summary>
+  [Item("RBFRegressionSolution", "Represents an RBF solution for a regression problem which can be visualized in the GUI.")]
+  [StorableClass]
+  public sealed class RadialBasisFunctionRegressionSolution : ConfidenceRegressionSolution {
+
+    [StorableConstructor]
+    private RadialBasisFunctionRegressionSolution(bool deserializing)
+      : base(deserializing) {
+    }
+    private RadialBasisFunctionRegressionSolution(RadialBasisFunctionRegressionSolution original, Cloner cloner)
+      : base(original, cloner) { }
+    public RadialBasisFunctionRegressionSolution(RadialBasisFunctionModel model, IRegressionProblemData problemData)
+      : base(model, problemData) { }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RadialBasisFunctionRegressionSolution(this, cloner);
+    }
+  }
+}
Index: branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisRegression.cs
===================================================================
--- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisRegression.cs	(revision 14386)
+++ branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisRegression.cs	(revision 14386)
@@ -0,0 +1,106 @@
+#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  /// <summary>
+  /// Linear regression data analysis algorithm.
+  /// </summary>
+  [Item("Radial Basis Function Regression (RBF-R)", "Radial basis function regression data analysis algorithm (uses for ALGLIB).")]
+  [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 100)]
+  [StorableClass]
+  public sealed class RadialBasisRegression : FixedDataAnalysisAlgorithm<IRegressionProblem> {
+    private const string RadialBasisRegressionModelResultName = "RBF regression solution";
+
+
+    #region Parameternames
+    private const string Kernelname = "Kernel";
+    #endregion
+
+    #region Paramterproperties
+    public ValueParameter<IKernelFunction<double[]>> KernelParameter
+    {
+      get { return Parameters[Kernelname] as ValueParameter<IKernelFunction<double[]>>; }
+    }
+    #endregion
+
+    #region Properties
+    public IKernelFunction<double[]> Kernel
+    {
+      get { return KernelParameter.Value; }
+    }
+
+    #endregion
+
+    [StorableConstructor]
+    private RadialBasisRegression(bool deserializing) : base(deserializing) { }
+    private RadialBasisRegression(RadialBasisRegression original, Cloner cloner)
+      : base(original, cloner) {
+    }
+    public RadialBasisRegression() {
+      Problem = new RegressionProblem();
+      Parameters.Add(new ValueParameter<IKernelFunction<double[]>>(Kernelname, "The radial basis function"));
+      var kernel = new PolysplineKernel<double[]>();
+      KernelParameter.Value = kernel;
+      kernel.BetaParameter.Value.Value = 1;
+    }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RadialBasisRegression(this, cloner);
+    }
+
+    #region regression
+    protected override void Run() {
+      double loocvrmse, cvRmsError;
+      var solution = CreateRadialBasisRegressionSolution(Problem.ProblemData, Kernel, out loocvrmse, out cvRmsError);
+      Results.Add(new Result(RadialBasisRegressionModelResultName, "The RBF regression solution.", solution));
+      Results.Add(new Result("LOOCVRMSE", "The root of the mean of squared errors of a leave-one-out-cross-validation on the trainingsset (This is not the RSME on the trainingset)", new DoubleValue(loocvrmse)));
+      Results.Add(new Result("Estimated root mean square error (cross-validation)", "The estimated root of the mean of squared errors of the linear regression solution via cross validation.", new DoubleValue(cvRmsError)));
+    }
+
+    public static IConfidenceRegressionSolution CreateRadialBasisRegressionSolution(IRegressionProblemData problemData, IKernelFunction<double[]> kernel, out double loocvRmsError, out double cvRmsError) {
+      var model = new RadialBasisFunctionModel(problemData.Dataset, problemData.TargetVariable, problemData.AllowedInputVariables, problemData.TrainingIndices, kernel);
+      loocvRmsError = model.LeaveOneOutCrossValidationRootMeanSquaredError();
+      cvRmsError = Math.Sqrt(model.GetEstimatedValues(problemData.Dataset, problemData.TestIndices)
+        .Zip(problemData.TargetVariableTestValues, (a, b) => (a - b) * (a - b))
+        .Sum());
+      var solution = (RadialBasisFunctionRegressionSolution)model.CreateRegressionSolution((IRegressionProblemData)problemData.Clone());
+      solution.Model.Name = "Radial Basis Regression Model";
+      solution.Name = "Radial Basis Regression Solution";
+      return solution;
+    }
+    #endregion
+
+    #region helpers
+    #endregion
+  }
+}
