Package operators

Examples of operators.N


    // gnear rule
    for (FaspConstant a : atm) {
      for (FaspConstant t : town) {
        // Why doesn't Java just support new ArrayList<FaspConstant>({a,t}) ?
        GroundLiteral head = createLiteral("locNear", false, null, a, t);
        GroundLiteral bodyElt = createLiteral("locNear2", true, new N(), a, t);
        GroundRule gnear = createRegularRule(head, new TW(), bodyElt);
        rules.add(gnear);
      }
    }

    // gnear' rule
    for (FaspConstant a : atm) {
      for (FaspConstant t1 : town) {
        GroundLiteral head = createLiteral("locNear2", false, null, a, t1);
        for (FaspConstant t2 : town) {
          GroundLiteral b1 = createRegLiteral("loc", a, t1, t2);
          GroundLiteral b2 = createNafLiteral("near", new N(), t1, t2);
          GroundLiteral b3 = createRegLiteral("locNear", a, t2);
          GroundRule gnearP = createRegularRule(head, new TW(), b1, b2, b3);
          rules.add(gnearP);
        }
      }
    }

    // nearr rule
    for (FaspConstant t1 : town) {
      for (FaspConstant t2 : town) {
        GroundLiteral head = createRegLiteral("near", t1, t2);
        for (FaspConstant t3 : town) {
          GroundLiteral b1 = createRegLiteral("conn", t1, t3);
          GroundLiteral b2 = createRegLiteral("near", t1, t3);
          GroundLiteral b3 = createRegLiteral("near", t3, t2);
          GroundRule nearr = createRegularRule(head, new TW(), b1, b2, b3);
          rules.add(nearr);
        }
      }
    }

    // locr rule
    for (FaspConstant a : atm) {
      for (FaspConstant t1 : town) {
        for (FaspConstant t2 : town) {
          // Small optimization
          if (!t1.equals(t2)) {
            GroundLiteral head = createRegLiteral("loc", a, t1, t2);
            GroundLiteral body = createRegLiteral("loc", a, t2, t1);
            GroundRule locr = createRegularRule(head, new TW(), body);
            rules.add(locr);
          }
        }
      }
    }

    // atmr rule
    for (FaspConstant a : atm) {
      for (FaspConstant t : town) {
        //GroundLiteral head = createRegLiteral("isNear", a, t);
        GroundLiteral head = createRegLiteral("atmNear", a, t);
        for (FaspConstant t1 : town) {
          for (FaspConstant t2 : town) {
            GroundLiteral b1 = createRegLiteral("loc", a, t1, t2);
            GroundLiteral b2 = createRegLiteral("locNear", a, t1);
            GroundLiteral b3 = createRegLiteral("near", t, t1);
            GroundRule atmr = createRegularRule(head, new TW(), b1, b2, b3);
            rules.add(atmr);
          }
        }
      }
    }

    // nearestAtm rule
    for (FaspConstant t : town) {
      GroundLiteral head = createRegLiteral("nearestAtm", t);
      for (FaspConstant a : atm) {
        GroundLiteral b = createRegLiteral("atmNear", a, t);
        GroundRule nearestAtm = createRegularRule(head, new TW(), b);
        rules.add(nearestAtm);
      }
    }

    // tDist rule
    GroundLiteral tDistHead = createRegLiteral("totNear");
    ArrayList<FaspFuzzyExpression> tDistBody = new ArrayList<FaspFuzzyExpression>();
    for (FaspConstant a : atm) {
      for (FaspConstant t : town) {
        tDistBody.add(createRegLiteral("atmNear", a, t));
      }
    }
    GroundRule tDistRule = new GroundRegularRule(tDistHead, tDistBody, new TM());
    rules.add(tDistRule);

    /*GroundLiteral tDistHead = createRegLiteral("totNear");
    ArrayList<FaspFuzzyExpression> tDistBody = new ArrayList<FaspFuzzyExpression>();
    for (FaspConstant t : town) {
    tDistBody.add(createRegLiteral("nearestAtm",t));
    }
    GroundRule tDistRule = new GroundRegularRule(tDistHead,tDistBody, new TM());
    rules.add(tDistRule);*/

    // constraint rule
    ArrayList<FaspFuzzyExpression> constrBody = new ArrayList<FaspFuzzyExpression>();
    constrBody.add(createNafLiteral("totNear", new N()));
    // We use 1-k because constraint (1-k) <- (1-totNear) means
    // 1-k >= 1-totNear, hence k <= totNear
    rules.add(new GroundRegularConstraint(new LattVal(1 - k), constrBody, new TW()));

    // Print the grounded program
View Full Code Here

TOP

Related Classes of operators.N

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.