- Timestamp:
- 02/15/11 13:36:45 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests/SymbolicExpressionImporter.cs
r5445 r5465 42 42 {"EXP", new Exponential()}, 43 43 {"LOG", new Logarithm()}, 44 {"POW", new Power()}, 45 {"ROOT", new Root()}, 44 46 {"SIN",new Sine()}, 45 47 {"COS", new Cosine()}, -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Tests/SymbolicSimplifierTest.cs
r5461 r5465 170 170 { 171 171 // cancellation 172 var actualTree = simplifier.Simplify(importer.Import("(exp (log (variable 2.0 a)))"));173 var expectedTree = importer.Import("(variable 2.0 a)");174 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));175 }176 {177 // cancellation178 172 var actualTree = simplifier.Simplify(importer.Import("(log (exp (variable 2.0 a)))")); 179 173 var expectedTree = importer.Import("(variable 2.0 a)"); … … 190 184 var actualTree = simplifier.Simplify(importer.Import("(log (/ (variable 2.0 a) (variable 3.0 b)))")); 191 185 var expectedTree = importer.Import("(- (log (variable 2.0 a)) (log (variable 3.0 b)))"); 186 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 187 } 188 #endregion 189 #region exponentiation rules 190 { 191 // cancellation 192 var actualTree = simplifier.Simplify(importer.Import("(exp (log (variable 2.0 a)))")); 193 var expectedTree = importer.Import("(variable 2.0 a)"); 194 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 195 } 196 { 197 // exp transformation 198 var actualTree = simplifier.Simplify(importer.Import("(exp (+ (variable 2.0 a) (variable 3.0 b)))")); 199 var expectedTree = importer.Import("(* (exp (variable 2.0 a)) (exp (variable 3.0 b)))"); 200 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 201 } 202 { 203 // exp transformation 204 var actualTree = simplifier.Simplify(importer.Import("(exp (- (variable 2.0 a) (variable 3.0 b)))")); 205 var expectedTree = importer.Import("(* (exp (variable 2.0 a)) (exp (variable -3.0 b)))"); 206 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 207 } 208 #endregion 209 #region power rules 210 { 211 // cancellation 212 var actualTree = simplifier.Simplify(importer.Import("(pow (variable 2.0 a) 0.0)")); 213 var expectedTree = importer.Import("1.0"); 214 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 215 } 216 { 217 // fixed point 218 var actualTree = simplifier.Simplify(importer.Import("(pow (variable 2.0 a) 1.0)")); 219 var expectedTree = importer.Import("(variable 2.0 a)"); 220 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 221 } 222 { 223 // inversion fixed point 224 var actualTree = simplifier.Simplify(importer.Import("(pow (variable 2.0 a) -1.0)")); 225 var expectedTree = importer.Import("(/ 1.0 (variable 2.0 a))"); 226 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 227 } 228 { 229 // inversion 230 var actualTree = simplifier.Simplify(importer.Import("(pow (variable 2.0 a) -2.0)")); 231 var expectedTree = importer.Import("(/ 1.0 (pow (variable 2.0 a) 2.0))"); 232 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 233 } 234 { 235 // constant folding 236 var actualTree = simplifier.Simplify(importer.Import("(pow 3.0 2.0)")); 237 var expectedTree = importer.Import("9.0"); 238 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 239 } 240 #endregion 241 #region root rules 242 { 243 // cancellation 244 var actualTree = simplifier.Simplify(importer.Import("(root (variable 2.0 a) 0.0)")); 245 var expectedTree = importer.Import("1.0"); 246 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 247 } 248 { 249 // fixed point 250 var actualTree = simplifier.Simplify(importer.Import("(root (variable 2.0 a) 1.0)")); 251 var expectedTree = importer.Import("(variable 2.0 a)"); 252 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 253 } 254 { 255 // inversion fixed point 256 var actualTree = simplifier.Simplify(importer.Import("(root (variable 2.0 a) -1.0)")); 257 var expectedTree = importer.Import("(/ 1.0 (variable 2.0 a))"); 258 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 259 } 260 { 261 // inversion 262 var actualTree = simplifier.Simplify(importer.Import("(root (variable 2.0 a) -2.0)")); 263 var expectedTree = importer.Import("(/ 1.0 (root (variable 2.0 a) 2.0))"); 264 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 265 } 266 { 267 // constant folding 268 var actualTree = simplifier.Simplify(importer.Import("(root 9.0 2.0)")); 269 var expectedTree = importer.Import("3.0"); 192 270 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 193 271 }
Note: See TracChangeset
for help on using the changeset viewer.