- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 1 deleted
- 23 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer.cs
r12012 r14029 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 42 41 private const string TrainingBestSolutionQualitiesParameterName = "Best training solution qualities"; 43 42 private const string UpdateAlwaysParameterName = "Always update best solutions"; 43 private const string TrainingBestSolutionParameterName = "Best training solution"; 44 44 45 45 #region parameter properties … … 55 55 #endregion 56 56 #region properties 57 p ublicItemList<T> TrainingBestSolutions {57 private ItemList<T> TrainingBestSolutions { 58 58 get { return TrainingBestSolutionsParameter.ActualValue; } 59 59 set { TrainingBestSolutionsParameter.ActualValue = value; } 60 60 } 61 p ublicItemList<DoubleArray> TrainingBestSolutionQualities {61 private ItemList<DoubleArray> TrainingBestSolutionQualities { 62 62 get { return TrainingBestSolutionQualitiesParameter.ActualValue; } 63 63 set { TrainingBestSolutionQualitiesParameter.ActualValue = value; } 64 64 } 65 public BoolValue UpdateAlways { 66 get { return UpdateAlwaysParameter.Value; } 65 public bool UpdateAlways { 66 get { return UpdateAlwaysParameter.Value.Value; } 67 set { UpdateAlwaysParameter.Value.Value = value; } 67 68 } 68 69 #endregion … … 97 98 } 98 99 100 if (!results.ContainsKey(TrainingBestSolutionParameterName)) { 101 results.Add(new Result(TrainingBestSolutionParameterName, "", typeof(ISymbolicDataAnalysisSolution))); 102 } 103 99 104 //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) {105 List<double[]> trainingBestQualities; 106 if (UpdateAlways) { 102 107 trainingBestQualities = new List<double[]>(); 103 108 } else { … … 105 110 } 106 111 107 #region find best trees 108 IList<int> nonDominatedIndexes = new List<int>(); 109 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 112 ISymbolicExpressionTree[] trees = SymbolicExpressionTree.ToArray(); 110 113 List<double[]> qualities = Qualities.Select(x => x.ToArray()).ToList(); 111 114 bool[] maximization = Maximization.ToArray(); 112 List<double[]> newNonDominatedQualities = new List<double[]>(); 113 for (int i = 0; i < tree.Length; i++) { 114 if (IsNonDominated(qualities[i], trainingBestQualities, maximization) && 115 IsNonDominated(qualities[i], qualities, maximization)) { 116 if (!newNonDominatedQualities.Contains(qualities[i], new DoubleArrayComparer())) { 117 newNonDominatedQualities.Add(qualities[i]); 118 nonDominatedIndexes.Add(i); 115 116 var nonDominatedIndividuals = new[] { new { Tree = default(ISymbolicExpressionTree), Qualities = default(double[]) } }.ToList(); 117 nonDominatedIndividuals.Clear(); 118 119 // build list of new non-dominated solutions 120 for (int i = 0; i < trees.Length; i++) { 121 if (IsNonDominated(qualities[i], nonDominatedIndividuals.Select(ind => ind.Qualities), maximization) && 122 IsNonDominated(qualities[i], trainingBestQualities, maximization)) { 123 for (int j = nonDominatedIndividuals.Count - 1; j >= 0; j--) { 124 if (IsBetterOrEqual(qualities[i], nonDominatedIndividuals[j].Qualities, maximization)) { 125 nonDominatedIndividuals.RemoveAt(j); 126 } 119 127 } 128 nonDominatedIndividuals.Add(new { Tree = trees[i], Qualities = qualities[i] }); 120 129 } 121 130 } 122 #endregion 131 132 var nonDominatedSolutions = nonDominatedIndividuals.Select(x => new { Solution = CreateSolution(x.Tree, x.Qualities), Qualities = x.Qualities }).ToList(); 133 nonDominatedSolutions.ForEach(s => s.Solution.Name = string.Join(",", s.Qualities.Select(q => q.ToString()))); 134 123 135 #region update Pareto-optimal solution archive 124 if (nonDominatedIndexes.Count > 0) { 125 ItemList<DoubleArray> nonDominatedQualities = new ItemList<DoubleArray>(); 126 ItemList<T> nonDominatedSolutions = new ItemList<T>(); 127 // add all new non-dominated solutions to the archive 128 foreach (var index in nonDominatedIndexes) { 129 T solution = CreateSolution(tree[index], qualities[index]); 130 nonDominatedSolutions.Add(solution); 131 nonDominatedQualities.Add(new DoubleArray(qualities[index])); 132 } 133 // add old non-dominated solutions only if they are not dominated by one of the new solutions 136 if (nonDominatedSolutions.Count > 0) { 137 //add old non-dominated solutions only if they are not dominated by one of the new solutions 134 138 for (int i = 0; i < trainingBestQualities.Count; i++) { 135 if (IsNonDominated(trainingBestQualities[i], newNonDominatedQualities, maximization)) { 136 if (!newNonDominatedQualities.Contains(trainingBestQualities[i], new DoubleArrayComparer())) { 137 nonDominatedSolutions.Add(TrainingBestSolutions[i]); 138 nonDominatedQualities.Add(TrainingBestSolutionQualities[i]); 139 } 139 if (IsNonDominated(trainingBestQualities[i], nonDominatedSolutions.Select(x => x.Qualities), maximization)) { 140 nonDominatedSolutions.Add(new { Solution = TrainingBestSolutions[i], Qualities = TrainingBestSolutionQualities[i].ToArray() }); 140 141 } 141 142 } 142 143 143 results[TrainingBestSolutionsParameter.Name].Value = nonDominatedSolutions; 144 results[TrainingBestSolutionQualitiesParameter.Name].Value = nonDominatedQualities; 144 //assumes the the first objective is always the accuracy 145 var sortedNonDominatedSolutions = maximization[0] 146 ? nonDominatedSolutions.OrderByDescending(x => x.Qualities[0]) 147 : nonDominatedSolutions.OrderBy(x => x.Qualities[0]); 148 var trainingBestSolution = sortedNonDominatedSolutions.Select(s => s.Solution).First(); 149 results[TrainingBestSolutionParameterName].Value = trainingBestSolution; 150 TrainingBestSolutions = new ItemList<T>(sortedNonDominatedSolutions.Select(x => x.Solution)); 151 results[TrainingBestSolutionsParameter.Name].Value = TrainingBestSolutions; 152 TrainingBestSolutionQualities = new ItemList<DoubleArray>(sortedNonDominatedSolutions.Select(x => new DoubleArray(x.Qualities))); 153 results[TrainingBestSolutionQualitiesParameter.Name].Value = TrainingBestSolutionQualities; 145 154 } 146 155 #endregion … … 148 157 } 149 158 150 private class DoubleArrayComparer : IEqualityComparer<double[]> {151 public bool Equals(double[] x, double[] y) {152 if (y.Length != x.Length) throw new ArgumentException();153 for (int i = 0; i < x.Length; i++) {154 if (!x[i].IsAlmost(y[i])) return false;155 }156 return true;157 }158 159 public int GetHashCode(double[] obj) {160 int c = obj.Length;161 for (int i = 0; i < obj.Length; i++)162 c ^= obj[i].GetHashCode();163 return c;164 }165 }166 167 159 protected abstract T CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality); 168 160 169 private bool IsNonDominated(double[] point, I List<double[]> points, bool[] maximization) {161 private bool IsNonDominated(double[] point, IEnumerable<double[]> points, bool[] maximization) { 170 162 foreach (var refPoint in points) { 171 bool refPointDominatesPoint = true; 172 for (int i = 0; i < point.Length; i++) { 173 refPointDominatesPoint &= IsBetterOrEqual(refPoint[i], point[i], maximization[i]); 174 } 163 bool refPointDominatesPoint = IsBetterOrEqual(refPoint, point, maximization); 175 164 if (refPointDominatesPoint) return false; 176 165 } 177 166 return true; 178 167 } 168 169 private bool IsBetterOrEqual(double[] lhs, double[] rhs, bool[] maximization) { 170 for (int i = 0; i < lhs.Length; i++) { 171 var result = IsBetterOrEqual(lhs[i], rhs[i], maximization[i]); 172 if (!result) return false; 173 } 174 return true; 175 } 176 179 177 private bool IsBetterOrEqual(double lhs, double rhs, bool maximization) { 180 if (maximization) return lhs > rhs;181 else return lhs < rhs;178 if (maximization) return lhs >= rhs; 179 else return lhs <= rhs; 182 180 } 183 181 } -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Creators/MultiSymbolicDataAnalysisExpressionCreator.cs
r12108 r14029 35 35 36 36 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Creators { 37 [StorableClass] 37 38 public class MultiSymbolicDataAnalysisExpressionCreator : StochasticMultiBranch<ISymbolicDataAnalysisSolutionCreator>, 38 39 ISymbolicDataAnalysisSolutionCreator, -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs
r12422 r14029 34 34 "- Randomly choose a node N from P1\n" + 35 35 "- Test all crossover points from P0 to determine the best location for N to be inserted")] 36 [StorableClass] 36 37 public sealed class SymbolicDataAnalysisExpressionContextAwareCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { 37 38 [StorableConstructor] -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionCrossover.cs
r12012 r14029 32 32 33 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 34 [StorableClass] 34 35 public abstract class SymbolicDataAnalysisExpressionCrossover<T> : SymbolicExpressionTreeCrossover, ISymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { 35 36 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter"; -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs
r12422 r14029 36 36 "- Standard (mid 50% of the tree)\n" + 37 37 "- LowLevel (lower 25% of the tree)")] 38 [StorableClass] 38 39 public sealed class SymbolicDataAnalysisExpressionDepthConstrainedCrossover<T> : 39 40 SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDeterministicBestCrossover.cs
r12422 r14029 34 34 "- Randomly choose a crossover point C from P0\n" + 35 35 "- Test all nodes from P1 to determine the one that produces the best child when inserted at place C in P0")] 36 [StorableClass] 36 37 public sealed class SymbolicDataAnalysisExpressionDeterministicBestCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { 37 38 [StorableConstructor] -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs
r12422 r14029 36 36 "\t\tD(N,M) = 0.5 * ( abs(max(N) - max(M)) + abs(min(N) - min(M)) )\n" + 37 37 "- Make a probabilistic weighted choice of node M from P1, based on the inversed and normalized behavioral distance")] 38 [StorableClass] 38 39 public sealed class SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { 39 40 [StorableConstructor] -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs
r12422 r14029 37 37 "- Find the first node M that satisfies the semantic similarity criteria\n" + 38 38 "- Swap N for M and return P0")] 39 [StorableClass] 39 40 public sealed class SymbolicDataAnalysisExpressionSemanticSimilarityCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { 40 41 private const string SemanticSimilarityRangeParameterName = "SemanticSimilarityRange"; -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Evaluators/SymbolicDataAnalysisEvaluator.cs
r12012 r14029 93 93 public SymbolicDataAnalysisEvaluator() 94 94 : base() { 95 Parameters.Add(new ValueLookupParameter<IRandom>(RandomParameterName, "The random generator to use.") );96 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic data analysis tree.") );97 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic data analysis solution encoded as a symbolic expression tree.") );98 Parameters.Add(new ValueLookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.") );99 Parameters.Add(new ValueLookupParameter<IntRange>(EvaluationPartitionParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated.") );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.") );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).") );95 Parameters.Add(new ValueLookupParameter<IRandom>(RandomParameterName, "The random generator to use.") { Hidden = true }); 96 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic data analysis tree.") { Hidden = true }); 97 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic data analysis solution encoded as a symbolic expression tree.") { Hidden = true }); 98 Parameters.Add(new ValueLookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.") { Hidden = true }); 99 Parameters.Add(new ValueLookupParameter<IntRange>(EvaluationPartitionParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated.") { Hidden = true }); 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.") { Hidden = true }); 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.") { Hidden = true }); 102 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating.") { Hidden = true }); 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).") { Hidden = true }); 104 104 } 105 105 -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Evaluators/SymbolicDataAnalysisMultiObjectiveEvaluator.cs
r12012 r14029 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 27 using HeuristicLab.Parameters; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 31 [StorableClass] 31 32 public abstract class SymbolicDataAnalysisMultiObjectiveEvaluator<T> : SymbolicDataAnalysisEvaluator<T>, ISymbolicDataAnalysisMultiObjectiveEvaluator<T> 32 33 where T : class, IDataAnalysisProblemData { -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r12645 r14029 56 56 57 57 private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 58 // TODO: adapt to interpreter semantics. The HL interpreter also allows Boolean operations on reals 58 59 if (node.Subtrees.Any()) { 59 60 if (node.Symbol is Addition) { … … 83 84 } else if (node.Symbol is Or) { 84 85 FormatOperator(node, "||", strBuilder); 86 } else if (node.Symbol is Xor) { 87 FormatOperator(node, "^", strBuilder); 85 88 } else if (node.Symbol is Sine) { 86 89 FormatFunction(node, "Math.Sin", strBuilder); 87 90 } else if (node.Symbol is Subtraction) { 88 Format Operator(node, "-", strBuilder);91 FormatSubtraction(node, strBuilder); 89 92 } else if (node.Symbol is Tangent) { 90 93 FormatFunction(node, "Math.Tan", strBuilder); … … 142 145 } 143 146 147 private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 148 if (node.SubtreeCount == 1) { 149 strBuilder.Append("-"); 150 FormatRecursively(node.GetSubtree(0), strBuilder); 151 return; 152 } 153 //Default case: more than 1 child 154 FormatOperator(node, "-", strBuilder); 155 } 156 144 157 private void FormatOperator(ISymbolicExpressionTreeNode node, string symbol, StringBuilder strBuilder) { 145 158 strBuilder.Append("("); … … 176 189 } 177 190 178 var orderedNames = varNames.OrderBy(n => n, new NaturalStringComparer()).Select(n => "double " + n);191 var orderedNames = varNames.OrderBy(n => n, new NaturalStringComparer()).Select(n => "double " + n); 179 192 strBuilder.Append(string.Join(", ", orderedNames)); 180 193 -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r12012 r14029 403 403 var constStr = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{0:G5}", constant); 404 404 if (!constStr.Contains(".")) constStr = constStr + ".0"; 405 constStr = constStr.Replace(".", " \\negthickspace&."); // fix problem in rendering of aligned expressions405 constStr = constStr.Replace(".", "&."); // fix problem in rendering of aligned expressions 406 406 strBuilder.Append("c_{" + i + "}& = & " + constStr); 407 407 strBuilder.Append(@"\\"); -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r12434 r14029 133 133 <SubType>Code</SubType> 134 134 </Compile> 135 <Compile Include="Formatters\InfixExpressionFormatter.cs" /> 136 <Compile Include="Formatters\SymbolicDataAnalysisExpressionMathematicaFormatter.cs" /> 135 137 <Compile Include="Formatters\SymbolicDataAnalysisExpressionCSharpFormatter.cs" /> 138 <Compile Include="Importer\InfixExpressionParser.cs" /> 136 139 <Compile Include="Importer\SymbolicExpressionImporter.cs" /> 137 140 <Compile Include="Importer\Token.cs" /> 138 141 <Compile Include="Interfaces\IModelBacktransformator.cs" /> 142 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs" /> 143 <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" /> 144 <Compile Include="SymbolicDataAnalysisModelComplexityCalculator.cs" /> 139 145 <Compile Include="SymbolicExpressionTreeBacktransformator.cs" /> 140 146 <Compile Include="SymbolicDataAnalysisExpressionPruningOperator.cs" /> -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisExpressionTreeInterpreter.cs
r12509 r14029 22 22 using System.Collections.Generic; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 25 … … 28 27 public interface ISymbolicDataAnalysisExpressionTreeInterpreter : INamedItem, IStatefulItem { 29 28 IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows); 30 IntValueEvaluatedSolutions { get; set; }29 int EvaluatedSolutions { get; set; } 31 30 } 32 31 } -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r12509 r14029 69 69 70 70 private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic"; 71 private const string CheckExpressionsWithIntervalArithmeticParameterDescription = "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression."; 71 72 private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions"; 72 73 … … 80 81 81 82 #region parameter properties 82 83 public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter { 84 get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; } 85 } 86 87 public IValueParameter<IntValue> EvaluatedSolutionsParameter { 88 get { return (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; } 89 } 90 83 public IFixedValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter { 84 get { return (IFixedValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; } 85 } 86 87 public IFixedValueParameter<IntValue> EvaluatedSolutionsParameter { 88 get { return (IFixedValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; } 89 } 91 90 #endregion 92 91 93 92 #region properties 94 95 public BoolValue CheckExpressionsWithIntervalArithmetic { 96 get { return CheckExpressionsWithIntervalArithmeticParameter.Value; } 97 set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; } 98 } 99 100 public IntValue EvaluatedSolutions { 101 get { return EvaluatedSolutionsParameter.Value; } 102 set { EvaluatedSolutionsParameter.Value = value; } 103 } 104 93 public bool CheckExpressionsWithIntervalArithmetic { 94 get { return CheckExpressionsWithIntervalArithmeticParameter.Value.Value; } 95 set { CheckExpressionsWithIntervalArithmeticParameter.Value.Value = value; } 96 } 97 public int EvaluatedSolutions { 98 get { return EvaluatedSolutionsParameter.Value.Value; } 99 set { EvaluatedSolutionsParameter.Value.Value = value; } 100 } 105 101 #endregion 106 107 102 108 103 [StorableConstructor] … … 116 111 public SymbolicDataAnalysisExpressionTreeILEmittingInterpreter() 117 112 : base("SymbolicDataAnalysisExpressionTreeILEmittingInterpreter", "Interpreter for symbolic expression trees.") { 118 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 119 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 113 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, 114 "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 115 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 116 } 117 118 public SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(string name, string description) 119 : base(name, description) { 120 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, 121 "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 122 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 120 123 } 121 124 122 125 [StorableHook(HookType.AfterDeserialization)] 123 126 private void AfterDeserialization() { 124 if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName)) 125 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 127 var evaluatedSolutions = new IntValue(0); 128 var checkExpressionsWithIntervalArithmetic = new BoolValue(false); 129 if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) { 130 var evaluatedSolutionsParameter = (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; 131 evaluatedSolutions = evaluatedSolutionsParameter.Value; 132 Parameters.Remove(EvaluatedSolutionsParameterName); 133 } 134 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions)); 135 if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) { 136 var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; 137 Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName); 138 checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value; 139 } 140 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic)); 126 141 } 127 142 128 143 #region IStatefulItem 129 130 144 public void InitializeState() { 131 EvaluatedSolutions .Value= 0;145 EvaluatedSolutions = 0; 132 146 } 133 147 134 148 public void ClearState() { 135 EvaluatedSolutions.Value = 0; 136 } 137 149 } 138 150 #endregion 139 151 152 private readonly object syncRoot = new object(); 140 153 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 141 if (CheckExpressionsWithIntervalArithmetic .Value)154 if (CheckExpressionsWithIntervalArithmetic) 142 155 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); 143 156 144 EvaluatedSolutions.Value++; // increment the evaluated solutions counter 157 lock (syncRoot) { 158 EvaluatedSolutions++; // increment the evaluated solutions counter 159 } 145 160 var state = PrepareInterpreterState(tree, dataset); 146 161 -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r12509 r14029 32 32 [StorableClass] 33 33 [Item("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.")] 34 public class SymbolicDataAnalysisExpressionTreeInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter { 34 public class SymbolicDataAnalysisExpressionTreeInterpreter : ParameterizedNamedItem, 35 ISymbolicDataAnalysisExpressionTreeInterpreter { 35 36 private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic"; 37 private const string CheckExpressionsWithIntervalArithmeticParameterDescription = "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression."; 36 38 private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions"; 37 39 38 public override bool CanChangeName { get { return false; } } 39 public override bool CanChangeDescription { get { return false; } } 40 public override bool CanChangeName { 41 get { return false; } 42 } 43 44 public override bool CanChangeDescription { 45 get { return false; } 46 } 40 47 41 48 #region parameter properties 42 public I ValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {43 get { return (I ValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }44 } 45 46 public I ValueParameter<IntValue> EvaluatedSolutionsParameter {47 get { return (I ValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }49 public IFixedValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter { 50 get { return (IFixedValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; } 51 } 52 53 public IFixedValueParameter<IntValue> EvaluatedSolutionsParameter { 54 get { return (IFixedValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; } 48 55 } 49 56 #endregion 50 57 51 58 #region properties 52 public BoolValueCheckExpressionsWithIntervalArithmetic {53 get { return CheckExpressionsWithIntervalArithmeticParameter.Value ; }54 set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; }55 } 56 57 public IntValueEvaluatedSolutions {58 get { return EvaluatedSolutionsParameter.Value ; }59 set { EvaluatedSolutionsParameter.Value = value; }59 public bool CheckExpressionsWithIntervalArithmetic { 60 get { return CheckExpressionsWithIntervalArithmeticParameter.Value.Value; } 61 set { CheckExpressionsWithIntervalArithmeticParameter.Value.Value = value; } 62 } 63 64 public int EvaluatedSolutions { 65 get { return EvaluatedSolutionsParameter.Value.Value; } 66 set { EvaluatedSolutionsParameter.Value.Value = value; } 60 67 } 61 68 #endregion … … 63 70 [StorableConstructor] 64 71 protected SymbolicDataAnalysisExpressionTreeInterpreter(bool deserializing) : base(deserializing) { } 65 protected SymbolicDataAnalysisExpressionTreeInterpreter(SymbolicDataAnalysisExpressionTreeInterpreter original, Cloner cloner) : base(original, cloner) { } 72 73 protected SymbolicDataAnalysisExpressionTreeInterpreter(SymbolicDataAnalysisExpressionTreeInterpreter original, 74 Cloner cloner) 75 : base(original, cloner) { } 76 66 77 public override IDeepCloneable Clone(Cloner cloner) { 67 78 return new SymbolicDataAnalysisExpressionTreeInterpreter(this, cloner); … … 70 81 public SymbolicDataAnalysisExpressionTreeInterpreter() 71 82 : base("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.") { 72 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));73 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));83 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 84 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 74 85 } 75 86 76 87 protected SymbolicDataAnalysisExpressionTreeInterpreter(string name, string description) 77 88 : base(name, description) { 78 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));79 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));89 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 90 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 80 91 } 81 92 82 93 [StorableHook(HookType.AfterDeserialization)] 83 94 private void AfterDeserialization() { 84 if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName)) 85 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 95 var evaluatedSolutions = new IntValue(0); 96 var checkExpressionsWithIntervalArithmetic = new BoolValue(false); 97 if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) { 98 var evaluatedSolutionsParameter = (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; 99 evaluatedSolutions = evaluatedSolutionsParameter.Value; 100 Parameters.Remove(EvaluatedSolutionsParameterName); 101 } 102 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions)); 103 if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) { 104 var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; 105 Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName); 106 checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value; 107 } 108 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic)); 86 109 } 87 110 88 111 #region IStatefulItem 89 112 public void InitializeState() { 90 EvaluatedSolutions.Value = 0; 91 } 92 93 public void ClearState() { 94 } 113 EvaluatedSolutions = 0; 114 } 115 116 public void ClearState() { } 95 117 #endregion 96 118 97 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 98 if (CheckExpressionsWithIntervalArithmetic.Value) 119 private readonly object syncRoot = new object(); 120 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, 121 IEnumerable<int> rows) { 122 if (CheckExpressionsWithIntervalArithmetic) { 99 123 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); 100 101 lock (EvaluatedSolutions) { 102 EvaluatedSolutions.Value++; // increment the evaluated solutions counter 124 } 125 126 lock (syncRoot) { 127 EvaluatedSolutions++; // increment the evaluated solutions counter 103 128 } 104 129 var state = PrepareInterpreterState(tree, dataset); … … 131 156 } 132 157 133 134 158 public virtual double Evaluate(IDataset dataset, ref int row, InterpreterState state) { 135 159 Instruction currentInstr = state.NextInstruction(); … … 147 171 s -= Evaluate(dataset, ref row, state); 148 172 } 149 if (currentInstr.nArguments == 1) s = -s;173 if (currentInstr.nArguments == 1) { s = -s; } 150 174 return s; 151 175 } … … 162 186 p /= Evaluate(dataset, ref row, state); 163 187 } 164 if (currentInstr.nArguments == 1) p = 1.0 / p;188 if (currentInstr.nArguments == 1) { p = 1.0 / p; } 165 189 return p; 166 190 } … … 205 229 case OpCodes.Gamma: { 206 230 var x = Evaluate(dataset, ref row, state); 207 if (double.IsNaN(x)) return double.NaN; 208 else return alglib.gammafunction(x); 231 if (double.IsNaN(x)) { return double.NaN; } else { return alglib.gammafunction(x); } 209 232 } 210 233 case OpCodes.Psi: { … … 216 239 case OpCodes.Dawson: { 217 240 var x = Evaluate(dataset, ref row, state); 218 if (double.IsNaN(x)) return double.NaN;241 if (double.IsNaN(x)) { return double.NaN; } 219 242 return alglib.dawsonintegral(x); 220 243 } 221 244 case OpCodes.ExponentialIntegralEi: { 222 245 var x = Evaluate(dataset, ref row, state); 223 if (double.IsNaN(x)) return double.NaN;246 if (double.IsNaN(x)) { return double.NaN; } 224 247 return alglib.exponentialintegralei(x); 225 248 } … … 349 372 int positiveSignals = 0; 350 373 for (int i = 0; i < currentInstr.nArguments; i++) { 351 if (Evaluate(dataset, ref row, state) > 0.0) positiveSignals++;374 if (Evaluate(dataset, ref row, state) > 0.0) { positiveSignals++; } 352 375 } 353 376 return positiveSignals % 2 != 0 ? 1.0 : -1.0; … … 356 379 double x = Evaluate(dataset, ref row, state); 357 380 double y = Evaluate(dataset, ref row, state); 358 if (x > y) return 1.0; 359 else return -1.0; 381 if (x > y) { return 1.0; } else { return -1.0; } 360 382 } 361 383 case OpCodes.LT: { 362 384 double x = Evaluate(dataset, ref row, state); 363 385 double y = Evaluate(dataset, ref row, state); 364 if (x < y) return 1.0; 365 else return -1.0; 386 if (x < y) { return 1.0; } else { return -1.0; } 366 387 } 367 388 case OpCodes.TimeLag: { … … 437 458 var laggedVariableTreeNode = (LaggedVariableTreeNode)currentInstr.dynamicNode; 438 459 int actualRow = row + laggedVariableTreeNode.Lag; 439 if (actualRow < 0 || actualRow >= dataset.Rows) return double.NaN;460 if (actualRow < 0 || actualRow >= dataset.Rows) { return double.NaN; } 440 461 return ((IList<double>)currentInstr.data)[actualRow] * laggedVariableTreeNode.Weight; 441 462 } … … 459 480 return trueBranch * p + falseBranch * (1 - p); 460 481 } 461 default: throw new NotSupportedException(); 482 default: 483 throw new NotSupportedException(); 462 484 } 463 485 } -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r12509 r14029 35 35 public sealed class SymbolicDataAnalysisExpressionTreeLinearInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter { 36 36 private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic"; 37 private const string CheckExpressionsWithIntervalArithmeticParameterDescription = "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression."; 37 38 private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions"; 38 39 … … 48 49 49 50 #region parameter properties 50 public I ValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {51 get { return (I ValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }52 } 53 54 public I ValueParameter<IntValue> EvaluatedSolutionsParameter {55 get { return (I ValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }51 public IFixedValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter { 52 get { return (IFixedValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; } 53 } 54 55 public IFixedValueParameter<IntValue> EvaluatedSolutionsParameter { 56 get { return (IFixedValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; } 56 57 } 57 58 #endregion 58 59 59 60 #region properties 60 public BoolValueCheckExpressionsWithIntervalArithmetic {61 get { return CheckExpressionsWithIntervalArithmeticParameter.Value ; }62 set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; }63 } 64 public IntValueEvaluatedSolutions {65 get { return EvaluatedSolutionsParameter.Value ; }66 set { EvaluatedSolutionsParameter.Value = value; }61 public bool CheckExpressionsWithIntervalArithmetic { 62 get { return CheckExpressionsWithIntervalArithmeticParameter.Value.Value; } 63 set { CheckExpressionsWithIntervalArithmeticParameter.Value.Value = value; } 64 } 65 public int EvaluatedSolutions { 66 get { return EvaluatedSolutionsParameter.Value.Value; } 67 set { EvaluatedSolutionsParameter.Value.Value = value; } 67 68 } 68 69 #endregion … … 84 85 public SymbolicDataAnalysisExpressionTreeLinearInterpreter() 85 86 : base("SymbolicDataAnalysisExpressionTreeLinearInterpreter", "Linear (non-recursive) interpreter for symbolic expression trees (does not support ADFs).") { 86 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 87 Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 87 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, new BoolValue(false))); 88 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 89 interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter(); 90 } 91 92 public SymbolicDataAnalysisExpressionTreeLinearInterpreter(string name, string description) 93 : base(name, description) { 94 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, new BoolValue(false))); 95 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0))); 88 96 interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter(); 89 97 } … … 91 99 [StorableHook(HookType.AfterDeserialization)] 92 100 private void AfterDeserialization() { 93 if (interpreter == null) interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter(); 101 var evaluatedSolutions = new IntValue(0); 102 var checkExpressionsWithIntervalArithmetic = new BoolValue(false); 103 if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) { 104 var evaluatedSolutionsParameter = (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; 105 evaluatedSolutions = evaluatedSolutionsParameter.Value; 106 Parameters.Remove(EvaluatedSolutionsParameterName); 107 } 108 Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions)); 109 if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) { 110 var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; 111 Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName); 112 checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value; 113 } 114 Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic)); 94 115 } 95 116 96 117 #region IStatefulItem 97 118 public void InitializeState() { 98 EvaluatedSolutions .Value= 0;119 EvaluatedSolutions = 0; 99 120 } 100 121 … … 102 123 #endregion 103 124 125 private readonly object syncRoot = new object(); 104 126 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 105 if (CheckExpressionsWithIntervalArithmetic .Value)127 if (CheckExpressionsWithIntervalArithmetic) 106 128 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); 107 129 108 lock ( EvaluatedSolutions) {109 EvaluatedSolutions .Value++; // increment the evaluated solutions counter130 lock (syncRoot) { 131 EvaluatedSolutions++; // increment the evaluated solutions counter 110 132 } 111 133 … … 122 144 if (instr.opCode == OpCodes.Variable) { 123 145 if (row < 0 || row >= dataset.Rows) instr.value = double.NaN; 124 var variableTreeNode = (VariableTreeNode)instr.dynamicNode; 125 instr.value = ((IList<double>)instr.data)[row] * variableTreeNode.Weight; 146 else { 147 var variableTreeNode = (VariableTreeNode)instr.dynamicNode; 148 instr.value = ((IList<double>)instr.data)[row] * variableTreeNode.Weight; 149 } 126 150 } else if (instr.opCode == OpCodes.LagVariable) { 127 151 var laggedVariableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode; … … 190 214 } else if (instr.opCode == OpCodes.Root) { 191 215 double x = code[instr.childIndex].value; 192 double y = code[instr.childIndex + 1].value;216 double y = Math.Round(code[instr.childIndex + 1].value); 193 217 instr.value = Math.Pow(x, 1 / y); 194 218 } else if (instr.opCode == OpCodes.Exp) { -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r12753 r14029 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. 8.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic","Provides base classes for symbolic data analysis tasks.", "3.4.9.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.ALGLIB", "3.7.0")] -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Properties/AssemblyInfo.cs.frame
r12753 r14029 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4. 8.$WCREV$")]55 [assembly: AssemblyFileVersion("3.4.9.$WCREV$")] -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs
r12012 r14029 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 25 using System.Linq; 24 26 using HeuristicLab.Common; 25 27 using HeuristicLab.Core; … … 56 58 get { return interpreter; } 57 59 } 60 61 public IEnumerable<string> VariablesUsedForPrediction { 62 get { 63 var variables = 64 SymbolicExpressionTree.IterateNodesPrefix() 65 .OfType<VariableTreeNode>() 66 .Select(x => x.VariableName) 67 .Distinct(); 68 var variableConditions = SymbolicExpressionTree.IterateNodesPrefix() 69 .OfType<VariableConditionTreeNode>().Select(x => x.VariableName).Distinct(); 70 71 return variables.Union(variableConditions).OrderBy(x => x); 72 } 73 } 74 58 75 #endregion 59 76 … … 160 177 } 161 178 #endregion 179 162 180 } 163 181 } -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs
r12012 r14029 100 100 allVariableNames.Clear(); 101 101 allVariableNames.AddRange(value); 102 VariableNames = value;103 102 } 104 103 } … … 149 148 OnChanged(EventArgs.Empty); 150 149 } 150 } 151 } 152 153 public override bool Enabled { 154 get { 155 if (variableNames.Count == 0) return false; 156 return base.Enabled; 157 } 158 set { 159 if (variableNames.Count == 0) base.Enabled = false; 160 else base.Enabled = value; 151 161 } 152 162 }
Note: See TracChangeset
for help on using the changeset viewer.