Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16332


Ignore:
Timestamp:
11/28/18 22:21:11 (6 years ago)
Author:
gkronber
Message:

#2915: merged r16241:16309 (current HEAD) from HL trunk to branch

Location:
branches/2915-AbsoluteSymbol
Files:
1 deleted
54 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/2915-AbsoluteSymbol

  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis

  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4

  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs

    r16240 r16332  
    262262
    263263
     264    public bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     265      return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     266    }
     267
     268    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     269      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     270
     271      var regressionProblemData = problemData as IRegressionProblemData;
     272      if (regressionProblemData != null)
     273        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     274
     275      var classificationProblemData = problemData as IClassificationProblemData;
     276      if (classificationProblemData != null)
     277        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     278
     279      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     280    }
     281
    264282    IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {
    265283      return new NearestNeighbourRegressionSolution(this, new RegressionProblemData(problemData));
  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs

    r16240 r16332  
    130130    }
    131131
     132
     133    public bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     134      return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     135    }
     136
     137    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     138      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     139
     140      var regressionProblemData = problemData as IRegressionProblemData;
     141      if (regressionProblemData != null)
     142        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     143
     144      var classificationProblemData = problemData as IClassificationProblemData;
     145      if (classificationProblemData != null)
     146        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     147
     148      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     149    }
     150
    132151    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    133152      return new NeuralNetworkEnsembleRegressionSolution(this, new RegressionEnsembleProblemData(problemData));
  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs

    r16240 r16332  
    134134    }
    135135
     136    public bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     137      return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     138    }
     139
     140    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     141      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     142
     143      var regressionProblemData = problemData as IRegressionProblemData;
     144      if (regressionProblemData != null)
     145        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     146
     147      var classificationProblemData = problemData as IClassificationProblemData;
     148      if (classificationProblemData != null)
     149        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     150
     151      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     152    }
     153
    136154    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    137155      return new NeuralNetworkRegressionSolution(this, new RegressionProblemData(problemData));
  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs

    r15786 r16332  
    286286    }
    287287
     288    public bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     289      return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     290    }
     291
     292    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     293      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     294
     295      var regressionProblemData = problemData as IRegressionProblemData;
     296      if (regressionProblemData != null)
     297        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     298
     299      var classificationProblemData = problemData as IClassificationProblemData;
     300      if (classificationProblemData != null)
     301        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     302
     303      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     304    }
     305
    288306    public static RandomForestModel CreateRegressionModel(IRegressionProblemData problemData, int nTrees, double r, double m, int seed,
    289307      out double rmsError, out double outOfBagRmsError, out double avgRelError, out double outOfBagAvgRelError) {
  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs

    r15854 r16332  
    126126      return new SupportVectorRegressionSolution(this, new RegressionProblemData(problemData));
    127127    }
    128     #endregion
     128
     129    public bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     130      return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     131    }
     132    #endregion
     133
     134    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     135      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     136
     137      var regressionProblemData = problemData as IRegressionProblemData;
     138      if (regressionProblemData != null)
     139        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     140
     141      var classificationProblemData = problemData as IClassificationProblemData;
     142      if (classificationProblemData != null)
     143        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     144
     145      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     146    }
    129147
    130148    #region IClassificationModel Members
     
    153171    }
    154172    #endregion
     173
    155174    private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) {
    156175      // calculate predictions for the currently requested rows
  • branches/2915-AbsoluteSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClusteringModel.cs

    r15583 r16332  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Drawing;
     
    3435  [StorableClass]
    3536  [Item("KMeansClusteringModel", "Represents a k-Means clustering model.")]
    36   public sealed class KMeansClusteringModel : NamedItem, IClusteringModel {
     37  public sealed class KMeansClusteringModel : DataAnalysisModel, IClusteringModel {
    3738    public static new Image StaticItemImage {
    3839      get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; }
    3940    }
    4041
    41     public IEnumerable<string> VariablesUsedForPrediction {
     42    public override IEnumerable<string> VariablesUsedForPrediction {
    4243      get { return allowedInputVariables; }
    4344    }
     
    8485    }
    8586
     87    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     88      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     89      return IsDatasetCompatible(problemData.Dataset, out errorMessage);
     90    }
     91
    8692
    8793    public IEnumerable<int> GetClusterValues(IDataset dataset, IEnumerable<int> rows) {
  • branches/2915-AbsoluteSymbol/HeuristicLab.Data

  • branches/2915-AbsoluteSymbol/HeuristicLab.Data/3.3

  • branches/2915-AbsoluteSymbol/HeuristicLab.Data/3.3/StringMatrix.cs

    r15583 r16332  
    209209    }
    210210
     211    public string[,] CloneAsMatrix() {
     212      return (string[,])matrix.Clone();
     213    }
     214
     215    public virtual IEnumerable<string> GetRow(int row) {
     216      for (var col = 0; col < Columns; col++) {
     217        yield return matrix[row, col];
     218      }
     219    }
     220
     221    public virtual IEnumerable<string> GetColumn(int col) {
     222      for (var row = 0; row < Rows; row++) {
     223        yield return matrix[row, col];
     224      }
     225    }
     226
    211227    public override string ToString() {
    212228      if (matrix.Length == 0) return "[]";
  • branches/2915-AbsoluteSymbol/HeuristicLab.ExtLibs

  • branches/2915-AbsoluteSymbol/HeuristicLab.ExtLibs.sln

    r16240 r16332  
    11
    22Microsoft Visual Studio Solution File, Format Version 12.00
    3 # Visual Studio 2013
    4 VisualStudioVersion = 12.0.40629.0
     3# Visual Studio 15
     4VisualStudioVersion = 15.0.28010.2048
    55MinimumVisualStudioVersion = 10.0.40219.1
    66Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.DayView-1.0", "HeuristicLab.ExtLibs\HeuristicLab.DayView\1.0\HeuristicLab.DayView-1.0.csproj", "{02766ECC-D0F5-4115-9ECA-47409167B638}"
     
    7171Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.SimSharp-3.0.11", "HeuristicLab.ExtLibs\HeuristicLab.SimSharp\3.0.11\HeuristicLab.SimSharp-3.0.11\HeuristicLab.SimSharp-3.0.11.csproj", "{5C93CAF7-AE6A-4540-95B2-5DA6761A2677}"
    7272EndProject
    73 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MathJax-2.6.1", "HeuristicLab.ExtLibs\HeuristicLab.MathJax\2.6.1\HeuristicLab.MathJax-2.6.1\HeuristicLab.MathJax-2.6.1.csproj", "{BCDA17A6-5B4A-495C-B182-E856CA081BE6}"
    74 EndProject
    7573Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.IGraph-0.8.0-pre", "HeuristicLab.ExtLibs\HeuristicLab.Igraph\0.8.0-pre\HeuristicLab.Igraph-0.8.0-pre\HeuristicLab.IGraph-0.8.0-pre.csproj", "{088D34F2-32EA-43FF-BAA8-22428D5B66BE}"
     74EndProject
     75Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.NativeInterpreter-0.1", "HeuristicLab.ExtLibs\HeuristicLab.NativeInterpreter\0.1\HeuristicLab.NativeInterpreter-0.1\HeuristicLab.NativeInterpreter-0.1.csproj", "{E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}"
     76EndProject
     77Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MathJax-2.7.5", "HeuristicLab.ExtLibs\HeuristicLab.MathJax\2.7.5\HeuristicLab.MathJax-2.7.5\HeuristicLab.MathJax-2.7.5.csproj", "{31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}"
    7678EndProject
    7779Global
     
    457459    {5C93CAF7-AE6A-4540-95B2-5DA6761A2677}.Release|x86.ActiveCfg = Release|x86
    458460    {5C93CAF7-AE6A-4540-95B2-5DA6761A2677}.Release|x86.Build.0 = Release|x86
    459     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    460     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
    461     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Debug|x64.ActiveCfg = Debug|x64
    462     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Debug|x64.Build.0 = Debug|x64
    463     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Debug|x86.ActiveCfg = Debug|x86
    464     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Debug|x86.Build.0 = Debug|x86
    465     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
    466     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Release|Any CPU.Build.0 = Release|Any CPU
    467     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Release|x64.ActiveCfg = Release|x64
    468     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Release|x64.Build.0 = Release|x64
    469     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Release|x86.ActiveCfg = Release|x86
    470     {BCDA17A6-5B4A-495C-B182-E856CA081BE6}.Release|x86.Build.0 = Release|x86
    471461    {088D34F2-32EA-43FF-BAA8-22428D5B66BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    472462    {088D34F2-32EA-43FF-BAA8-22428D5B66BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
     
    477467    {088D34F2-32EA-43FF-BAA8-22428D5B66BE}.Release|x64.ActiveCfg = Release|Any CPU
    478468    {088D34F2-32EA-43FF-BAA8-22428D5B66BE}.Release|x86.ActiveCfg = Release|Any CPU
     469    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     470    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
     471    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x64.ActiveCfg = Debug|Any CPU
     472    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x64.Build.0 = Debug|Any CPU
     473    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x86.ActiveCfg = Debug|Any CPU
     474    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x86.Build.0 = Debug|Any CPU
     475    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
     476    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|Any CPU.Build.0 = Release|Any CPU
     477    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x64.ActiveCfg = Release|Any CPU
     478    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x64.Build.0 = Release|Any CPU
     479    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x86.ActiveCfg = Release|Any CPU
     480    {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x86.Build.0 = Release|Any CPU
     481    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     482    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
     483    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Debug|x64.ActiveCfg = Debug|x64
     484    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Debug|x64.Build.0 = Debug|x64
     485    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Debug|x86.ActiveCfg = Debug|x86
     486    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Debug|x86.Build.0 = Debug|x86
     487    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
     488    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|Any CPU.Build.0 = Release|Any CPU
     489    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|x64.ActiveCfg = Release|x64
     490    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|x64.Build.0 = Release|x64
     491    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|x86.ActiveCfg = Release|x86
     492    {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|x86.Build.0 = Release|x86
    479493  EndGlobalSection
    480494  GlobalSection(SolutionProperties) = preSolution
    481495    HideSolutionNode = FALSE
    482496  EndGlobalSection
     497  GlobalSection(ExtensibilityGlobals) = postSolution
     498    SolutionGuid = {7851D6F6-9C5F-4A36-8159-8F1C316DFAE0}
     499  EndGlobalSection
    483500EndGlobal
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationModel.cs

    r15583 r16332  
    7474    }
    7575
     76    public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) {
     77      return ClassificationModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     78    }
     79
     80    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     81      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     82      var classificationProblemData = problemData as IClassificationProblemData;
     83      if (classificationProblemData == null)
     84        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     85      return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     86    }
     87
    7688    #region events
    7789    public event EventHandler TargetVariableChanged;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs

    r15583 r16332  
    8383    }
    8484
     85    public virtual bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     86      return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     87    }
     88
     89    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     90      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     91      var regressionProblemData = problemData as IRegressionProblemData;
     92      if (regressionProblemData == null)
     93        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     94      return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     95    }
     96
    8597    #region events
    8698    public event EventHandler TargetVariableChanged;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Plugin.cs.frame

    r15589 r16332  
    4242  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    4343  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    44   [PluginDependency("HeuristicLab.MathJax", "1.1")]
     44  [PluginDependency("HeuristicLab.MathJax", "1.2")]
    4545  [PluginDependency("HeuristicLab.Optimization","3.3")]
    4646  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Trading

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Trading/3.4/ProblemData.cs

    r15583 r16332  
    16501650      OnChanged();
    16511651    }
    1652 
    1653     public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    1654       var data = problemData as ProblemData;
    1655       if (data == null) throw new ArgumentException("The problem data is not a problem data set for trading. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    1656 
    1657       string errorMessage;
    1658       if (!data.IsProblemDataCompatible(this, out errorMessage)) {
    1659         throw new InvalidOperationException(errorMessage);
    1660       }
    1661 
    1662       base.AdjustProblemDataProperties(data);
    1663 
    1664       var toDelete = PriceChangeVariableParameter.ValidValues.ToList();
    1665       foreach (var entry in data.PriceChangeVariableParameter.ValidValues) {
    1666         if (toDelete.Any(x => x.Value == entry.Value)) {
    1667           toDelete.RemoveAll(x => x.Value == entry.Value);
    1668         } else {
    1669           PriceChangeVariableParameter.ValidValues.Add(new StringValue(entry.Value));
    1670         }
    1671       }
    1672       PriceChangeVariableParameter.Value =
    1673         PriceChangeVariableParameter.ValidValues.Single(v => v.Value == data.PriceChangeVariable);
    1674 
    1675       foreach (var varToDelete in toDelete) PriceChangeVariableParameter.ValidValues.Remove(varToDelete);
    1676 
    1677       TransactionCostsParameter.Value.Value = data.TransactionCosts;
    1678 
    1679       OnChanged();
    1680     }
    16811652  }
    16821653}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Trading/3.4/Symbolic/Model.cs

    r15583 r16332  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    5354    }
    5455
     56    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     57      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     58      return IsDatasetCompatible(problemData.Dataset, out errorMessage);
     59    }
     60
     61
    5562    // Transforms an enumerable of real values to an enumerable of trading signals (buy(1) / hold(0) / sell(-1))
    5663    public static IEnumerable<double> GetSignals(IEnumerable<double> xs) {
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Views

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r15583 r16332  
    141141
    142142        var solution = (IDataAnalysisSolution)Content.Clone();
    143         problemData.AdjustProblemDataProperties(solution.ProblemData);
    144 
    145143        solution.ProblemData = problemData;
    146144        if (!solution.Name.EndsWith(" with loaded problemData"))
     
    231229
    232230      try {
    233         problemData.AdjustProblemDataProperties(Content.ProblemData);
    234231        Content.ProblemData = problemData;
    235232
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r16240 r16332  
    167167      }
    168168    }
     169
     170    public bool ContainsVariable(string variableName) {
     171      return variableValues.ContainsKey(variableName);
     172    }
    169173    public IEnumerable<string> DoubleVariables {
    170174      get { return variableValues.Where(p => p.Value is IList<double>).Select(p => p.Key); }
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs

    r15583 r16332  
    6666    public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
    6767
     68    public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) {
     69      return IsProblemDataCompatible(this, problemData, out errorMessage);
     70    }
     71
     72    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     73      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     74      var classificationProblemData = problemData as IClassificationProblemData;
     75      if (classificationProblemData == null)
     76        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     77      return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     78    }
     79
     80    public static bool IsProblemDataCompatible(IClassificationModel model, IClassificationProblemData problemData, out string errorMessage) {
     81      if (model == null) throw new ArgumentNullException("model", "The provided model is null.");
     82      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     83      errorMessage = string.Empty;
     84
     85      if (model.TargetVariable != problemData.TargetVariable)
     86        errorMessage = string.Format("The target variable of the model {0} does not match the target variable of the problemData {1}.", model.TargetVariable, problemData.TargetVariable);
     87
     88      var evaluationErrorMessage = string.Empty;
     89      var datasetCompatible = model.IsDatasetCompatible(problemData.Dataset, out evaluationErrorMessage);
     90      if (!datasetCompatible)
     91        errorMessage += evaluationErrorMessage;
     92
     93      return string.IsNullOrEmpty(errorMessage);
     94    }
     95
    6896    #region events
    6997    public event EventHandler TargetVariableChanged;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r15583 r16332  
    467467    }
    468468    #endregion
    469 
    470     protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
    471       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    472       IClassificationProblemData classificationProblemData = problemData as IClassificationProblemData;
    473       if (classificationProblemData == null)
    474         throw new ArgumentException("The problem data is no classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    475 
    476       var returnValue = base.IsProblemDataCompatible(classificationProblemData, out errorMessage);
    477       //check targetVariable
    478       if (classificationProblemData.InputVariables.All(var => var.Value != TargetVariable)) {
    479         errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)
    480                        + Environment.NewLine + errorMessage;
    481         return false;
    482       }
    483 
    484       var newClassValues = classificationProblemData.Dataset.GetDoubleValues(TargetVariable).Distinct().OrderBy(x => x);
    485       if (!newClassValues.SequenceEqual(ClassValues)) {
    486         errorMessage = errorMessage + string.Format("The class values differ in the provided classification problem data.");
    487         returnValue = false;
    488       }
    489 
    490       var newPositivieClassName = classificationProblemData.PositiveClass;
    491       if (newPositivieClassName != PositiveClass) {
    492         errorMessage = errorMessage + string.Format("The positive class differs in the provided classification problem data.");
    493         returnValue = false;
    494       }
    495 
    496       return returnValue;
    497     }
    498 
    499     public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    500       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    501       ClassificationProblemData classificationProblemData = problemData as ClassificationProblemData;
    502       if (classificationProblemData == null)
    503         throw new ArgumentException("The problem data is not a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    504 
    505       base.AdjustProblemDataProperties(problemData);
    506       TargetVariable = classificationProblemData.TargetVariable;
    507       for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)
    508         ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
    509 
    510       PositiveClass = classificationProblemData.PositiveClass;
    511 
    512       for (int i = 0; i < Classes; i++) {
    513         for (int j = 0; j < Classes; j++) {
    514           ClassificationPenaltiesParameter.Value[i, j] = classificationProblemData.GetClassificationPenalty(ClassValuesCache[i], ClassValuesCache[j]);
    515         }
    516       }
    517     }
    518469  }
    519470}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r15583 r16332  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    4445    public new IClassificationProblemData ProblemData {
    4546      get { return (IClassificationProblemData)base.ProblemData; }
    46       set { base.ProblemData = value; }
     47      set {
     48        if (value == null) throw new ArgumentNullException("The problemData must not be null.");
     49        string errorMessage = string.Empty;
     50        if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage);
     51
     52        base.ProblemData = value;
     53      }
    4754    }
    4855
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/ConstantModel.cs

    r15583 r16332  
    8383    }
    8484
     85    public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) {
     86      return ClassificationModel.IsProblemDataCompatible(this, problemData, out errorMessage);
     87    }
     88
     89    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     90      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     91
     92      var regressionProblemData = problemData as IRegressionProblemData;
     93      if (regressionProblemData != null)
     94        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     95
     96      var classificationProblemData = problemData as IClassificationProblemData;
     97      if (classificationProblemData != null)
     98        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     99
     100      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     101    }
     102
    85103    #region IStringConvertibleValue
    86104    public bool ReadOnly { get; private set; }
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisModel.cs

    r15583 r16332  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Common;
     
    3839
    3940    public abstract IEnumerable<string> VariablesUsedForPrediction { get; }
     41
     42    public virtual bool IsDatasetCompatible(IDataset dataset, out string errorMessage) {
     43      if (dataset == null) throw new ArgumentNullException("dataset", "The provided dataset is null.");
     44      return IsDatasetCompatible(this, dataset, out errorMessage);
     45    }
     46
     47    public abstract bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage);
     48
     49    public static bool IsDatasetCompatible(IDataAnalysisModel model, IDataset dataset, out string errorMessage) {
     50      if(model == null) throw new ArgumentNullException("model", "The provided model is null.");
     51      if (dataset == null) throw new ArgumentNullException("dataset", "The provided dataset is null.");
     52      errorMessage = string.Empty;
     53
     54      foreach (var variable in model.VariablesUsedForPrediction) {
     55        if (!dataset.ContainsVariable(variable)) {
     56          if (string.IsNullOrEmpty(errorMessage)) {
     57            errorMessage = "The following variables must be present in the dataset for model evaluation:";
     58          }
     59          errorMessage += System.Environment.NewLine + " " + variable;
     60        }
     61      }
     62
     63      return string.IsNullOrEmpty(errorMessage);
     64    }
    4065  }
    4166}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r16240 r16332  
    207207      if (listeners != null) listeners(this, EventArgs.Empty);
    208208    }
    209 
    210     protected virtual bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
    211       errorMessage = string.Empty;
    212       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    213 
    214       //check allowed input variables
    215       StringBuilder message = new StringBuilder();
    216       var variables = new HashSet<string>(problemData.InputVariables.Select(x => x.Value));
    217       foreach (var item in AllowedInputVariables) {
    218         if (!variables.Contains(item))
    219           message.AppendLine("Input variable '" + item + "' is not present in the new problem data.");
    220       }
    221 
    222       if (message.Length != 0) {
    223         errorMessage = message.ToString();
    224         return false;
    225       }
    226       return true;
    227 
    228     }
    229 
    230     public virtual void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    231       DataAnalysisProblemData data = problemData as DataAnalysisProblemData;
    232       if (data == null) throw new ArgumentException("The problem data is not a data analysis problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    233 
    234       string errorMessage;
    235       if (!data.IsProblemDataCompatible(this, out errorMessage)) {
    236         throw new InvalidOperationException(errorMessage);
    237       }
    238 
    239       foreach (var inputVariable in InputVariables) {
    240         var variable = data.InputVariables.FirstOrDefault(i => i.Value == inputVariable.Value);
    241         InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable));
    242       }
    243     }
    244209  }
    245210}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs

    r15583 r16332  
    5858      get { return (IDataAnalysisProblemData)this[ProblemDataResultName].Value; }
    5959      set {
    60         if (this[ProblemDataResultName].Value != value) {
    61           if (value != null) {
    62             ProblemData.Changed -= new EventHandler(ProblemData_Changed);
    63             this[ProblemDataResultName].Value = value;
    64             ProblemData.Changed += new EventHandler(ProblemData_Changed);
    65             OnProblemDataChanged();
    66           }
    67         }
     60        if (value == null) throw new ArgumentNullException("The problemData must not be null.");
     61        if (this[ProblemDataResultName].Value == value) return;
     62        string errorMessage = string.Empty;
     63        if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage);
     64
     65        ProblemData.Changed -= new EventHandler(ProblemData_Changed);
     66        this[ProblemDataResultName].Value = value;
     67        ProblemData.Changed += new EventHandler(ProblemData_Changed);
     68        OnProblemDataChanged();
    6869      }
    6970    }
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionModel.cs

    r15583 r16332  
    6767    public abstract IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData);
    6868
     69    public virtual bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
     70      return IsProblemDataCompatible(this, problemData, out errorMessage);
     71    }
     72
     73    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     74      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     75      var regressionProblemData = problemData as IRegressionProblemData;
     76      if (regressionProblemData == null)
     77        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     78      return IsProblemDataCompatible(regressionProblemData, out errorMessage);
     79    }
     80
     81    public static bool IsProblemDataCompatible(IRegressionModel model, IRegressionProblemData problemData, out string errorMessage) {
     82      if (model == null) throw new ArgumentNullException("model", "The provided model is null.");
     83      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     84      errorMessage = string.Empty;
     85
     86      if (model.TargetVariable != problemData.TargetVariable)
     87        errorMessage = string.Format("The target variable of the model {0} does not match the target variable of the problemData {1}.", model.TargetVariable, problemData.TargetVariable);
     88
     89      var evaluationErrorMessage = string.Empty;
     90      var datasetCompatible = model.IsDatasetCompatible(problemData.Dataset, out evaluationErrorMessage);
     91      if (!datasetCompatible)
     92        errorMessage += evaluationErrorMessage;
     93
     94      return string.IsNullOrEmpty(errorMessage);
     95    }
     96
    6997    #region events
    7098    public event EventHandler TargetVariableChanged;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r15583 r16332  
    161161      OnChanged();
    162162    }
    163 
    164     protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
    165       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    166       IRegressionProblemData regressionProblemData = problemData as IRegressionProblemData;
    167       if (regressionProblemData == null)
    168         throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    169 
    170       var returnValue = base.IsProblemDataCompatible(problemData, out errorMessage);
    171       return returnValue;
    172     }
    173 
    174     public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    175       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    176       RegressionProblemData regressionProblemData = problemData as RegressionProblemData;
    177       if (regressionProblemData == null)
    178         throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    179 
    180       base.AdjustProblemDataProperties(problemData);
    181     }
    182163  }
    183164}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r15583 r16332  
    7070    public new IRegressionProblemData ProblemData {
    7171      get { return (IRegressionProblemData)base.ProblemData; }
    72       set { base.ProblemData = value; }
     72      set {
     73        if (value == null) throw new ArgumentNullException("The problemData must not be null.");
     74        string errorMessage = string.Empty;
     75        if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage);
     76
     77        base.ProblemData = value;
     78      }
    7379    }
    7480
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs

    r15583 r16332  
    16201620      OnChanged();
    16211621    }
    1622 
    1623     protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
    1624       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    1625       ITimeSeriesPrognosisProblemData timeseriesProblemData = problemData as ITimeSeriesPrognosisProblemData;
    1626       if (timeseriesProblemData == null)
    1627         throw new ArgumentException("The problem data is not a time-series problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    1628 
    1629       var returnValue = base.IsProblemDataCompatible(problemData, out errorMessage);
    1630       //check targetVariable
    1631       if (problemData.InputVariables.All(var => var.Value != TargetVariable)) {
    1632         errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)
    1633                        + Environment.NewLine + errorMessage;
    1634         return false;
    1635       }
    1636       return returnValue;
    1637     }
    1638 
    1639     public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    1640       TimeSeriesPrognosisProblemData timeSeriesProblemData = problemData as TimeSeriesPrognosisProblemData;
    1641       if (timeSeriesProblemData == null)
    1642         throw new ArgumentException("The problem data is not a timeseries problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    1643 
    1644       var trainingDataStart = TrainingIndices.First();
    1645 
    1646       base.AdjustProblemDataProperties(problemData);
    1647 
    1648       TestPartition.Start = trainingDataStart;
    1649 
    1650       TrainingHorizon = timeSeriesProblemData.TrainingHorizon;
    1651       TestHorizon = timeSeriesProblemData.TestHorizon;
    1652     }
    1653 
    16541622  }
    16551623}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationModel.cs

    r15583 r16332  
    3131    IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows);
    3232    IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
     33    bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage);
    3334    string TargetVariable { get; set; }
    3435    event EventHandler TargetVariableChanged;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs

    r15583 r16332  
    3030  public interface IDataAnalysisModel : INamedItem {
    3131    IEnumerable<string> VariablesUsedForPrediction { get; }
     32    bool IsDatasetCompatible(IDataset dataset, out string errorMessage);
     33    bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage);
    3234  }
    3335}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r15583 r16332  
    4949
    5050    event EventHandler Changed;
    51 
    52     void AdjustProblemDataProperties(IDataAnalysisProblemData problemData);
    5351  }
    5452}
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataset.cs

    r15583 r16332  
    3333    IEnumerable<string> DateTimeVariables { get; }
    3434
     35    bool ContainsVariable(string variablename);
    3536    bool VariableHasType<T>(string variableName);
    3637
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionModel.cs

    r15583 r16332  
    3131    IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows);
    3232    IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData);
     33    bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage);
    3334    string TargetVariable { get; set; }
    3435    event EventHandler TargetVariableChanged;
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs

    r16240 r16332  
    5656
    5757    public IEnumerable<object> GetRow(int row) {
     58      if (row < 0 || row >= Rows)
     59        throw new ArgumentException(string.Format("Invalid row {0} specified. The dataset contains {1} row(s).", row, Rows));
     60
    5861      return variableValues.Select(x => x.Value[row]);
    5962    }
  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.Instances.DataAnalysis

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj

    r16240 r16332  
    169169    <Compile Include="Regression\PennML\PennMLRegressionDataDescriptor.cs" />
    170170    <Compile Include="Regression\PennML\PennMLRegressionInstanceProvider.cs" />
     171    <Compile Include="Regression\Physics\AircraftLift.cs" />
     172    <Compile Include="Regression\Physics\AircraftMaximumLift.cs" />
     173    <Compile Include="Regression\Physics\FluidDynamics.cs" />
     174    <Compile Include="Regression\Physics\PhysicsInstanceProvider.cs" />
     175    <Compile Include="Regression\Physics\RocketFuelFlow.cs" />
    171176    <Compile Include="Regression\VariableNetworks\LinearVariableNetwork.cs" />
    172177    <Compile Include="Regression\VariableNetworks\GaussianProcessVariableNetwork.cs" />
  • branches/2915-AbsoluteSymbol/HeuristicLab.Services.Hive.DataAccess

  • branches/2915-AbsoluteSymbol/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs

    r16240 r16332  
    4141    public void DeleteByIds(IEnumerable<Guid> ids) {
    4242      string paramProjectIds = string.Join(",", ids.ToList().Select(x => string.Format("'{0}'", x)));
    43       if(!string.IsNullOrWhiteSpace(paramProjectIds)) {
     43      if (!string.IsNullOrWhiteSpace(paramProjectIds)) {
    4444        string queryString = string.Format(DeleteByIdsQueryString, paramProjectIds);
    4545        DataContext.ExecuteCommand(queryString);
     
    117117      WITH rtree AS
    118118      (
    119         SELECT ResourceId, ParentResourceId
    120         FROM [Resource]
    121         UNION ALL
    122         SELECT rt.ResourceId, r.ParentResourceId
    123         FROM [Resource] r
    124         JOIN rtree rt ON rt.ParentResourceId = r.ResourceId
    125       )
    126       SELECT apr.ProjectId, SUM(res.Cores) AS Cores, SUM(res.Memory) AS Memory
    127       FROM rtree, [AssignedProjectResource] apr, [Resource] res
    128       WHERE rtree.ResourceId = res.ResourceId
    129       AND res.ResourceType = 'Slave'
    130       AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating')
    131       AND rtree.ParentResourceId = apr.ResourceId
    132       GROUP BY apr.ProjectId
    133       UNION
    134       SELECT apr.ProjectId, SUM(res.Cores) AS Cores, SUM(res.Memory) AS Memory
    135       FROM [AssignedProjectResource] apr, [Resource] res
    136       WHERE apr.ResourceId = res.ResourceId
    137       AND res.ResourceType = 'Slave'
    138       AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating')
    139       GROUP BY apr.ProjectId
     119        SELECT ResourceId, ParentResourceId
     120        FROM [Resource]
     121        UNION ALL
     122        SELECT rt.ResourceId, r.ParentResourceId
     123        FROM [Resource] r
     124        JOIN rtree rt ON rt.ParentResourceId = r.ResourceId
     125      )
     126      SELECT [union].ProjectId, SUM([union].Cores), SUM([union].Memory)
     127      FROM
     128      (
     129        SELECT apr.ProjectId, res.Cores, res.Memory
     130        FROM rtree, [AssignedProjectResource] apr, [Resource] res
     131        WHERE rtree.ResourceId = res.ResourceId
     132        AND res.ResourceType = 'Slave'
     133        AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating')
     134        AND rtree.ParentResourceId = apr.ResourceId
     135        UNION ALL
     136        SELECT apr.ProjectId, res.Cores, res.Memory
     137        FROM [AssignedProjectResource] apr, [Resource] res
     138        WHERE apr.ResourceId = res.ResourceId
     139        AND res.ResourceType = 'Slave'
     140        AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating')
     141      ) AS [union]
     142      GROUP BY [union].ProjectId
    140143    ";
    141144
  • branches/2915-AbsoluteSymbol/HeuristicLab.Tests

  • branches/2915-AbsoluteSymbol/HeuristicLab.Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4/SubtreeCrossoverTest.cs

    r15583 r16332  
    4646          SubroutineCreater.CreateSubroutine(random, trees[i], 100, 10, 3, 3);
    4747      }
     48      var children = new List<ISymbolicExpressionTree>(trees);
     49
    4850      Stopwatch stopwatch = new Stopwatch();
    4951      stopwatch.Start();
     
    5254          var par0 = (ISymbolicExpressionTree)trees.SampleRandom(random).Clone();
    5355          var par1 = (ISymbolicExpressionTree)trees.SampleRandom(random).Clone();
    54           SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10);
     56          children[i] = SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10);
    5557        }
     58        trees = children;
    5659      }
    5760      stopwatch.Stop();
  • branches/2915-AbsoluteSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs

    r16240 r16332  
    4545      Assert.AreEqual("6", Derive("2*3*x", "x"));
    4646      Assert.AreEqual("(10*'y')", Derive("10*x*y+20*y", "x"));
    47       Assert.AreEqual("(1 / (SQR('x') * (-1)))",  Derive("1/x", "x"));
     47      Assert.AreEqual("(1 / (SQR('x') * (-1)))", Derive("1/x", "x"));
    4848      Assert.AreEqual("('y' / (SQR('x') * (-1)))", Derive("y/x", "x"));
    4949      Assert.AreEqual("((((-2*'x') + (-1)) * ('a' + 'b')) / SQR(('x' + ('x' * 'x'))))",
     
    5858      Assert.AreEqual("(COS((3*'x')) * 3)", Derive("sin(3*x)", "x"));
    5959      Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos(3*x)", "x"));
     60      Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan(3*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator
    6061
     62      {
     63        // special case: Inv(x) using only one argument to the division symbol
     64        // f(x) = 1/x
     65        var root = new ProgramRootSymbol().CreateTreeNode();
     66        var start = new StartSymbol().CreateTreeNode();
     67        var div = new Division().CreateTreeNode();
     68        var varNode = (VariableTreeNode)(new Variable().CreateTreeNode());
     69        varNode.Weight = 1.0;
     70        varNode.VariableName = "x";
     71        div.AddSubtree(varNode);
     72        start.AddSubtree(div);
     73        root.AddSubtree(start);
     74        var t = new SymbolicExpressionTree(root);
     75        Assert.AreEqual("(1 / (SQR('x') * (-1)))",
     76          formatter.Format(DerivativeCalculator.Derive(t, "x")));
     77      }
    6178
    62       // special case: Inv(x) using only one argument to the division symbol
    63       // f(x) = 1/x
    64       var root = new ProgramRootSymbol().CreateTreeNode();
    65       var start = new StartSymbol().CreateTreeNode();
    66       var div = new Division().CreateTreeNode();
    67       var varNode = (VariableTreeNode)(new Variable().CreateTreeNode());
    68       varNode.Weight = 1.0;
    69       varNode.VariableName = "x";
    70       div.AddSubtree(varNode);
    71       start.AddSubtree(div);
    72       root.AddSubtree(start);
    73       var t = new SymbolicExpressionTree(root);
    74       Assert.AreEqual("(1 / (SQR('x') * (-1)))",
    75         formatter.Format(DerivativeCalculator.Derive(t, "x")));
     79      {
     80        // special case: multiplication with only one argument
     81        var root = new ProgramRootSymbol().CreateTreeNode();
     82        var start = new StartSymbol().CreateTreeNode();
     83        var mul = new Multiplication().CreateTreeNode();
     84        var varNode = (VariableTreeNode)(new Variable().CreateTreeNode());
     85        varNode.Weight = 3.0;
     86        varNode.VariableName = "x";
     87        mul.AddSubtree(varNode);
     88        start.AddSubtree(mul);
     89        root.AddSubtree(start);
     90        var t = new SymbolicExpressionTree(root);
     91        Assert.AreEqual("3",
     92          formatter.Format(DerivativeCalculator.Derive(t, "x")));
     93      }
     94
     95      {
     96        // division with multiple arguments
     97        // div(x, y, z) is interpreted as (x / y) / z
     98        var root = new ProgramRootSymbol().CreateTreeNode();
     99        var start = new StartSymbol().CreateTreeNode();
     100        var div = new Division().CreateTreeNode();
     101        var varNode1 = (VariableTreeNode)(new Variable().CreateTreeNode());
     102        varNode1.Weight = 3.0;
     103        varNode1.VariableName = "x";
     104        var varNode2 = (VariableTreeNode)(new Variable().CreateTreeNode());
     105        varNode2.Weight = 4.0;
     106        varNode2.VariableName = "y";
     107        var varNode3 = (VariableTreeNode)(new Variable().CreateTreeNode());
     108        varNode3.Weight = 5.0;
     109        varNode3.VariableName = "z";
     110        div.AddSubtree(varNode1); div.AddSubtree(varNode2); div.AddSubtree(varNode3);
     111        start.AddSubtree(div);
     112        root.AddSubtree(start);
     113        var t = new SymbolicExpressionTree(root);
     114
     115        Assert.AreEqual("(('y' * 'z' * 60) / SQR(('y' * 'z' * 20)))", // actually 3 / (4y  5z) but simplifier is not smart enough to cancel numerator and denominator
     116                                                                      // 60 y z / y² z² 20² == 6 / y z 40 == 3 / y z 20
     117          formatter.Format(DerivativeCalculator.Derive(t, "x")));
     118        Assert.AreEqual("(('x' * 'z' * (-60)) / SQR(('y' * 'z' * 20)))", // actually 3x * -(4 5 z) / (4y 5z)² = -3x / (20 y² z)
     119                                                                         // -3 4 5 x z / 4² y² 5² z² = -60 x z / 20² z² y² ==    -60 x z / y² z² 20²
     120          formatter.Format(DerivativeCalculator.Derive(t, "y")));
     121        Assert.AreEqual("(('x' * 'y' * (-60)) / SQR(('y' * 'z' * 20)))",
     122          formatter.Format(DerivativeCalculator.Derive(t, "z")));
     123      }
    76124    }
    77125
  • branches/2915-AbsoluteSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs

    r15583 r16332  
    119119    public void LinearInterpreterTestArithmeticGrammarPerformance() {
    120120      TestArithmeticGrammarPerformance(new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), 12.5e6);
     121    }
     122
     123    [TestMethod]
     124    [TestCategory("Problems.DataAnalysis.Symbolic")]
     125    [TestProperty("Time", "long")]
     126    public void BatchInterpreterTestTypeCoherentGrammarPerformance() {
     127      TestTypeCoherentGrammarPerformance(new SymbolicDataAnalysisExpressionTreeBatchInterpreter(), 12.5e6);
     128    }
     129    [TestMethod]
     130    [TestCategory("Problems.DataAnalysis.Symbolic")]
     131    [TestProperty("Time", "long")]
     132    public void BatchInterpreterTestArithmeticGrammarPerformance() {
     133      TestArithmeticGrammarPerformance(new SymbolicDataAnalysisExpressionTreeBatchInterpreter(), 12.5e6);
    121134    }
    122135
  • branches/2915-AbsoluteSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs

    r14354 r16332  
    77  [TestClass]
    88  public class BottomUpSimilarityCalculatorTest {
    9     private readonly SymbolicExpressionTreeBottomUpSimilarityCalculator busCalculator;
    10     private readonly SymbolicExpressionImporter importer;
     9    private readonly SymbolicExpressionTreeBottomUpSimilarityCalculator similarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator() { MatchConstantValues = false, MatchVariableWeights = false };
     10    private readonly SymbolicExpressionImporter importer = new SymbolicExpressionImporter();
    1111
    12     private const int N = 150;
     12    private const int N = 1000;
    1313    private const int Rows = 1;
    1414    private const int Columns = 10;
    1515
    1616    public BottomUpSimilarityCalculatorTest() {
    17       busCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator();
    18       importer = new SymbolicExpressionImporter();
     17      var parser = new InfixExpressionParser();
    1918    }
    2019
     
    2322    [TestProperty("Time", "short")]
    2423    public void BottomUpTreeSimilarityCalculatorTestMapping() {
    25       TestMatchedNodes("(+ 1 2)", "(+ 2 1)", 5);
    26       TestMatchedNodes("(- 2 1)", "(- 1 2)", 2);
    27       TestMatchedNodes("(* (variable 1 X1) (variable 1 X2))", "(* (+ (variable 1 X1) 1) (+ (variable 1 X2) 1))", 2);
     24      TestMatchedNodes("(+ 1 1)", "(+ 2 2)", 0, strict: true);
     25      TestMatchedNodes("(+ 1 1)", "(+ 2 2)", 3, strict: false);
     26      TestMatchedNodes("(+ 1 1)", "(+ 1 2)", 1, strict: true);
     27      TestMatchedNodes("(+ 2 1)", "(+ 1 2)", 3, strict: true);
    2828
    29       TestMatchedNodes("(* (variable 1 X1) (variable 1 X2))", "(* (+ (variable 1 X1) 1) (variable 1 X2))", 2);
     29      TestMatchedNodes("(- 1 1)", "(- 2 2)", 0, strict: true);
     30      TestMatchedNodes("(- 1 1)", "(- 2 2)", 3, strict: false);
    3031
    31       TestMatchedNodes("(+ (variable 1 a) (variable 1 b))", "(+ (variable 1 a) (variable 1 a))", 1);
    32       TestMatchedNodes("(+ (+ (variable 1 a) (variable 1 b)) (variable 1 b))", "(+ (* (+ (variable 1 a) (variable 1 b)) (variable 1 b)) (+ (+ (variable 1 a) (variable 1 b)) (variable 1 b)))", 5);
    33 
    34       TestMatchedNodes(
    35         "(* (+ 2.84 (exp (+ (log (/ (variable 2.0539 X5) (variable -9.2452e-1 X6))) (/ (variable 2.0539 X5) (variable -9.2452e-1 X6))))) 2.9081)",
    36         "(* (- (variable 9.581e-1 X6) (+ (- (variable 5.1491e-1 X5) 1.614e+1) (+ (/ (variable 2.0539 X5) (variable -9.2452e-1 X6)) (log (/ (variable 2.0539 X5) (variable -9.2452e-1 X6)))))) 2.9081)",
    37         9);
    38 
    39       TestMatchedNodes("(* (* (* (variable 1.68 x) (* (variable 1.68 x) (variable 2.55 x))) (variable 1.68 x)) (* (* (variable 1.68 x) (* (variable 1.68 x) (* (variable 1.68 x) (variable 2.55 x)))) (variable 2.55 x)))", "(* (variable 2.55 x) (* (variable 1.68 x) (* (variable 1.68 x) (* (variable 1.68 x) (variable 2.55 x)))))", 9);
    40 
    41       TestMatchedNodes("(+ (exp 2.1033) (/ -4.3072 (variable 2.4691 X7)))", "(/ 1 (+ (/ -4.3072 (variable 2.4691 X7)) (exp 2.1033)))", 6);
    42       TestMatchedNodes("(+ (exp 2.1033) (/ -4.3072 (variable 2.4691 X7)))", "(/ 1 (+ (/ (variable 2.4691 X7) -4.3072) (exp 2.1033)))", 4);
    43 
    44       const string expr1 = "(* (- 1.2175e+1 (+ (/ (exp -1.4134e+1) (exp 9.2013)) (exp (log (exp (/ (exp (- (* -4.2461 (variable 2.2634 X5)) (- -9.6267e-1 3.3243))) (- (/ (/ (variable 1.0883 X1) (variable 6.9620e-1 X2)) (log 1.3011e+1)) (variable -4.3098e-1 X7)))))))) (log 1.3011e+1))";
    45       const string expr2 = "(* (- 1.2175e+1 (+ (/ (/ (+ (variable 3.0140 X9) (variable 1.3430 X8)) -1.0864e+1) (exp 9.2013)) (exp (log (exp (/ (exp (- (* -4.2461 (variable 2.2634 X5)) (- -9.6267e-1 3.3243))) (- (/ (/ (variable 1.0883 X1) (variable 6.9620e-1 X2)) (log 1.3011e+1)) (variable -4.3098e-1 X7)))))))) (exp (variable 4.0899e-1 X7)))";
    46 
    47       TestMatchedNodes(expr1, expr2, 23);
    48 
     32      TestMatchedNodes("(- 2 1)", "(- 1 2)", 2, strict: true);
     33      TestMatchedNodes("(- 2 1)", "(- 1 2)", 3, strict: false);
    4934    }
    5035
    51     private void TestMatchedNodes(string expr1, string expr2, int expected) {
     36    private void TestMatchedNodes(string expr1, string expr2, int expected, bool strict) {
    5237      var t1 = importer.Import(expr1);
    5338      var t2 = importer.Import(expr2);
    5439
    55       var mapping = busCalculator.ComputeBottomUpMapping(t1.Root, t2.Root);
    56       var c = mapping.Count;
     40      var map = SymbolicExpressionTreeBottomUpSimilarityCalculator.ComputeBottomUpMapping(t1, t2, strict);
    5741
    58       if (c != expected) {
    59         throw new Exception("Match count " + c + " is different than expected value " + expected);
     42      if (map.Count != expected) {
     43        throw new Exception($"Match count {map.Count} is different than expected value {expected} for expressions:\n{expr1} and {expr2} (strict = {strict})");
    6044      }
    6145    }
     
    7761      for (int i = 0; i < trees.Length - 1; ++i) {
    7862        for (int j = i + 1; j < trees.Length; ++j) {
    79           s += busCalculator.CalculateSimilarity(trees[i], trees[j]);
     63          s += similarityCalculator.CalculateSimilarity(trees[i], trees[j]);
    8064        }
    8165      }
Note: See TracChangeset for help on using the changeset viewer.