- Timestamp:
- 11/15/12 16:47:25 (12 years ago)
- 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 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 using HeuristicLab.Operators;29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 27 33 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 39 34 private const string QualitiesParameterName = "Qualities"; 40 35 private const string MaximizationParameterName = "Maximization"; 36 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 41 37 #region parameter properties 42 38 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { … … 45 41 public ILookupParameter<BoolArray> MaximizationParameter { 46 42 get { return (ILookupParameter<BoolArray>)Parameters[MaximizationParameterName]; } 43 } 44 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 45 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 47 46 } 48 47 #endregion … … 64 63 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>(QualitiesParameterName, "The qualities of the trees that should be analyzed.")); 65 64 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.")); 66 74 } 67 75 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveAnalyzer.cs
r7259 r8915 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 using HeuristicLab.Operators;29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 27 33 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 39 34 private const string QualityParameterName = "Quality"; 40 35 private const string MaximizationParameterName = "Maximization"; 36 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 37 41 38 #region parameter properties 42 39 public IScopeTreeLookupParameter<DoubleValue> QualityParameter { … … 45 42 public ILookupParameter<BoolValue> MaximizationParameter { 46 43 get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; } 44 } 45 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 46 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 47 47 } 48 48 #endregion … … 64 64 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The qualities of the trees that should be analyzed.")); 65 65 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.")); 66 75 } 67 76 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs
r7259 r8915 85 85 86 86 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))) { 89 89 TrainingBestSolution = CreateSolution(bestTree, bestQuality); 90 90 TrainingBestSolutionQuality = new DoubleValue(bestQuality); -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r7721 r8915 76 76 : base(original, cloner) { 77 77 } 78 public SymbolicDataAnalysisSingleObjectiveValidationAnalyzer() 79 78 79 protected SymbolicDataAnalysisSingleObjectiveValidationAnalyzer(): base() { 80 80 Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator.")); 81 81 Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem.")); 82 82 Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition.")); 83 83 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees.")); 84 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The svalidation partition."));84 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition.")); 85 85 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.")); 86 86 Parameters.Add(new ValueLookupParameter<PercentValue>(PercentageOfBestSolutionsParameterName, -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r7259 r8915 109 109 // update variable impacts matrix 110 110 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) }) 112 112 .OrderByDescending(p => p.Impact) 113 113 .ToList(); -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Evaluators/SymbolicDataAnalysisEvaluator.cs
r7259 r8915 44 44 private const string EvaluationPartitionParameterName = "EvaluationPartition"; 45 45 private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples"; 46 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 47 private const string ValidRowIndicatorParameterName = "ValidRowIndicator"; 46 48 47 49 public override bool CanChangeName { get { return false; } } … … 70 72 get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; } 71 73 } 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 } 72 80 #endregion 73 81 … … 87 95 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.")); 88 96 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).")); 89 109 } 90 110 … … 94 114 95 115 protected IEnumerable<int> GenerateRowsToEvaluate(double percentageOfRows) { 96 97 98 116 IEnumerable<int> rows; 99 117 int samplesStart = EvaluationPartitionParameter.ActualValue.Start; … … 101 119 int testPartitionStart = ProblemDataParameter.ActualValue.TestPartition.Start; 102 120 int testPartitionEnd = ProblemDataParameter.ActualValue.TestPartition.End; 103 104 121 if (samplesEnd < samplesStart) throw new ArgumentException("Start value is larger than end value."); 105 122 … … 113 130 } 114 131 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 } 116 183 } 117 184 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7708 r8915 33 33 [StorableClass] 34 34 public sealed class SymbolicDataAnalysisExpressionLatexFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 35 private List<double> constants; 35 private readonly List<double> constants; 36 private int targetCount; 36 37 private int currentLag; 37 38 … … 98 99 } else if (node.Symbol is Division) { 99 100 if (node.SubtreeCount == 1) { 100 strBuilder.Append(@" \cfrac{1 }{");101 strBuilder.Append(@" \cfrac{1"); 101 102 } else { 102 103 strBuilder.Append(@" \cfrac{ "); … … 196 197 strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( "); 197 198 } else if (node.Symbol is StartSymbol) { 198 strBuilder.Append(" Result& = ");199 strBuilder.Append("target_" + (targetCount++) + "(t) & = "); 199 200 } else if (node.Symbol is Argument) { 200 201 var argSym = node.Symbol as Argument; … … 301 302 strBuilder.Append(" , "); 302 303 } else if (node.Symbol is StartSymbol) { 303 strBuilder.Append(@"\\" + Environment.NewLine + " & "); 304 strBuilder.Append(@"\\" + Environment.NewLine); 305 strBuilder.Append("target_" + (targetCount++) + "(t) & = "); 304 306 } else if (node.Symbol is Power) { 305 307 strBuilder.Append(@"\right) ^ { \operatorname{round} \left("); -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r7707 r8915 116 116 var laggedVariable = new LaggedVariable(); 117 117 laggedVariable.InitialFrequency = 0.0; 118 var autoregressiveVariable = new AutoregressiveTargetVariable(); 119 autoregressiveVariable.InitialFrequency = 0.0; 120 autoregressiveVariable.Enabled = false; 118 121 119 122 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp, 120 123 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 }; 122 125 var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative, 123 126 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral … … 126 129 var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, variableCondition }; 127 130 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 }; 129 132 130 133 foreach (var symb in allSymbols) -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r7696 r8915 104 104 var variableSymbol = new Variable(); 105 105 var laggedVariable = new LaggedVariable(); 106 var autoregressiveVariable = new AutoregressiveTargetVariable(); 106 107 #endregion 107 108 … … 122 123 var conditionalSymbols = new GroupSymbol(ConditionalSymbolsName, new List<ISymbol> { conditionSymbols, comparisonSymbols, booleanOperationSymbols }); 123 124 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 }); 125 126 #endregion 126 127 … … 152 153 SetSubtreeCount(derivative, 1, 1); 153 154 SetSubtreeCount(laggedVariable, 0, 0); 155 SetSubtreeCount(autoregressiveVariable, 0, 0); 154 156 #endregion 155 157 … … 225 227 Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = false; 226 228 } 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 } 227 242 } 228 243 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r8388 r8915 93 93 </PropertyGroup> 94 94 <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> 97 99 </Reference> 98 100 <Reference Include="HeuristicLab.Analysis-3.3"> 99 101 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 102 <Private>False</Private> 100 103 </Reference> 101 104 <Reference Include="HeuristicLab.Collections-3.3"> 102 105 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> 106 <Private>False</Private> 103 107 </Reference> 104 108 <Reference Include="HeuristicLab.Common-3.3"> 105 109 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 110 <Private>False</Private> 106 111 </Reference> 107 112 <Reference Include="HeuristicLab.Common.Resources-3.3"> 108 113 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath> 114 <Private>False</Private> 109 115 </Reference> 110 116 <Reference Include="HeuristicLab.Core-3.3"> 111 117 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 118 <Private>False</Private> 112 119 </Reference> 113 120 <Reference Include="HeuristicLab.Data-3.3"> 114 121 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 122 <Private>False</Private> 115 123 </Reference> 116 124 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4"> 117 125 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath> 126 <Private>False</Private> 118 127 </Reference> 119 128 <Reference Include="HeuristicLab.Operators-3.3"> 120 129 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath> 130 <Private>False</Private> 121 131 </Reference> 122 132 <Reference Include="HeuristicLab.Optimization-3.3"> 123 133 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath> 134 <Private>False</Private> 124 135 </Reference> 125 136 <Reference Include="HeuristicLab.Optimization.Operators-3.3"> 126 137 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath> 138 <Private>False</Private> 127 139 </Reference> 128 140 <Reference Include="HeuristicLab.Parameters-3.3"> 129 141 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> 142 <Private>False</Private> 130 143 </Reference> 131 144 <Reference Include="HeuristicLab.Persistence-3.3"> 132 145 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath> 146 <Private>False</Private> 133 147 </Reference> 134 148 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 135 149 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 150 <Private>False</Private> 136 151 </Reference> 137 152 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4"> 138 153 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath> 154 <Private>False</Private> 139 155 </Reference> 140 156 <Reference Include="HeuristicLab.Problems.Instances-3.3"> 141 157 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath> 158 <Private>False</Private> 142 159 </Reference> 143 160 <Reference Include="HeuristicLab.Random-3.3"> 144 161 <HintPath>..\..\..\..\Trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath> 162 <Private>False</Private> 145 163 </Reference> 146 164 <Reference Include="System" /> … … 187 205 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" /> 188 206 <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" /> 189 211 <Compile Include="Plugin.cs" /> 190 <Compile Include="SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs" />191 212 <Compile Include="Formatters\SymbolicDataAnalysisExpressionLatexFormatter.cs" /> 192 213 <Compile Include="Formatters\SymbolicDataAnalysisExpressionMATLABFormatter.cs" /> … … 206 227 <Compile Include="Interfaces\ISymbolicDataAnalysisAnalyzer.cs" /> 207 228 <Compile Include="SymbolicDataAnalysisSingleObjectiveProblem.cs" /> 208 <Compile Include="SymbolicDataAnalysisExpressionTreeInterpreter.cs" />209 229 <Compile Include="SymbolicDataAnalysisExpressionTreeSimplifier.cs" /> 210 230 <Compile Include="SymbolicDataAnalysisProblem.cs" /> 211 <Compile Include="SymbolicDataAnalysisSolution ValuesCalculator.cs" />231 <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" /> 212 232 <Compile Include="Symbols\Addition.cs" /> 213 233 <Compile Include="Symbols\And.cs" /> 234 <Compile Include="Symbols\AutoregressiveVariable.cs" /> 214 235 <Compile Include="Symbols\Average.cs" /> 215 236 <Compile Include="Symbols\Constant.cs" /> … … 301 322 --> 302 323 <PropertyGroup> 303 <PreBuildEvent >set Path=%25Path%25;$(ProjectDir);$(SolutionDir)324 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 304 325 set ProjectDir=$(ProjectDir) 305 326 set SolutionDir=$(SolutionDir) … … 308 329 call PreBuildEvent.cmd 309 330 </PreBuildEvent> 331 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 332 export ProjectDir=$(ProjectDir) 333 export SolutionDir=$(SolutionDir) 334 335 $SolutionDir/PreBuildEvent.sh 336 </PreBuildEvent> 310 337 </PropertyGroup> 311 338 </Project> -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisEvaluator.cs
r7259 r8915 29 29 IValueLookupParameter<IntRange> EvaluationPartitionParameter { get; } 30 30 IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter { get; } 31 ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; } 31 32 32 33 IValueLookupParameter<T> ProblemDataParameter { get; } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisMultiObjectiveAnalyzer.cs
r7259 r8915 21 21 using HeuristicLab.Core; 22 22 using HeuristicLab.Data; 23 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;24 using HeuristicLab.Optimization;25 using HeuristicLab.Parameters;26 23 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 27 24 public interface ISymbolicDataAnalysisMultiObjectiveAnalyzer : ISymbolicDataAnalysisAnalyzer { 28 25 IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { get; } 29 26 ILookupParameter<BoolArray> MaximizationParameter { get; } 27 ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; } 30 28 31 29 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisSingleObjectiveAnalyzer.cs
r7259 r8915 28 28 IScopeTreeLookupParameter<DoubleValue> QualityParameter { get; } 29 29 ILookupParameter<BoolValue> MaximizationParameter { get; } 30 ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; } 30 31 } 31 32 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r8246 r8915 28 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic","Provides base classes for symbolic data analysis tasks.", "3.4.3.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3. 5.0")]30 [PluginDependency("HeuristicLab.ALGLIB", "3.6.0")] 31 31 [PluginDependency("HeuristicLab.Analysis", "3.3")] 32 32 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r7696 r8915 52 52 private GreaterThan gtSymbol = new GreaterThan(); 53 53 private LessThan ltSymbol = new LessThan(); 54 private Integral integralSymbol = new Integral(); 55 private LaggedVariable laggedVariableSymbol = new LaggedVariable(); 56 private TimeLag timeLagSymbol = new TimeLag(); 54 57 55 58 public ISymbolicExpressionTree Simplify(ISymbolicExpressionTree originalTree) { … … 182 185 private bool IsConstant(ISymbolicExpressionTreeNode node) { 183 186 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; 184 195 } 185 196 … … 234 245 } else if (IsNot(original)) { 235 246 return SimplifyNot(original); 247 } else if (IsTimeLag(original)) { 248 return SimplifyTimeLag(original); 249 } else if (IsIntegral(original)) { 250 return SimplifyIntegral(original); 236 251 } else { 237 252 return SimplifyAny(original); … … 376 391 return MakePower(GetSimplifiedTree(original.GetSubtree(0)), GetSimplifiedTree(original.GetSubtree(1))); 377 392 } 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 378 412 #endregion 379 413 380 414 #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 381 436 private ISymbolicExpressionTreeNode MakeNot(ISymbolicExpressionTreeNode t) { 382 437 if (IsConstant(t)) { … … 847 902 848 903 #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 } 849 932 850 933 private bool AreSameVariable(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b) { -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs
r7259 r8915 20 20 #endregion 21 21 22 using System; 22 23 using System.Drawing; 23 24 using HeuristicLab.Common; … … 66 67 this.interpreter = interpreter; 67 68 } 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 68 152 } 69 153 } -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r8203 r8915 53 53 private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition"; 54 54 private const string ValidationPartitionParameterName = "ValidationPartition"; 55 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 55 56 56 57 private const string ProblemDataParameterDescription = ""; … … 64 65 private const string FitnessCalculationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to calculate the fitness of an individual."; 65 66 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."; 66 68 #endregion 67 69 … … 100 102 get { return (IFixedValueParameter<IntRange>)Parameters[ValidationPartitionParameterName]; } 101 103 } 104 public IFixedValueParameter<BoolValue> ApplyLinearScalingParameter { 105 get { return (IFixedValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 106 } 102 107 #endregion 103 108 … … 144 149 public IntRange ValidationPartition { 145 150 get { return ValidationPartitionParameter.Value; } 151 } 152 public BoolValue ApplyLinearScaling { 153 get { return ApplyLinearScalingParameter.Value; } 146 154 } 147 155 #endregion … … 151 159 [StorableHook(HookType.AfterDeserialization)] 152 160 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 153 171 RegisterEventHandlers(); 154 172 } … … 170 188 Parameters.Add(new FixedValueParameter<IntRange>(ValidationPartitionParameterName, ValidationPartitionParameterDescription)); 171 189 Parameters.Add(new FixedValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, RelativeNumberOfEvaluatedSamplesParameterDescription, new PercentValue(1))); 190 Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false))); 172 191 173 192 SymbolicExpressionTreeInterpreterParameter.Hidden = true; 174 193 MaximumFunctionArgumentsParameter.Hidden = true; 175 194 MaximumFunctionDefinitionsParameter.Hidden = true; 195 ApplyLinearScalingParameter.Hidden = true; 176 196 177 197 SymbolicExpressionTreeGrammar = new TypeCoherentExpressionGrammar(); … … 191 211 SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value; 192 212 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; 194 214 } 195 215 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; 197 217 } 198 218 } … … 274 294 275 295 foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) { 276 op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter Name;296 op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name; 277 297 } 278 298 foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) { 279 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter Name;280 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter Name;299 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name; 300 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name; 281 301 } 282 302 foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) { 283 op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter Name;284 op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter Name;303 op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name; 304 op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name; 285 305 } 286 306 foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) { … … 289 309 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; 290 310 op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name; 311 op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name; 291 312 } 292 313 foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) { … … 300 321 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 301 322 } 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 } 302 329 foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) { 303 330 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; … … 308 335 } 309 336 foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>()) { 310 op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter Name;337 op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 311 338 } 312 339 foreach (var op in operators.OfType<ISymbolicDataAnalysisExpressionCrossover<T>>()) { 313 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter Name;340 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; 314 341 op.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 315 342 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedVariable.cs
r7259 r8915 27 27 [StorableClass] 28 28 [Item("LaggedVariable", "Represents a variable value with a time offset.")] 29 public sealedclass LaggedVariable : Variable {29 public class LaggedVariable : Variable { 30 30 [Storable] 31 31 private int minLag; … … 41 41 } 42 42 [StorableConstructor] 43 pr ivateLaggedVariable(bool deserializing) : base(deserializing) { }44 pr ivateLaggedVariable(LaggedVariable original, Cloner cloner)43 protected LaggedVariable(bool deserializing) : base(deserializing) { } 44 protected LaggedVariable(LaggedVariable original, Cloner cloner) 45 45 : base(original, cloner) { 46 46 minLag = original.minLag; 47 47 maxLag = original.maxLag; 48 48 } 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; 52 54 } 53 55 -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedVariableTreeNode.cs
r7259 r8915 37 37 } 38 38 39 public override bool HasLocalParameters { 40 get { return true; } 41 } 42 39 43 [StorableConstructor] 40 44 private LaggedVariableTreeNode(bool deserializing) : base(deserializing) { } … … 43 47 lag = original.lag; 44 48 } 45 private LaggedVariableTreeNode() { }46 49 47 50 public LaggedVariableTreeNode(LaggedVariable variableSymbol) : base(variableSymbol) { } 48 51 49 public override bool HasLocalParameters {50 get {51 return true;52 }53 }54 52 55 53 public override void ResetLocalParameters(IRandom random) { -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs
r7259 r8915 101 101 } 102 102 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 103 126 private const int minimumArity = 0; 104 127 private const int maximumArity = 0; … … 112 135 #endregion 113 136 137 [StorableHook(HookType.AfterDeserialization)] 138 private void AfterDeserialization() { 139 if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) { 140 allVariableNames = variableNames; 141 } 142 } 143 114 144 [StorableConstructor] 115 145 protected Variable(bool deserializing) 116 146 : base(deserializing) { 117 147 variableNames = new List<string>(); 148 allVariableNames = new List<string>(); 118 149 } 119 150 protected Variable(Variable original, Cloner cloner) … … 122 153 weightSigma = original.weightSigma; 123 154 variableNames = new List<string>(original.variableNames); 155 allVariableNames = new List<string>(original.allVariableNames); 124 156 weightManipulatorMu = original.weightManipulatorMu; 125 157 weightManipulatorSigma = original.weightManipulatorSigma; … … 135 167 multiplicativeWeightManipulatorSigma = 0.03; 136 168 variableNames = new List<string>(); 169 allVariableNames = new List<string>(); 137 170 } 138 171 -
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs
r8099 r8915 86 86 set { 87 87 if (value == null) throw new ArgumentNullException(); 88 variableNames = new List<string>(value); 88 variableNames.Clear(); 89 variableNames.AddRange(value); 89 90 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; 90 103 } 91 104 } … … 151 164 152 165 #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 153 173 [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 } 155 179 private VariableCondition(VariableCondition original, Cloner cloner) 156 180 : base(original, cloner) { … … 161 185 162 186 variableNames = new List<string>(original.variableNames); 187 allVariableNames = new List<string>(original.allVariableNames); 163 188 164 189 slopeInitializerMu = original.slopeInitializerMu; … … 181 206 182 207 variableNames = new List<string>(); 208 allVariableNames = new List<string>(); 183 209 184 210 slopeInitializerMu = 0.0;
Note: See TracChangeset
for help on using the changeset viewer.