Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/15/12 16:47:25 (12 years ago)
Author:
mkommend
Message:

#1763: merged changes from trunk into the tree simplifier branch.

Location:
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
21 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveAnalyzer.cs

    r7259 r8915  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
    2422using HeuristicLab.Common;
    2523using HeuristicLab.Core;
    2624using HeuristicLab.Data;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    2925using HeuristicLab.Parameters;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    3227
    3328namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    3934    private const string QualitiesParameterName = "Qualities";
    4035    private const string MaximizationParameterName = "Maximization";
     36    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    4137    #region parameter properties
    4238    public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
     
    4541    public ILookupParameter<BoolArray> MaximizationParameter {
    4642      get { return (ILookupParameter<BoolArray>)Parameters[MaximizationParameterName]; }
     43    }
     44    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
     45      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
    4746    }
    4847    #endregion
     
    6463      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>(QualitiesParameterName, "The qualities of the trees that should be analyzed."));
    6564      Parameters.Add(new LookupParameter<BoolArray>(MaximizationParameterName, "The directions of optimization for each dimension."));
     65      Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
     66    }
     67
     68    [StorableHook(HookType.AfterDeserialization)]
     69    private void AfterDeserialization() {
     70      if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>)
     71        Parameters.Remove(ApplyLinearScalingParameterName);
     72      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
     73        Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
    6674    }
    6775  }
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveAnalyzer.cs

    r7259 r8915  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
    2422using HeuristicLab.Common;
    2523using HeuristicLab.Core;
    2624using HeuristicLab.Data;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    2925using HeuristicLab.Parameters;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    3227
    3328namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    3934    private const string QualityParameterName = "Quality";
    4035    private const string MaximizationParameterName = "Maximization";
     36    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
     37
    4138    #region parameter properties
    4239    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     
    4542    public ILookupParameter<BoolValue> MaximizationParameter {
    4643      get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
     44    }
     45    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
     46      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
    4747    }
    4848    #endregion
     
    6464      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The qualities of the trees that should be analyzed."));
    6565      Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization."));
     66      Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
     67    }
     68
     69    [StorableHook(HookType.AfterDeserialization)]
     70    private void AfterDeserialization() {
     71      if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && !(Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>))
     72        Parameters.Remove(ApplyLinearScalingParameterName);
     73      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
     74        Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
    6675    }
    6776  }
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r7259 r8915  
    8585
    8686      var results = ResultCollection;
    87       if (TrainingBestSolutionQuality == null ||
    88         IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value)) {
     87      if (bestTree != null && (TrainingBestSolutionQuality == null ||
     88        IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value))) {
    8989        TrainingBestSolution = CreateSolution(bestTree, bestQuality);
    9090        TrainingBestSolutionQuality = new DoubleValue(bestQuality);
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs

    r7721 r8915  
    7676      : base(original, cloner) {
    7777    }
    78     public SymbolicDataAnalysisSingleObjectiveValidationAnalyzer()
    79       : base() {
     78
     79    protected SymbolicDataAnalysisSingleObjectiveValidationAnalyzer(): base() {
    8080      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator."));
    8181      Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem."));
    8282      Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition."));
    8383      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees."));
    84       Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "Thes validation partition."));
     84      Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition."));
    8585      Parameters.Add(new ValueLookupParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index."));
    8686      Parameters.Add(new ValueLookupParameter<PercentValue>(PercentageOfBestSolutionsParameterName,
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs

    r7259 r8915  
    109109      // update variable impacts matrix
    110110      var orderedImpacts = (from row in datatable.Rows
    111                             select new { Name = row.Name, Impact = datatable.Rows[row.Name].Values.Average() })
     111                            select new { Name = row.Name, Impact = Math.Round(datatable.Rows[row.Name].Values.Average(), 3) })
    112112                           .OrderByDescending(p => p.Impact)
    113113                           .ToList();
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Evaluators/SymbolicDataAnalysisEvaluator.cs

    r7259 r8915  
    4444    private const string EvaluationPartitionParameterName = "EvaluationPartition";
    4545    private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
     46    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
     47    private const string ValidRowIndicatorParameterName = "ValidRowIndicator";
    4648
    4749    public override bool CanChangeName { get { return false; } }
     
    7072      get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
    7173    }
     74    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
     75      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
     76    }
     77    public IValueLookupParameter<StringValue> ValidRowIndicatorParameter {
     78      get { return (IValueLookupParameter<StringValue>)Parameters[ValidRowIndicatorParameterName]; }
     79    }
    7280    #endregion
    7381
     
    8795      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The upper and lower limit that should be used as cut off value for the output values of symbolic data analysis trees."));
    8896      Parameters.Add(new ValueLookupParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index."));
     97      Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
     98      Parameters.Add(new ValueLookupParameter<StringValue>(ValidRowIndicatorParameterName, "An indicator variable in the data set that specifies which rows should be evaluated (those for which the indicator <> 0) (optional)."));
     99    }
     100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && !(Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>))
     104        Parameters.Remove(ApplyLinearScalingParameterName);
     105      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
     106        Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
     107      if (!Parameters.ContainsKey(ValidRowIndicatorParameterName))
     108        Parameters.Add(new ValueLookupParameter<StringValue>(ValidRowIndicatorParameterName, "An indicator variable in the data set that specifies which rows should be evaluated (those for which the indicator <> 0) (optional)."));
    89109    }
    90110
     
    94114
    95115    protected IEnumerable<int> GenerateRowsToEvaluate(double percentageOfRows) {
    96 
    97 
    98116      IEnumerable<int> rows;
    99117      int samplesStart = EvaluationPartitionParameter.ActualValue.Start;
     
    101119      int testPartitionStart = ProblemDataParameter.ActualValue.TestPartition.Start;
    102120      int testPartitionEnd = ProblemDataParameter.ActualValue.TestPartition.End;
    103 
    104121      if (samplesEnd < samplesStart) throw new ArgumentException("Start value is larger than end value.");
    105122
     
    113130      }
    114131
    115       return rows.Where(i => i < testPartitionStart || testPartitionEnd <= i);
     132      rows = rows.Where(i => i < testPartitionStart || testPartitionEnd <= i);
     133      if (ValidRowIndicatorParameter.ActualValue != null) {
     134        string indicatorVar = ValidRowIndicatorParameter.ActualValue.Value;
     135        var problemData = ProblemDataParameter.ActualValue;
     136        var indicatorRow = problemData.Dataset.GetReadOnlyDoubleValues(indicatorVar);
     137        rows = rows.Where(r => !indicatorRow[r].IsAlmost(0.0));
     138      }
     139      return rows;
     140    }
     141
     142    [ThreadStatic]
     143    private static double[] cache;
     144    protected static void CalculateWithScaling(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues,
     145      double lowerEstimationLimit, double upperEstimationLimit,
     146      IOnlineCalculator calculator, int maxRows) {
     147      if (cache == null || cache.GetLength(0) < maxRows) {
     148        cache = new double[maxRows];
     149      }
     150
     151      // calculate linear scaling
     152      // the static methods of the calculator are not used because the evaluated values should be cached for performance reasons
     153      int i = 0;
     154      var linearScalingCalculator = new OnlineLinearScalingParameterCalculator();
     155      var targetValuesEnumerator = targetValues.GetEnumerator();
     156      var estimatedValuesEnumerator = estimatedValues.GetEnumerator();
     157      while (targetValuesEnumerator.MoveNext() & estimatedValuesEnumerator.MoveNext()) {
     158        double target = targetValuesEnumerator.Current;
     159        double estimated = estimatedValuesEnumerator.Current;
     160        cache[i] = estimated;
     161        if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
     162          linearScalingCalculator.Add(estimated, target);
     163        i++;
     164      }
     165      if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None && (targetValuesEnumerator.MoveNext() || estimatedValuesEnumerator.MoveNext()))
     166        throw new ArgumentException("Number of elements in target and estimated values enumeration do not match.");
     167
     168      double alpha = linearScalingCalculator.Alpha;
     169      double beta = linearScalingCalculator.Beta;
     170      if (linearScalingCalculator.ErrorState != OnlineCalculatorError.None) {
     171        alpha = 0.0;
     172        beta = 1.0;
     173      }
     174
     175      //calculate the quality by using the passed online calculator
     176      targetValuesEnumerator = targetValues.GetEnumerator();
     177      var scaledBoundedEstimatedValuesEnumerator = Enumerable.Range(0, i).Select(x => cache[x] * beta + alpha)
     178        .LimitToRange(lowerEstimationLimit, upperEstimationLimit).GetEnumerator();
     179
     180      while (targetValuesEnumerator.MoveNext() & scaledBoundedEstimatedValuesEnumerator.MoveNext()) {
     181        calculator.Add(targetValuesEnumerator.Current, scaledBoundedEstimatedValuesEnumerator.Current);
     182      }
    116183    }
    117184  }
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r7708 r8915  
    3333  [StorableClass]
    3434  public sealed class SymbolicDataAnalysisExpressionLatexFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter {
    35     private List<double> constants;
     35    private readonly List<double> constants;
     36    private int targetCount;
    3637    private int currentLag;
    3738
     
    9899      } else if (node.Symbol is Division) {
    99100        if (node.SubtreeCount == 1) {
    100           strBuilder.Append(@" \cfrac{1}{");
     101          strBuilder.Append(@" \cfrac{1");
    101102        } else {
    102103          strBuilder.Append(@" \cfrac{ ");
     
    196197        strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( ");
    197198      } else if (node.Symbol is StartSymbol) {
    198         strBuilder.Append("Result & = ");
     199        strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
    199200      } else if (node.Symbol is Argument) {
    200201        var argSym = node.Symbol as Argument;
     
    301302        strBuilder.Append(" , ");
    302303      } else if (node.Symbol is StartSymbol) {
    303         strBuilder.Append(@"\\" + Environment.NewLine + " & ");
     304        strBuilder.Append(@"\\" + Environment.NewLine);
     305        strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
    304306      } else if (node.Symbol is Power) {
    305307        strBuilder.Append(@"\right) ^ { \operatorname{round} \left(");
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r7707 r8915  
    116116      var laggedVariable = new LaggedVariable();
    117117      laggedVariable.InitialFrequency = 0.0;
     118      var autoregressiveVariable = new AutoregressiveTargetVariable();
     119      autoregressiveVariable.InitialFrequency = 0.0;
     120      autoregressiveVariable.Enabled = false;
    118121
    119122      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp,
    120123        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
    121         @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable, variableCondition };
     124        @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable,autoregressiveVariable, variableCondition };
    122125      var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative,
    123126        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
     
    126129      var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, variableCondition };
    127130      var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };
    128       var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable };
     131      var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable, autoregressiveVariable };
    129132
    130133      foreach (var symb in allSymbols)
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r7696 r8915  
    104104      var variableSymbol = new Variable();
    105105      var laggedVariable = new LaggedVariable();
     106      var autoregressiveVariable = new AutoregressiveTargetVariable();
    106107      #endregion
    107108
     
    122123      var conditionalSymbols = new GroupSymbol(ConditionalSymbolsName, new List<ISymbol> { conditionSymbols, comparisonSymbols, booleanOperationSymbols });
    123124
    124       var timeSeriesSymbols = new GroupSymbol(TimeSeriesSymbolsName, new List<ISymbol> { timeLag, integral, derivative, laggedVariable });
     125      var timeSeriesSymbols = new GroupSymbol(TimeSeriesSymbolsName, new List<ISymbol> { timeLag, integral, derivative, laggedVariable, autoregressiveVariable });
    125126      #endregion
    126127
     
    152153      SetSubtreeCount(derivative, 1, 1);
    153154      SetSubtreeCount(laggedVariable, 0, 0);
     155      SetSubtreeCount(autoregressiveVariable, 0, 0);
    154156      #endregion
    155157
     
    225227      Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = false;
    226228    }
     229
     230    public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() {
     231      Symbols.First(s => s is Average).Enabled = false;
     232      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
     233      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
     234      Symbols.First(s => s.Name == ConditionalSymbolsName).Enabled = false;
     235      Symbols.First(s => s.Name == SpecialFunctionsName).Enabled = false;
     236
     237      Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = true;
     238      Symbols.First(s => s is Derivative).Enabled = false;
     239      Symbols.First(s => s is Integral).Enabled = false;
     240      Symbols.First(s => s is TimeLag).Enabled = false;
     241    }
    227242  }
    228243}
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r8388 r8915  
    9393  </PropertyGroup>
    9494  <ItemGroup>
    95     <Reference Include="ALGLIB-3.5.0">
    96       <HintPath>..\..\..\..\Trunk\sources\bin\ALGLIB-3.5.0.dll</HintPath>
     95    <Reference Include="ALGLIB-3.6.0, Version=3.6.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     96      <SpecificVersion>False</SpecificVersion>
     97      <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.6.0.dll</HintPath>
     98      <Private>False</Private>
    9799    </Reference>
    98100    <Reference Include="HeuristicLab.Analysis-3.3">
    99101      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     102      <Private>False</Private>
    100103    </Reference>
    101104    <Reference Include="HeuristicLab.Collections-3.3">
    102105      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     106      <Private>False</Private>
    103107    </Reference>
    104108    <Reference Include="HeuristicLab.Common-3.3">
    105109      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     110      <Private>False</Private>
    106111    </Reference>
    107112    <Reference Include="HeuristicLab.Common.Resources-3.3">
    108113      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     114      <Private>False</Private>
    109115    </Reference>
    110116    <Reference Include="HeuristicLab.Core-3.3">
    111117      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     118      <Private>False</Private>
    112119    </Reference>
    113120    <Reference Include="HeuristicLab.Data-3.3">
    114121      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     122      <Private>False</Private>
    115123    </Reference>
    116124    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
    117125      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     126      <Private>False</Private>
    118127    </Reference>
    119128    <Reference Include="HeuristicLab.Operators-3.3">
    120129      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     130      <Private>False</Private>
    121131    </Reference>
    122132    <Reference Include="HeuristicLab.Optimization-3.3">
    123133      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     134      <Private>False</Private>
    124135    </Reference>
    125136    <Reference Include="HeuristicLab.Optimization.Operators-3.3">
    126137      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     138      <Private>False</Private>
    127139    </Reference>
    128140    <Reference Include="HeuristicLab.Parameters-3.3">
    129141      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     142      <Private>False</Private>
    130143    </Reference>
    131144    <Reference Include="HeuristicLab.Persistence-3.3">
    132145      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     146      <Private>False</Private>
    133147    </Reference>
    134148    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    135149      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     150      <Private>False</Private>
    136151    </Reference>
    137152    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4">
    138153      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
     154      <Private>False</Private>
    139155    </Reference>
    140156    <Reference Include="HeuristicLab.Problems.Instances-3.3">
    141157      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     158      <Private>False</Private>
    142159    </Reference>
    143160    <Reference Include="HeuristicLab.Random-3.3">
    144161      <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     162      <Private>False</Private>
    145163    </Reference>
    146164    <Reference Include="System" />
     
    187205    <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" />
    188206    <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" />
     207    <Compile Include="Interpreter\InterpreterState.cs" />
     208    <Compile Include="Interpreter\OpCodes.cs" />
     209    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs" />
     210    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeInterpreter.cs" />
    189211    <Compile Include="Plugin.cs" />
    190     <Compile Include="SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs" />
    191212    <Compile Include="Formatters\SymbolicDataAnalysisExpressionLatexFormatter.cs" />
    192213    <Compile Include="Formatters\SymbolicDataAnalysisExpressionMATLABFormatter.cs" />
     
    206227    <Compile Include="Interfaces\ISymbolicDataAnalysisAnalyzer.cs" />
    207228    <Compile Include="SymbolicDataAnalysisSingleObjectiveProblem.cs" />
    208     <Compile Include="SymbolicDataAnalysisExpressionTreeInterpreter.cs" />
    209229    <Compile Include="SymbolicDataAnalysisExpressionTreeSimplifier.cs" />
    210230    <Compile Include="SymbolicDataAnalysisProblem.cs" />
    211     <Compile Include="SymbolicDataAnalysisSolutionValuesCalculator.cs" />
     231    <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" />
    212232    <Compile Include="Symbols\Addition.cs" />
    213233    <Compile Include="Symbols\And.cs" />
     234    <Compile Include="Symbols\AutoregressiveVariable.cs" />
    214235    <Compile Include="Symbols\Average.cs" />
    215236    <Compile Include="Symbols\Constant.cs" />
     
    301322  -->
    302323  <PropertyGroup>
    303     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     324    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    304325set ProjectDir=$(ProjectDir)
    305326set SolutionDir=$(SolutionDir)
     
    308329call PreBuildEvent.cmd
    309330</PreBuildEvent>
     331    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     332export ProjectDir=$(ProjectDir)
     333export SolutionDir=$(SolutionDir)
     334
     335$SolutionDir/PreBuildEvent.sh
     336</PreBuildEvent>
    310337  </PropertyGroup>
    311338</Project>
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisEvaluator.cs

    r7259 r8915  
    2929    IValueLookupParameter<IntRange> EvaluationPartitionParameter { get; }
    3030    IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter { get; }
     31    ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; }
    3132
    3233    IValueLookupParameter<T> ProblemDataParameter { get; }
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisMultiObjectiveAnalyzer.cs

    r7259 r8915  
    2121using HeuristicLab.Core;
    2222using HeuristicLab.Data;
    23 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    24 using HeuristicLab.Optimization;
    25 using HeuristicLab.Parameters;
    2623namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2724  public interface ISymbolicDataAnalysisMultiObjectiveAnalyzer : ISymbolicDataAnalysisAnalyzer {
    2825    IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { get; }
    2926    ILookupParameter<BoolArray> MaximizationParameter { get; }
     27    ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; }
    3028
    3129  }
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisSingleObjectiveAnalyzer.cs

    r7259 r8915  
    2828    IScopeTreeLookupParameter<DoubleValue> QualityParameter { get; }
    2929    ILookupParameter<BoolValue> MaximizationParameter { get; }
     30    ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; }
    3031  }
    3132}
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame

    r8246 r8915  
    2828  [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic","Provides base classes for symbolic data analysis tasks.", "3.4.3.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.ALGLIB", "3.5.0")]
     30  [PluginDependency("HeuristicLab.ALGLIB", "3.6.0")]
    3131  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3232  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs

    r7696 r8915  
    5252    private GreaterThan gtSymbol = new GreaterThan();
    5353    private LessThan ltSymbol = new LessThan();
     54    private Integral integralSymbol = new Integral();
     55    private LaggedVariable laggedVariableSymbol = new LaggedVariable();
     56    private TimeLag timeLagSymbol = new TimeLag();
    5457
    5558    public ISymbolicExpressionTree Simplify(ISymbolicExpressionTree originalTree) {
     
    182185    private bool IsConstant(ISymbolicExpressionTreeNode node) {
    183186      return node.Symbol is Constant;
     187    }
     188
     189    // dynamic
     190    private bool IsTimeLag(ISymbolicExpressionTreeNode node) {
     191      return node.Symbol is TimeLag;
     192    }
     193    private bool IsIntegral(ISymbolicExpressionTreeNode node) {
     194      return node.Symbol is Integral;
    184195    }
    185196
     
    234245      } else if (IsNot(original)) {
    235246        return SimplifyNot(original);
     247      } else if (IsTimeLag(original)) {
     248        return SimplifyTimeLag(original);
     249      } else if (IsIntegral(original)) {
     250        return SimplifyIntegral(original);
    236251      } else {
    237252        return SimplifyAny(original);
     
    376391      return MakePower(GetSimplifiedTree(original.GetSubtree(0)), GetSimplifiedTree(original.GetSubtree(1)));
    377392    }
     393    private ISymbolicExpressionTreeNode SimplifyTimeLag(ISymbolicExpressionTreeNode original) {
     394      var laggedTreeNode = original as ILaggedTreeNode;
     395      var simplifiedSubtree = GetSimplifiedTree(original.GetSubtree(0));
     396      if (!ContainsVariableCondition(simplifiedSubtree)) {
     397        return AddLagToDynamicNodes(simplifiedSubtree, laggedTreeNode.Lag);
     398      } else {
     399        return MakeTimeLag(simplifiedSubtree, laggedTreeNode.Lag);
     400      }
     401    }
     402    private ISymbolicExpressionTreeNode SimplifyIntegral(ISymbolicExpressionTreeNode original) {
     403      var laggedTreeNode = original as ILaggedTreeNode;
     404      var simplifiedSubtree = GetSimplifiedTree(original.GetSubtree(0));
     405      if (IsConstant(simplifiedSubtree)) {
     406        return GetSimplifiedTree(MakeProduct(simplifiedSubtree, MakeConstant(-laggedTreeNode.Lag)));
     407      } else {
     408        return MakeIntegral(simplifiedSubtree, laggedTreeNode.Lag);
     409      }
     410    }
     411
    378412    #endregion
    379413
    380414    #region low level tree restructuring
     415    private ISymbolicExpressionTreeNode MakeTimeLag(ISymbolicExpressionTreeNode subtree, int lag) {
     416      if (lag == 0) return subtree;
     417      if (IsConstant(subtree)) return subtree;
     418      var lagNode = (LaggedTreeNode)timeLagSymbol.CreateTreeNode();
     419      lagNode.Lag = lag;
     420      lagNode.AddSubtree(subtree);
     421      return lagNode;
     422    }
     423
     424    private ISymbolicExpressionTreeNode MakeIntegral(ISymbolicExpressionTreeNode subtree, int lag) {
     425      if (lag == 0) return subtree;
     426      else if (lag == -1 || lag == 1) {
     427        return MakeSum(subtree, AddLagToDynamicNodes((ISymbolicExpressionTreeNode)subtree.Clone(), lag));
     428      } else {
     429        var node = (LaggedTreeNode)integralSymbol.CreateTreeNode();
     430        node.Lag = lag;
     431        node.AddSubtree(subtree);
     432        return node;
     433      }
     434    }
     435
    381436    private ISymbolicExpressionTreeNode MakeNot(ISymbolicExpressionTreeNode t) {
    382437      if (IsConstant(t)) {
     
    847902
    848903    #region helper functions
     904    private bool ContainsVariableCondition(ISymbolicExpressionTreeNode node) {
     905      if (node.Symbol is VariableCondition) return true;
     906      foreach (var subtree in node.Subtrees)
     907        if (ContainsVariableCondition(subtree)) return true;
     908      return false;
     909    }
     910
     911    private ISymbolicExpressionTreeNode AddLagToDynamicNodes(ISymbolicExpressionTreeNode node, int lag) {
     912      var laggedTreeNode = node as ILaggedTreeNode;
     913      var variableNode = node as VariableTreeNode;
     914      var variableConditionNode = node as VariableConditionTreeNode;
     915      if (laggedTreeNode != null)
     916        laggedTreeNode.Lag += lag;
     917      else if (variableNode != null) {
     918        var laggedVariableNode = (LaggedVariableTreeNode)laggedVariableSymbol.CreateTreeNode();
     919        laggedVariableNode.Lag = lag;
     920        laggedVariableNode.VariableName = variableNode.VariableName;
     921        return laggedVariableNode;
     922      } else if (variableConditionNode != null) {
     923        throw new NotSupportedException("Removal of time lags around variable condition symbols is not allowed.");
     924      }
     925      var subtrees = new List<ISymbolicExpressionTreeNode>(node.Subtrees);
     926      while (node.SubtreeCount > 0) node.RemoveSubtree(0);
     927      foreach (var subtree in subtrees) {
     928        node.AddSubtree(AddLagToDynamicNodes(subtree, lag));
     929      }
     930      return node;
     931    }
    849932
    850933    private bool AreSameVariable(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b) {
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs

    r7259 r8915  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
    2324using HeuristicLab.Common;
     
    6667      this.interpreter = interpreter;
    6768    }
     69
     70    #region Scaling
     71    public static void Scale(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData, string targetVariable) {
     72      var dataset = problemData.Dataset;
     73      var rows = problemData.TrainingIndices;
     74      var estimatedValues = model.Interpreter.GetSymbolicExpressionTreeValues(model.SymbolicExpressionTree, dataset, rows);
     75      var targetValues = dataset.GetDoubleValues(targetVariable, rows);
     76
     77      var linearScalingCalculator = new OnlineLinearScalingParameterCalculator();
     78      var targetValuesEnumerator = targetValues.GetEnumerator();
     79      var estimatedValuesEnumerator = estimatedValues.GetEnumerator();
     80      while (targetValuesEnumerator.MoveNext() & estimatedValuesEnumerator.MoveNext()) {
     81        double target = targetValuesEnumerator.Current;
     82        double estimated = estimatedValuesEnumerator.Current;
     83        if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
     84          linearScalingCalculator.Add(estimated, target);
     85      }
     86      if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None && (targetValuesEnumerator.MoveNext() || estimatedValuesEnumerator.MoveNext()))
     87        throw new ArgumentException("Number of elements in target and estimated values enumeration do not match.");
     88
     89      double alpha = linearScalingCalculator.Alpha;
     90      double beta = linearScalingCalculator.Beta;
     91      if (linearScalingCalculator.ErrorState != OnlineCalculatorError.None) return;
     92
     93      ConstantTreeNode alphaTreeNode = null;
     94      ConstantTreeNode betaTreeNode = null;
     95      // check if model has been scaled previously by analyzing the structure of the tree
     96      var startNode = model.SymbolicExpressionTree.Root.GetSubtree(0);
     97      if (startNode.GetSubtree(0).Symbol is Addition) {
     98        var addNode = startNode.GetSubtree(0);
     99        if (addNode.SubtreeCount == 2 && addNode.GetSubtree(0).Symbol is Multiplication && addNode.GetSubtree(1).Symbol is Constant) {
     100          alphaTreeNode = addNode.GetSubtree(1) as ConstantTreeNode;
     101          var mulNode = addNode.GetSubtree(0);
     102          if (mulNode.SubtreeCount == 2 && mulNode.GetSubtree(1).Symbol is Constant) {
     103            betaTreeNode = mulNode.GetSubtree(1) as ConstantTreeNode;
     104          }
     105        }
     106      }
     107      // if tree structure matches the structure necessary for linear scaling then reuse the existing tree nodes
     108      if (alphaTreeNode != null && betaTreeNode != null) {
     109        betaTreeNode.Value *= beta;
     110        alphaTreeNode.Value *= beta;
     111        alphaTreeNode.Value += alpha;
     112      } else {
     113        var mainBranch = startNode.GetSubtree(0);
     114        startNode.RemoveSubtree(0);
     115        var scaledMainBranch = MakeSum(MakeProduct(mainBranch, beta), alpha);
     116        startNode.AddSubtree(scaledMainBranch);
     117      }
     118    }
     119
     120    private static ISymbolicExpressionTreeNode MakeSum(ISymbolicExpressionTreeNode treeNode, double alpha) {
     121      if (alpha.IsAlmost(0.0)) {
     122        return treeNode;
     123      } else {
     124        var addition = new Addition();
     125        var node = addition.CreateTreeNode();
     126        var alphaConst = MakeConstant(alpha);
     127        node.AddSubtree(treeNode);
     128        node.AddSubtree(alphaConst);
     129        return node;
     130      }
     131    }
     132
     133    private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) {
     134      if (beta.IsAlmost(1.0)) {
     135        return treeNode;
     136      } else {
     137        var multipliciation = new Multiplication();
     138        var node = multipliciation.CreateTreeNode();
     139        var betaConst = MakeConstant(beta);
     140        node.AddSubtree(treeNode);
     141        node.AddSubtree(betaConst);
     142        return node;
     143      }
     144    }
     145
     146    private static ISymbolicExpressionTreeNode MakeConstant(double c) {
     147      var node = (ConstantTreeNode)(new Constant()).CreateTreeNode();
     148      node.Value = c;
     149      return node;
     150    }
     151    #endregion
    68152  }
    69153}
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r8203 r8915  
    5353    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
    5454    private const string ValidationPartitionParameterName = "ValidationPartition";
     55    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    5556
    5657    private const string ProblemDataParameterDescription = "";
     
    6465    private const string FitnessCalculationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to calculate the fitness of an individual.";
    6566    private const string ValidationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to select the best model from (optional).";
     67    private const string ApplyLinearScalingParameterDescription = "Flag that indicates if the individual should be linearly scaled before evaluating.";
    6668    #endregion
    6769
     
    100102      get { return (IFixedValueParameter<IntRange>)Parameters[ValidationPartitionParameterName]; }
    101103    }
     104    public IFixedValueParameter<BoolValue> ApplyLinearScalingParameter {
     105      get { return (IFixedValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
     106    }
    102107    #endregion
    103108
     
    144149    public IntRange ValidationPartition {
    145150      get { return ValidationPartitionParameter.Value; }
     151    }
     152    public BoolValue ApplyLinearScaling {
     153      get { return ApplyLinearScalingParameter.Value; }
    146154    }
    147155    #endregion
     
    151159    [StorableHook(HookType.AfterDeserialization)]
    152160    private void AfterDeserialization() {
     161      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {
     162        Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));
     163        ApplyLinearScalingParameter.Hidden = true;
     164
     165        //it is assumed that for all symbolic regression algorithms linear scaling was set to true
     166        //there is no possibility to determine the previous value of the parameter as it was stored in the evaluator
     167        if (GetType().Name.Contains("SymbolicRegression"))
     168          ApplyLinearScaling.Value = true;
     169      }
     170
    153171      RegisterEventHandlers();
    154172    }
     
    170188      Parameters.Add(new FixedValueParameter<IntRange>(ValidationPartitionParameterName, ValidationPartitionParameterDescription));
    171189      Parameters.Add(new FixedValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, RelativeNumberOfEvaluatedSamplesParameterDescription, new PercentValue(1)));
     190      Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));
    172191
    173192      SymbolicExpressionTreeInterpreterParameter.Hidden = true;
    174193      MaximumFunctionArgumentsParameter.Hidden = true;
    175194      MaximumFunctionDefinitionsParameter.Hidden = true;
     195      ApplyLinearScalingParameter.Hidden = true;
    176196
    177197      SymbolicExpressionTreeGrammar = new TypeCoherentExpressionGrammar();
     
    191211      SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value;
    192212      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {
    193         if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables;
     213        if (!varSymbol.Fixed) varSymbol.AllVariableNames = ProblemData.AllowedInputVariables;
    194214      }
    195215      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {
    196         if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables;
     216        if (!varSymbol.Fixed) varSymbol.AllVariableNames = ProblemData.AllowedInputVariables;
    197217      }
    198218    }
     
    274294
    275295      foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
    276         op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameterName;
     296        op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name;
    277297      }
    278298      foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {
    279         op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameterName;
    280         op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameterName;
     299        op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name;
     300        op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
    281301      }
    282302      foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) {
    283         op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameterName;
    284         op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameterName;
     303        op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name;
     304        op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name;
    285305      }
    286306      foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) {
     
    289309        op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
    290310        op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
     311        op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
    291312      }
    292313      foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) {
     
    300321        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    301322      }
     323      foreach (var op in operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>()) {
     324        op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
     325      }
     326      foreach (var op in operators.OfType<ISymbolicDataAnalysisMultiObjectiveAnalyzer>()) {
     327        op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
     328      }
    302329      foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) {
    303330        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     
    308335      }
    309336      foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>()) {
    310         op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameterName;
     337        op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
    311338      }
    312339      foreach (var op in operators.OfType<ISymbolicDataAnalysisExpressionCrossover<T>>()) {
    313         op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameterName;
     340        op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
    314341        op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    315342        op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedVariable.cs

    r7259 r8915  
    2727  [StorableClass]
    2828  [Item("LaggedVariable", "Represents a variable value with a time offset.")]
    29   public sealed class LaggedVariable : Variable {
     29  public class LaggedVariable : Variable {
    3030    [Storable]
    3131    private int minLag;
     
    4141    }
    4242    [StorableConstructor]
    43     private LaggedVariable(bool deserializing) : base(deserializing) { }
    44     private LaggedVariable(LaggedVariable original, Cloner cloner)
     43    protected LaggedVariable(bool deserializing) : base(deserializing) { }
     44    protected LaggedVariable(LaggedVariable original, Cloner cloner)
    4545      : base(original, cloner) {
    4646      minLag = original.minLag;
    4747      maxLag = original.maxLag;
    4848    }
    49     public LaggedVariable()
    50       : base("LaggedVariable", "Represents a variable value with a time offset.") {
    51       minLag = -1; maxLag = -1;
     49    public LaggedVariable() : this("LaggedVariable", "Represents a variable value with a time offset.") { }
     50    protected LaggedVariable(string name, string description)
     51      : base(name, description) {
     52      MinLag = -1;
     53      MaxLag = -1;
    5254    }
    5355
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedVariableTreeNode.cs

    r7259 r8915  
    3737    }
    3838
     39    public override bool HasLocalParameters {
     40      get { return true; }
     41    }
     42
    3943    [StorableConstructor]
    4044    private LaggedVariableTreeNode(bool deserializing) : base(deserializing) { }
     
    4347      lag = original.lag;
    4448    }
    45     private LaggedVariableTreeNode() { }
    4649
    4750    public LaggedVariableTreeNode(LaggedVariable variableSymbol) : base(variableSymbol) { }
    4851
    49     public override bool HasLocalParameters {
    50       get {
    51         return true;
    52       }
    53     }
    5452
    5553    public override void ResetLocalParameters(IRandom random) {
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs

    r7259 r8915  
    101101    }
    102102
     103    private List<string> allVariableNames;
     104    [Storable]
     105    public IEnumerable<string> AllVariableNames {
     106      get { return allVariableNames; }
     107      set {
     108        if (value == null) throw new ArgumentNullException();
     109        allVariableNames.Clear();
     110        allVariableNames.AddRange(value);
     111        VariableNames = value;
     112      }
     113    }
     114
     115    public override bool Enabled {
     116      get {
     117        if (variableNames.Count == 0) return false;
     118        return base.Enabled;
     119      }
     120      set {
     121        if (variableNames.Count == 0) base.Enabled = false;
     122        else base.Enabled = value;
     123      }
     124    }
     125
    103126    private const int minimumArity = 0;
    104127    private const int maximumArity = 0;
     
    112135    #endregion
    113136
     137    [StorableHook(HookType.AfterDeserialization)]
     138    private void AfterDeserialization() {
     139      if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) {
     140        allVariableNames = variableNames;
     141      }
     142    }
     143
    114144    [StorableConstructor]
    115145    protected Variable(bool deserializing)
    116146      : base(deserializing) {
    117147      variableNames = new List<string>();
     148      allVariableNames = new List<string>();
    118149    }
    119150    protected Variable(Variable original, Cloner cloner)
     
    122153      weightSigma = original.weightSigma;
    123154      variableNames = new List<string>(original.variableNames);
     155      allVariableNames = new List<string>(original.allVariableNames);
    124156      weightManipulatorMu = original.weightManipulatorMu;
    125157      weightManipulatorSigma = original.weightManipulatorSigma;
     
    135167      multiplicativeWeightManipulatorSigma = 0.03;
    136168      variableNames = new List<string>();
     169      allVariableNames = new List<string>();
    137170    }
    138171
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs

    r8099 r8915  
    8686      set {
    8787        if (value == null) throw new ArgumentNullException();
    88         variableNames = new List<string>(value);
     88        variableNames.Clear();
     89        variableNames.AddRange(value);
    8990        OnChanged(EventArgs.Empty);
     91      }
     92    }
     93
     94    private List<string> allVariableNames;
     95    [Storable]
     96    public IEnumerable<string> AllVariableNames {
     97      get { return allVariableNames; }
     98      set {
     99        if (value == null) throw new ArgumentNullException();
     100        allVariableNames.Clear();
     101        allVariableNames.AddRange(value);
     102        VariableNames = value;
    90103      }
    91104    }
     
    151164
    152165    #region persistence and cloning
     166    [StorableHook(HookType.AfterDeserialization)]
     167    private void AfterDeserialization() {
     168      if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) {
     169        allVariableNames = variableNames;
     170      }
     171    }
     172
    153173    [StorableConstructor]
    154     private VariableCondition(bool deserializing) : base(deserializing) { }
     174    private VariableCondition(bool deserializing)
     175      : base(deserializing) {
     176      variableNames = new List<string>();
     177      allVariableNames = new List<string>();
     178    }
    155179    private VariableCondition(VariableCondition original, Cloner cloner)
    156180      : base(original, cloner) {
     
    161185
    162186      variableNames = new List<string>(original.variableNames);
     187      allVariableNames = new List<string>(original.allVariableNames);
    163188
    164189      slopeInitializerMu = original.slopeInitializerMu;
     
    181206
    182207      variableNames = new List<string>();
     208      allVariableNames = new List<string>();
    183209
    184210      slopeInitializerMu = 0.0;
Note: See TracChangeset for help on using the changeset viewer.