- Timestamp:
- 02/17/15 16:03:49 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestCanonicalExpressions.cs
r12014 r12024 67 67 Assert.AreEqual("a*b+b*c", extender.CanonicalRepresentation("b*(c-a)")); 68 68 Assert.AreEqual("a*b+a*d+b*c+c*d", extender.CanonicalRepresentation("(b-d)*(c-a)")); 69 Assert.AreEqual(" |/(a+b)", extender.CanonicalRepresentation("c%c%(a+b)"));69 Assert.AreEqual("/(a+b)", extender.CanonicalRepresentation("c%c%(a+b)")); 70 70 } 71 71 [TestMethod] 72 72 public void TestDivisionExpansion() { 73 73 var extender = new ExpressionExtender(); 74 Assert.AreEqual("a* |/c+b*|/c", extender.CanonicalRepresentation("(b+a)%c"));75 Assert.AreEqual("a* |/c*|/d+b*|/c*|/d", extender.CanonicalRepresentation("(b+a)%(d*c)"));76 Assert.AreEqual("a* |/(c+d)+b*|/(c+d)", extender.CanonicalRepresentation("(b-a)%(d-c)"));77 Assert.AreEqual("a*b* |/(c+d)", extender.CanonicalRepresentation("(b*a)%(d-c)"));74 Assert.AreEqual("a*/c+b*/c", extender.CanonicalRepresentation("(b+a)%c")); 75 Assert.AreEqual("a*/c*/d+b*/c*/d", extender.CanonicalRepresentation("(b+a)%(d*c)")); 76 Assert.AreEqual("a*/(c+d)+b*/(c+d)", extender.CanonicalRepresentation("(b-a)%(d-c)")); 77 Assert.AreEqual("a*b*/(c+d)", extender.CanonicalRepresentation("(b*a)%(d-c)")); 78 78 79 Assert.AreEqual("a*b* |/(a+b)*|/(c+d)", extender.CanonicalRepresentation("(b*a)%(d-c)%(a+b)"));80 Assert.AreEqual("a*b* |/(c+d)*|/(a*|/e+b*|/e)", extender.CanonicalRepresentation("((b*a)%(d-c))%((a+b)%e)"));79 Assert.AreEqual("a*b*/(a+b)*/(c+d)", extender.CanonicalRepresentation("(b*a)%(d-c)%(a+b)")); 80 Assert.AreEqual("a*b*/(c+d)*/(a*/e+b*/e)", extender.CanonicalRepresentation("((b*a)%(d-c))%((a+b)%e)")); 81 81 // a*b*e%(c+d)%(a+b) 82 82 } … … 84 84 public void TestDivisionCancellation() { 85 85 var extender = new ExpressionExtender(); 86 Assert.AreEqual(" |", extender.CanonicalRepresentation("a%a"));86 Assert.AreEqual("1", extender.CanonicalRepresentation("a%a")); 87 87 Assert.AreEqual("a", extender.CanonicalRepresentation("a*a%a")); 88 Assert.AreEqual(" |/a", extender.CanonicalRepresentation("(a%a)%a"));89 Assert.AreEqual(" |/a", extender.CanonicalRepresentation("a%a%a"));88 Assert.AreEqual("/a", extender.CanonicalRepresentation("(a%a)%a")); 89 Assert.AreEqual("/a", extender.CanonicalRepresentation("a%a%a")); 90 90 Assert.AreEqual("a", extender.CanonicalRepresentation("a%(a%a)")); 91 Assert.AreEqual(" |", extender.CanonicalRepresentation("(a+b)%(b+a)"));92 Assert.AreEqual(" |/a+|/b", extender.CanonicalRepresentation("(a+b)%(a*b)"));93 Assert.AreEqual("a* |/(a*c*|/b+e*|/d*|/f)+b*|/(a*c*|/b+e*|/d*|/f)", extender.CanonicalRepresentation("(a+b)%(a%b*c+e%f%d)"));94 Assert.AreEqual(" |", extender.CanonicalRepresentation("(a%a%a+b%b%b)%(a%a*a%a%a+b%b*b%b%b)"));95 Assert.AreEqual(" |", extender.CanonicalRepresentation("(a%(a%a)+b%(b%b))%(a+b)"));91 Assert.AreEqual("1", extender.CanonicalRepresentation("(a+b)%(b+a)")); 92 Assert.AreEqual("/a+/b", extender.CanonicalRepresentation("(a+b)%(a*b)")); 93 Assert.AreEqual("a*/(a*c*/b+e*/d*/f)+b*/(a*c*/b+e*/d*/f)", extender.CanonicalRepresentation("(a+b)%(a%b*c+e%f%d)")); 94 Assert.AreEqual("1", extender.CanonicalRepresentation("(a%a%a+b%b%b)%(a%a*a%a%a+b%b*b%b%b)")); 95 Assert.AreEqual("1", extender.CanonicalRepresentation("(a%(a%a)+b%(b%b))%(a+b)")); 96 96 } 97 97
Note: See TracChangeset
for help on using the changeset viewer.