Changeset 12024 for branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg
- Timestamp:
- 02/17/15 16:03:49 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/ExpressionCompiler.cs
r12014 r12024 95 95 if (f != null) factors.Add(f); 96 96 var curSy = CurSy(); 97 while (curSy == '*' || curSy == '%' || curSy == '/') { // division and protected division symbols are handled in the same way97 while (curSy == '*' || curSy == '%') { // division and protected division symbols are handled in the same way 98 98 if (curSy == '*') { 99 99 NewSy(); … … 135 135 r = variables[varIdx]; 136 136 NewSy(); 137 } else if (curSy == ' |') {138 // pipe symbol is used in the expressionextender to represent constant one (|/x).137 } else if (curSy == '/') { 138 // /-symbol used in the expressionextender to represent inverse (1/x). 139 139 // this is necessary because we also use symbols 0..9 as indices for ERCs 140 r = 1.0;141 140 NewSy(); 141 r = 1.0 / Fact(variables, constants); 142 142 } else if (curSy >= '0' && curSy <= '9') { 143 143 int o = (byte)curSy - (byte)'0'; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/SymbolicRegressionProblem.cs
r12014 r12024 126 126 127 127 public double Evaluate(string sentence) { 128 var extender = new ExpressionExtender(); 129 sentence = extender.CanonicalRepresentation(sentence); 128 130 if (useConstantOpt) 129 131 return OptimizeConstantsAndEvaluate(sentence); 130 132 else { 131 var extender = new ExpressionExtender();132 133 133 134 Debug.Assert(SimpleEvaluate(sentence) == SimpleEvaluate(extender.CanonicalRepresentation(sentence))); … … 152 153 153 154 public IEnumerable<Feature> GetFeatures(string phrase) { 155 // throw new NotImplementedException(); 154 156 phrase = CanonicalRepresentation(phrase); 155 return new Feature[] { new Feature(phrase, 1.0) }; 157 return phrase.Split('+').Distinct().Select(t => new Feature(t, 1.0)); 158 // return new Feature[] { new Feature(phrase, 1.0) }; 156 159 } 157 160
Note: See TracChangeset
for help on using the changeset viewer.