Changeset 2449 for trunk/sources
- Timestamp:
- 10/27/09 09:50:46 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs
r2393 r2449 70 70 case EvaluatorSymbolTable.SUBTRACTION: { 71 71 double result = EvaluateBakedCode(); 72 if (currInstr.arity == 1) return -result; 72 73 for (int i = 1; i < currInstr.arity; i++) { 73 74 result -= EvaluateBakedCode(); … … 78 79 double result; 79 80 result = EvaluateBakedCode(); 81 if (currInstr.arity == 1) { 82 return result.IsAlmost(0.0) ? 0.0 : 1.0 / result; 83 } 80 84 for (int i = 1; i < currInstr.arity; i++) { 81 result /= EvaluateBakedCode(); 85 double tmp = EvaluateBakedCode(); 86 result = tmp.IsAlmost(0.0) ? 0.0 : result /= tmp; 82 87 } 83 if (double.IsInfinity(result)) return 0.0; 84 else return result; 88 return result; 85 89 } 86 90 case EvaluatorSymbolTable.AVERAGE: { … … 122 126 double result = EvaluateBakedCode(); 123 127 for (int i = 1; i < currInstr.arity; i++) { 124 if (result < 0.0) SkipBakedCode();128 if (result <= 0.0) SkipBakedCode(); 125 129 else { 126 130 result = EvaluateBakedCode(); 127 131 } 128 132 } 129 return Math.Sign(result);133 return result <= 0.0 ? -1.0 : 1.0; 130 134 } 131 135 case EvaluatorSymbolTable.EQU: { … … 143 147 double condition = EvaluateBakedCode(); 144 148 double result; 145 if (condition <0.0) {149 if (condition > 0.0) { 146 150 result = EvaluateBakedCode(); SkipBakedCode(); 147 151 } else { … … 162 166 double result = EvaluateBakedCode(); 163 167 for (int i = 1; i < currInstr.arity; i++) { 164 if (result > =0.0) SkipBakedCode();168 if (result > 0.0) SkipBakedCode(); 165 169 else { 166 170 result = EvaluateBakedCode(); 167 171 } 168 172 } 169 return Math.Sign(result);173 return result > 0.0 ? 1.0 : -1.0; 170 174 } 171 175 case EvaluatorSymbolTable.XOR: { … … 178 182 } 179 183 // invariant y >= x 180 if (y < 0.0 || x > 0.0) return -1.0;184 if (y <= 0.0 || x > 0.0) return -1.0; 181 185 else return 1.0; 182 186 }
Note: See TracChangeset
for help on using the changeset viewer.