- Timestamp:
- 02/15/11 10:34:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests/SymbolicSimplifierTest.cs
r5460 r5461 140 140 } 141 141 #endregion 142 #region constant and variable folding 143 { 144 var actualTree = simplifier.Simplify(importer.Import("(+ 1.0 2.0)")); 145 var expectedTree = importer.Import("3.0"); 146 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 147 } 148 { 149 var actualTree = simplifier.Simplify(importer.Import("(+ (variable 2.0 a) (variable 2.0 a))")); 150 var expectedTree = importer.Import("(variable 4.0 a)"); 151 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 152 } 153 { 154 var actualTree = simplifier.Simplify(importer.Import("(- (variable 2.0 a) (variable 1.0 a))")); 155 var expectedTree = importer.Import("(variable 1.0 a)"); 156 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 157 } 158 { 159 var actualTree = simplifier.Simplify(importer.Import("(* (variable 2.0 a) (variable 2.0 a))")); 160 var expectedTree = importer.Import("(* (* (variable 1.0 a) (variable 1.0 a)) 4.0)"); 161 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 162 } 163 { 164 var actualTree = simplifier.Simplify(importer.Import("(/ (variable 1.0 a) (variable 2.0 a))")); 165 var expectedTree = importer.Import("0.5"); 166 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 167 } 168 #endregion 142 169 #region logarithm rules 143 170 { … … 155 182 { 156 183 // log transformation 157 var actualTree = simplifier.Simplify(importer.Import("(log (* (variable 2.0 a) (variable 3.0 b)) "));158 var expectedTree = importer.Import("(+ (log (variable 2.0 a)) (log (variable 3.0 b)))");184 var actualTree = simplifier.Simplify(importer.Import("(log (* (variable 2.0 a) (variable 3.0 b)))")); 185 var expectedTree = importer.Import("(+ (log (variable 1.0 a)) (log (variable 1.0 b)) 1.7918)"); 159 186 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 160 187 } 161 188 { 162 189 // log transformation 163 var actualTree = simplifier.Simplify(importer.Import("(log (/ (variable 2.0 a) (variable 3.0 b)) "));190 var actualTree = simplifier.Simplify(importer.Import("(log (/ (variable 2.0 a) (variable 3.0 b)))")); 164 191 var expectedTree = importer.Import("(- (log (variable 2.0 a)) (log (variable 3.0 b)))"); 165 192 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); … … 194 221 // constant not 195 222 var actualTree = simplifier.Simplify(importer.Import("(not -2.0)")); 196 var expectedTree = importer.Import(" 1.0");223 var expectedTree = importer.Import("2.0"); 197 224 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 198 225 } … … 200 227 // constant not 201 228 var actualTree = simplifier.Simplify(importer.Import("(not 2.0)")); 202 var expectedTree = importer.Import("- 1.0");229 var expectedTree = importer.Import("-2.0"); 203 230 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 204 231 } … … 206 233 // constant not 207 234 var actualTree = simplifier.Simplify(importer.Import("(not 0.0)")); 208 var expectedTree = importer.Import(" 1.0");235 var expectedTree = importer.Import("0.0"); 209 236 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 210 237 } … … 245 272 var actualTree = simplifier.Simplify(importer.Import("(if (variable 1.0 a) (variable 2.0 a) (variable 3.0 a))")); 246 273 var expectedTree = importer.Import("(if (> (variable 1.0 a) 0.0) (variable 2.0 a) (variable 3.0 a))"); 247 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));248 }249 #endregion250 #region constant and variable folding251 {252 var actualTree = simplifier.Simplify(importer.Import("(+ 1.0 2.0)"));253 var expectedTree = importer.Import("3.0");254 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));255 }256 {257 var actualTree = simplifier.Simplify(importer.Import("(+ (variable 2.0 a) (variable 2.0 a))"));258 var expectedTree = importer.Import("(variable 4.0 a)");259 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));260 }261 {262 var actualTree = simplifier.Simplify(importer.Import("(- (variable 2.0 a) (variable 1.0 a))"));263 var expectedTree = importer.Import("(variable 1.0 a)");264 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));265 }266 {267 var actualTree = simplifier.Simplify(importer.Import("(* (variable 2.0 a) (variable 2.0 a))"));268 var expectedTree = importer.Import("(* (* (variable 1.0 a) (variable 1.0 a)) 4.0)");269 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));270 }271 {272 var actualTree = simplifier.Simplify(importer.Import("(/ (variable 1.0 a) (variable 2.0 a))"));273 var expectedTree = importer.Import("0.5");274 274 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 275 275 }
Note: See TracChangeset
for help on using the changeset viewer.