- Timestamp:
- 04/16/13 13:13:41 (11 years ago)
- Location:
- branches/OaaS
- Files:
-
- 2 deleted
- 33 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Property svn:ignore
-
old new 1 *.user 2 Plugin.cs 1 3 bin 2 *.user3 HeuristicLabProblemsDataAnalysisSymbolicPlugin.cs4 4 obj 5 *.vs10x6 Plugin.cs
-
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveAnalyzer.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer.cs
r7259 r9363 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 29 using HeuristicLab.Optimization; 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using System;33 32 34 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 42 41 private const string TrainingBestSolutionsParameterName = "Best training solutions"; 43 42 private const string TrainingBestSolutionQualitiesParameterName = "Best training solution qualities"; 43 private const string UpdateAlwaysParameterName = "Always update best solutions"; 44 44 45 45 #region parameter properties … … 49 49 public ILookupParameter<ItemList<DoubleArray>> TrainingBestSolutionQualitiesParameter { 50 50 get { return (ILookupParameter<ItemList<DoubleArray>>)Parameters[TrainingBestSolutionQualitiesParameterName]; } 51 } 52 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 53 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 51 54 } 52 55 #endregion … … 60 63 set { TrainingBestSolutionQualitiesParameter.ActualValue = value; } 61 64 } 65 public BoolValue UpdateAlways { 66 get { return UpdateAlwaysParameter.Value; } 67 } 62 68 #endregion 63 69 … … 69 75 Parameters.Add(new LookupParameter<ItemList<T>>(TrainingBestSolutionsParameterName, "The training best (Pareto-optimal) symbolic data analysis solutions.")); 70 76 Parameters.Add(new LookupParameter<ItemList<DoubleArray>>(TrainingBestSolutionQualitiesParameterName, "The qualities of the training best (Pareto-optimal) solutions.")); 77 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solutions should always be updated regardless of its quality.", new BoolValue(false))); 78 UpdateAlwaysParameter.Hidden = true; 79 } 80 81 [StorableHook(HookType.AfterDeserialization)] 82 private void AfterDeserialization() { 83 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 84 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solutions should always be updated regardless of its quality.", new BoolValue(false))); 85 UpdateAlwaysParameter.Hidden = true; 86 } 71 87 } 72 88 … … 81 97 } 82 98 83 IList<double[]> trainingBestQualities = TrainingBestSolutionQualities 84 .Select(x => x.ToArray()) 85 .ToList(); 99 //if the pareto front of best solutions shall be updated regardless of the quality, the list initialized empty to discard old solutions 100 IList<double[]> trainingBestQualities; 101 if (UpdateAlways.Value) { 102 trainingBestQualities = new List<double[]>(); 103 } else { 104 trainingBestQualities = TrainingBestSolutionQualities.Select(x => x.ToArray()).ToList(); 105 } 86 106 87 107 #region find best trees … … 131 151 public bool Equals(double[] x, double[] y) { 132 152 if (y.Length != x.Length) throw new ArgumentException(); 133 for (int i = 0; i < x.Length; i++) {153 for (int i = 0; i < x.Length; i++) { 134 154 if (!x[i].IsAlmost(y[i])) return false; 135 155 } -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r7259 r9363 44 44 private const string ValidationBestSolutionsParameterName = "Best validation solutions"; 45 45 private const string ValidationBestSolutionQualitiesParameterName = "Best validation solution qualities"; 46 private const string UpdateAlwaysParameterName = "Always update best solutions"; 46 47 47 48 #region parameter properties … … 51 52 public ILookupParameter<ItemList<DoubleArray>> ValidationBestSolutionQualitiesParameter { 52 53 get { return (ILookupParameter<ItemList<DoubleArray>>)Parameters[ValidationBestSolutionQualitiesParameterName]; } 54 } 55 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 56 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 53 57 } 54 58 #endregion … … 62 66 set { ValidationBestSolutionQualitiesParameter.ActualValue = value; } 63 67 } 68 public BoolValue UpdateAlways { 69 get { return UpdateAlwaysParameter.Value; } 70 } 64 71 #endregion 65 72 … … 71 78 Parameters.Add(new LookupParameter<ItemList<S>>(ValidationBestSolutionsParameterName, "The validation best (Pareto-optimal) symbolic data analysis solutions.")); 72 79 Parameters.Add(new LookupParameter<ItemList<DoubleArray>>(ValidationBestSolutionQualitiesParameterName, "The qualities of the validation best (Pareto-optimal) solutions.")); 80 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best validation solutions should always be updated regardless of its quality.", new BoolValue(false))); 81 UpdateAlwaysParameter.Hidden = true; 82 } 83 84 [StorableHook(HookType.AfterDeserialization)] 85 private void AfterDeserialization() { 86 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 87 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solutions should always be updated regardless of its quality.", new BoolValue(false))); 88 UpdateAlwaysParameter.Hidden = true; 89 } 73 90 } 74 91 … … 86 103 } 87 104 88 IList<double[]> trainingBestQualities = ValidationBestSolutionQualities 89 .Select(x => x.ToArray()) 90 .ToList(); 105 //if the pareto front of best solutions shall be updated regardless of the quality, the list initialized empty to discard old solutions 106 IList<double[]> trainingBestQualities; 107 if (UpdateAlways.Value) { 108 trainingBestQualities = new List<double[]>(); 109 } else { 110 trainingBestQualities = ValidationBestSolutionQualities.Select(x => x.ToArray()).ToList(); 111 } 91 112 92 113 #region find best trees -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveAnalyzer.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs
r7259 r9363 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Linq; 24 23 using HeuristicLab.Common; … … 26 25 using HeuristicLab.Data; 27 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 27 using HeuristicLab.Optimization; 30 28 using HeuristicLab.Parameters; … … 41 39 private const string TrainingBestSolutionParameterName = "Best training solution"; 42 40 private const string TrainingBestSolutionQualityParameterName = "Best training solution quality"; 41 private const string UpdateAlwaysParameterName = "Always update best solution"; 43 42 44 43 #region parameter properties … … 48 47 public ILookupParameter<DoubleValue> TrainingBestSolutionQualityParameter { 49 48 get { return (ILookupParameter<DoubleValue>)Parameters[TrainingBestSolutionQualityParameterName]; } 49 } 50 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 51 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 50 52 } 51 53 #endregion … … 59 61 set { TrainingBestSolutionQualityParameter.ActualValue = value; } 60 62 } 63 public BoolValue UpdateAlways { 64 get { return UpdateAlwaysParameter.Value; } 65 } 61 66 #endregion 62 67 … … 68 73 Parameters.Add(new LookupParameter<T>(TrainingBestSolutionParameterName, "The training best symbolic data analyis solution.")); 69 74 Parameters.Add(new LookupParameter<DoubleValue>(TrainingBestSolutionQualityParameterName, "The quality of the training best symbolic data analysis solution.")); 75 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false))); 76 UpdateAlwaysParameter.Hidden = true; 77 } 78 79 [StorableHook(HookType.AfterDeserialization)] 80 private void AfterDeserialization() { 81 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 82 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false))); 83 UpdateAlwaysParameter.Hidden = true; 84 } 70 85 } 71 86 … … 85 100 86 101 var results = ResultCollection; 87 if ( TrainingBestSolutionQuality == null ||88 IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value)) {102 if (bestTree != null && (UpdateAlways.Value || TrainingBestSolutionQuality == null || 103 IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value))) { 89 104 TrainingBestSolution = CreateSolution(bestTree, bestQuality); 90 105 TrainingBestSolutionQuality = new DoubleValue(bestQuality); -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r7721 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r7721 r9363 43 43 private const string ValidationBestSolutionParameterName = "Best validation solution"; 44 44 private const string ValidationBestSolutionQualityParameterName = "Best validation solution quality"; 45 private const string UpdateAlwaysParameterName = "Always update best solution"; 45 46 46 47 #region parameter properties … … 50 51 public ILookupParameter<DoubleValue> ValidationBestSolutionQualityParameter { 51 52 get { return (ILookupParameter<DoubleValue>)Parameters[ValidationBestSolutionQualityParameterName]; } 53 } 54 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 55 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 52 56 } 53 57 #endregion … … 61 65 set { ValidationBestSolutionQualityParameter.ActualValue = value; } 62 66 } 67 public BoolValue UpdateAlways { 68 get { return UpdateAlwaysParameter.Value; } 69 } 63 70 #endregion 64 71 … … 70 77 Parameters.Add(new LookupParameter<S>(ValidationBestSolutionParameterName, "The validation best symbolic data analyis solution.")); 71 78 Parameters.Add(new LookupParameter<DoubleValue>(ValidationBestSolutionQualityParameterName, "The quality of the validation best symbolic data analysis solution.")); 79 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best validation solution should always be updated regardless of its quality.", new BoolValue(false))); 80 UpdateAlwaysParameter.Hidden = true; 81 } 82 83 [StorableHook(HookType.AfterDeserialization)] 84 private void AfterDeserialization() { 85 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 86 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false))); 87 UpdateAlwaysParameter.Hidden = true; 88 } 72 89 } 73 90 … … 117 134 118 135 var results = ResultCollection; 119 if ( ValidationBestSolutionQuality == null ||136 if (UpdateAlways.Value || ValidationBestSolutionQuality == null || 120 137 IsBetter(bestValidationQuality, ValidationBestSolutionQuality.Value, Maximization.Value)) { 121 138 ValidationBestSolution = CreateSolution(bestTree, bestValidationQuality); -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Evaluators/SymbolicDataAnalysisEvaluator.cs
r7259 r9363 28 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 29 using HeuristicLab.Operators; 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 35 36 [StorableClass] 36 37 public abstract class SymbolicDataAnalysisEvaluator<T> : SingleSuccessorOperator, 37 ISymbolicDataAnalysisEvaluator<T>, ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator 38 ISymbolicDataAnalysisEvaluator<T>, ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator, IStochasticOperator 38 39 where T : class, IDataAnalysisProblemData { 39 40 private const string RandomParameterName = "Random"; … … 44 45 private const string EvaluationPartitionParameterName = "EvaluationPartition"; 45 46 private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples"; 47 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 48 private const string ValidRowIndicatorParameterName = "ValidRowIndicator"; 46 49 47 50 public override bool CanChangeName { get { return false; } } 48 51 49 52 #region parameter properties 53 ILookupParameter<IRandom> IStochasticOperator.RandomParameter { 54 get { return RandomParameter; } 55 } 56 50 57 public IValueLookupParameter<IRandom> RandomParameter { 51 58 get { return (IValueLookupParameter<IRandom>)Parameters[RandomParameterName]; } … … 70 77 get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; } 71 78 } 79 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 80 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 81 } 82 public IValueLookupParameter<StringValue> ValidRowIndicatorParameter { 83 get { return (IValueLookupParameter<StringValue>)Parameters[ValidRowIndicatorParameterName]; } 84 } 72 85 #endregion 73 86 … … 87 100 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 101 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.")); 102 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.")); 103 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).")); 104 } 105 106 [StorableHook(HookType.AfterDeserialization)] 107 private void AfterDeserialization() { 108 if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && !(Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>)) 109 Parameters.Remove(ApplyLinearScalingParameterName); 110 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) 111 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.")); 112 if (!Parameters.ContainsKey(ValidRowIndicatorParameterName)) 113 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 114 } 90 115 … … 94 119 95 120 protected IEnumerable<int> GenerateRowsToEvaluate(double percentageOfRows) { 96 97 98 121 IEnumerable<int> rows; 99 122 int samplesStart = EvaluationPartitionParameter.ActualValue.Start; … … 101 124 int testPartitionStart = ProblemDataParameter.ActualValue.TestPartition.Start; 102 125 int testPartitionEnd = ProblemDataParameter.ActualValue.TestPartition.End; 103 104 126 if (samplesEnd < samplesStart) throw new ArgumentException("Start value is larger than end value."); 105 127 … … 113 135 } 114 136 115 return rows.Where(i => i < testPartitionStart || testPartitionEnd <= i); 137 rows = rows.Where(i => i < testPartitionStart || testPartitionEnd <= i); 138 if (ValidRowIndicatorParameter.ActualValue != null) { 139 string indicatorVar = ValidRowIndicatorParameter.ActualValue.Value; 140 var problemData = ProblemDataParameter.ActualValue; 141 var indicatorRow = problemData.Dataset.GetReadOnlyDoubleValues(indicatorVar); 142 rows = rows.Where(r => !indicatorRow[r].IsAlmost(0.0)); 143 } 144 return rows; 145 } 146 147 [ThreadStatic] 148 private static double[] cache; 149 protected static void CalculateWithScaling(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, 150 double lowerEstimationLimit, double upperEstimationLimit, 151 IOnlineCalculator calculator, int maxRows) { 152 if (cache == null || cache.Length < maxRows) { 153 cache = new double[maxRows]; 154 } 155 156 // calculate linear scaling 157 int i = 0; 158 var linearScalingCalculator = new OnlineLinearScalingParameterCalculator(); 159 var targetValuesEnumerator = targetValues.GetEnumerator(); 160 var estimatedValuesEnumerator = estimatedValues.GetEnumerator(); 161 while (targetValuesEnumerator.MoveNext() & estimatedValuesEnumerator.MoveNext()) { 162 double target = targetValuesEnumerator.Current; 163 double estimated = estimatedValuesEnumerator.Current; 164 cache[i] = estimated; 165 if (!double.IsNaN(estimated) && !double.IsInfinity(estimated)) 166 linearScalingCalculator.Add(estimated, target); 167 i++; 168 } 169 if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None && (targetValuesEnumerator.MoveNext() || estimatedValuesEnumerator.MoveNext())) 170 throw new ArgumentException("Number of elements in target and estimated values enumeration do not match."); 171 172 double alpha = linearScalingCalculator.Alpha; 173 double beta = linearScalingCalculator.Beta; 174 if (linearScalingCalculator.ErrorState != OnlineCalculatorError.None) { 175 alpha = 0.0; 176 beta = 1.0; 177 } 178 179 //calculate the quality by using the passed online calculator 180 targetValuesEnumerator = targetValues.GetEnumerator(); 181 var scaledBoundedEstimatedValuesEnumerator = Enumerable.Range(0, i).Select(x => cache[x] * beta + alpha) 182 .LimitToRange(lowerEstimationLimit, upperEstimationLimit).GetEnumerator(); 183 184 while (targetValuesEnumerator.MoveNext() & scaledBoundedEstimatedValuesEnumerator.MoveNext()) { 185 calculator.Add(targetValuesEnumerator.Current, scaledBoundedEstimatedValuesEnumerator.Current); 186 } 116 187 } 117 188 } -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7708 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r7707 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r7696 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r8168 r9363 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="ALGLIB-3. 5.0, Version=3.5.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">96 <HintPath>..\..\bin\ALGLIB-3. 5.0.dll</HintPath>95 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 96 <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath> 97 97 <Private>False</Private> 98 98 </Reference> … … 140 140 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" /> 141 141 <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" /> 142 <Compile Include="Interfaces\ISymbolicDataAnalysisImpactValuesCalculator.cs" /> 143 <Compile Include="Interpreter\InterpreterState.cs" /> 144 <Compile Include="Interpreter\OpCodes.cs" /> 145 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs" /> 146 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeInterpreter.cs" /> 142 147 <Compile Include="Plugin.cs" /> 143 <Compile Include="SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs" />144 148 <Compile Include="Formatters\SymbolicDataAnalysisExpressionLatexFormatter.cs" /> 145 149 <Compile Include="Formatters\SymbolicDataAnalysisExpressionMATLABFormatter.cs" /> … … 159 163 <Compile Include="Interfaces\ISymbolicDataAnalysisAnalyzer.cs" /> 160 164 <Compile Include="SymbolicDataAnalysisSingleObjectiveProblem.cs" /> 161 <Compile Include="SymbolicDataAnalysisExpressionTreeInterpreter.cs" />162 165 <Compile Include="SymbolicDataAnalysisExpressionTreeSimplifier.cs" /> 163 166 <Compile Include="SymbolicDataAnalysisProblem.cs" /> 167 <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" /> 164 168 <Compile Include="Symbols\Addition.cs" /> 165 169 <Compile Include="Symbols\And.cs" /> 170 <Compile Include="Symbols\AutoregressiveVariable.cs" /> 166 171 <Compile Include="Symbols\Average.cs" /> 167 172 <Compile Include="Symbols\Constant.cs" /> … … 334 339 --> 335 340 <PropertyGroup> 336 <PreBuildEvent >set Path=%25Path%25;$(ProjectDir);$(SolutionDir)341 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 337 342 set ProjectDir=$(ProjectDir) 338 343 set SolutionDir=$(SolutionDir) … … 341 346 call PreBuildEvent.cmd 342 347 </PreBuildEvent> 348 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 349 export ProjectDir=$(ProjectDir) 350 export SolutionDir=$(SolutionDir) 351 352 $SolutionDir/PreBuildEvent.sh 353 </PreBuildEvent> 343 354 </PropertyGroup> 344 355 </Project> -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisEvaluator.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisMultiObjectiveAnalyzer.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisProblem.cs
r7259 r9363 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Data; 24 using HeuristicLab.Optimization; 24 25 25 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 26 public interface ISymbolicDataAnalysisProblem : IDataAnalysisProblem {27 public interface ISymbolicDataAnalysisProblem : IDataAnalysisProblem, IHeuristicOptimizationProblem { 27 28 IValueParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter { get; } 28 29 IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { get; } … … 45 46 IntRange ValidationPartition { get; } 46 47 } 48 49 public interface ISymbolicDataAnalysisSingleObjectiveProblem : ISymbolicDataAnalysisProblem, ISingleObjectiveHeuristicOptimizationProblem { } 50 public interface ISymbolicDataAnalysisMultiObjectiveProblem : ISymbolicDataAnalysisProblem, IMultiObjectiveHeuristicOptimizationProblem { } 47 51 } -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisSingleObjectiveAnalyzer.cs
r7259 r9363 28 28 IScopeTreeLookupParameter<DoubleValue> QualityParameter { get; } 29 29 ILookupParameter<BoolValue> MaximizationParameter { get; } 30 ILookupParameter<BoolValue> ApplyLinearScalingParameter { get; } 30 31 } 31 32 } -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r7834 r9363 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic","Provides base classes for symbolic data analysis tasks.", "3.4. 2.$WCREV$")]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.7.0")] 31 31 [PluginDependency("HeuristicLab.Analysis", "3.3")] 32 32 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Properties
- Property svn:ignore
--- +++
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Properties/AssemblyInfo.cs.frame
r7259 r9363 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4. 2.$WCREV$")]55 [assembly: AssemblyFileVersion("3.4.3.$WCREV$")] -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r7696 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs
r7259 r9363 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 protected void Scale(IDataAnalysisProblemData problemData, string targetVariable) { 72 var dataset = problemData.Dataset; 73 var rows = problemData.TrainingIndices; 74 var estimatedValues = Interpreter.GetSymbolicExpressionTreeValues(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 = 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisMultiObjectiveProblem.cs
r7259 r9363 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 31 31 [StorableClass] 32 public abstract class SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, I MultiObjectiveHeuristicOptimizationProblem32 public abstract class SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, ISymbolicDataAnalysisMultiObjectiveProblem 33 33 where T : class,IDataAnalysisProblemData 34 34 where U : class, ISymbolicDataAnalysisMultiObjectiveEvaluator<T> -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r8203 r9363 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) { 214 varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value); 215 varSymbol.VariableNames = ProblemData.AllowedInputVariables; 216 } 194 217 } 195 218 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) { 196 if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables; 219 if (!varSymbol.Fixed) { 220 varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value); 221 varSymbol.VariableNames = ProblemData.AllowedInputVariables; 222 } 197 223 } 198 224 } … … 274 300 275 301 foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) { 276 op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter Name;302 op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name; 277 303 } 278 304 foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) { 279 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter Name;280 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter Name;305 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name; 306 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name; 281 307 } 282 308 foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) { 283 op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter Name;284 op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter Name;309 op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name; 310 op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name; 285 311 } 286 312 foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) { … … 289 315 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; 290 316 op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name; 317 op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name; 291 318 } 292 319 foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) { … … 300 327 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 301 328 } 329 foreach (var op in operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>()) { 330 op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name; 331 } 332 foreach (var op in operators.OfType<ISymbolicDataAnalysisMultiObjectiveAnalyzer>()) { 333 op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name; 334 } 302 335 foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) { 303 336 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; … … 308 341 } 309 342 foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>()) { 310 op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter Name;343 op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name; 311 344 } 312 345 foreach (var op in operators.OfType<ISymbolicDataAnalysisExpressionCrossover<T>>()) { 313 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter Name;346 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; 314 347 op.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 315 348 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; … … 324 357 Description = data.Description; 325 358 ProblemData = data; 326 OnReset();327 359 } 328 360 -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSingleObjectiveProblem.cs
r7259 r9363 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 32 32 [StorableClass] 33 public abstract class SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, IS ingleObjectiveHeuristicOptimizationProblem33 public abstract class SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, ISymbolicDataAnalysisSingleObjectiveProblem 34 34 where T : class,IDataAnalysisProblemData 35 35 where U : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<T> -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedSymbol.cs
r5809 r9363 1 using HeuristicLab.Common; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using HeuristicLab.Common; 2 23 using HeuristicLab.Core; 3 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedVariable.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LaggedVariableTreeNode.cs
r7259 r9363 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/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs
r7259 r9363 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 } 112 } 113 114 public override bool Enabled { 115 get { 116 if (variableNames.Count == 0) return false; 117 return base.Enabled; 118 } 119 set { 120 if (variableNames.Count == 0) base.Enabled = false; 121 else base.Enabled = value; 122 } 123 } 124 103 125 private const int minimumArity = 0; 104 126 private const int maximumArity = 0; … … 112 134 #endregion 113 135 136 [StorableHook(HookType.AfterDeserialization)] 137 private void AfterDeserialization() { 138 if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) { 139 allVariableNames = variableNames; 140 } 141 } 142 114 143 [StorableConstructor] 115 144 protected Variable(bool deserializing) 116 145 : base(deserializing) { 117 146 variableNames = new List<string>(); 147 allVariableNames = new List<string>(); 118 148 } 119 149 protected Variable(Variable original, Cloner cloner) … … 122 152 weightSigma = original.weightSigma; 123 153 variableNames = new List<string>(original.variableNames); 154 allVariableNames = new List<string>(original.allVariableNames); 124 155 weightManipulatorMu = original.weightManipulatorMu; 125 156 weightManipulatorSigma = original.weightManipulatorSigma; … … 135 166 multiplicativeWeightManipulatorSigma = 0.03; 136 167 variableNames = new List<string>(); 137 } 138 139 protected override void OnChanged(EventArgs e) { 140 if (@Fixed) { 141 weightManipulatorMu = 1; 142 weightManipulatorSigma = 0; 143 weightMu = 1; 144 weightSigma = 0; 145 multiplicativeWeightManipulatorSigma = 0; 146 } 147 base.OnChanged(e); 168 allVariableNames = new List<string>(); 148 169 } 149 170 -
branches/OaaS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs
r8099 r9363 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.