Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/17/15 16:03:49 (10 years ago)
Author:
gkronber
Message:

#2283: changed handling of inverse expressions in transformation of expressions to canonical form

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestCanonicalExpressions.cs

    r12014 r12024  
    6767      Assert.AreEqual("a*b+b*c", extender.CanonicalRepresentation("b*(c-a)"));
    6868      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)"));
    7070    }
    7171    [TestMethod]
    7272    public void TestDivisionExpansion() {
    7373      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)"));
    7878
    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)"));
    8181      // a*b*e%(c+d)%(a+b)
    8282    }
     
    8484    public void TestDivisionCancellation() {
    8585      var extender = new ExpressionExtender();
    86       Assert.AreEqual("|", extender.CanonicalRepresentation("a%a"));
     86      Assert.AreEqual("1", extender.CanonicalRepresentation("a%a"));
    8787      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"));
    9090      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)"));
    9696    }
    9797
Note: See TracChangeset for help on using the changeset viewer.