Package operators

Examples of operators.TW


  public MultiOperator getRuleImplicator () {
    return new IW();
  }

  public MultiOperator getRuleTNorm () {
    return new TW();
  }
View Full Code Here


    for (FaspConstant t1 : town) {
      for (FaspConstant t2 : town) {
        if (distances.containsKey(new Pair<String, String>(t1.getName(), t2.getName()))) {
          GroundLiteral headd = createRegLiteral("near", t1, t2);
          GroundLiteral headc = createRegLiteral("conn", t1, t2);
          GroundRule factd = createRegularRule(headd, new TW(),
              new LattVal(distances.get(new Pair<String, String>(t1.getName(), t2.getName()))));
          GroundRule factc = createRegularRule(headc, new TW(), new LattVal(1.0));
          rules.add(factd);
          rules.add(factc);
        }
      }
    }

    // gloc rule
    for (FaspConstant a : atm) {
      for (FaspConstant t1 : town) {
        for (FaspConstant t2 : town) {
          // Different to the TPLP paper:
          if (!t1.equals(t2)) {
            GroundLiteral head = createRegLiteral("loc", a, t1, t2);

            GroundLiteral bodyl = createRegLiteral("conn", t1, t2);
            ArrayList<FaspFuzzyExpression> body = new ArrayList<FaspFuzzyExpression>();
            body.add(bodyl);

            for (FaspConstant tt1 : town) {
              for (FaspConstant tt2 : town) {
                if (!(((t1.equals(tt1)) && (t2.equals(tt2))) || ((t1.equals(tt2))
                    || (t2.equals(tt1))))
                    && (!tt1.equals(tt2))) {
                  GroundLiteral betaLit = createLiteral("loc", true, new NM(), a, tt1, tt2);
                  body.add(betaLit);
                }
              }
            }

            GroundRule locRule = new GroundRegularRule(head, body, new TW());
            rules.add(locRule);
          }
        }
      }
    }

    // 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
    /*for (GroundRule r : rules) {
    System.out.println(r);
    }*/
 
View Full Code Here

//    rules.add(tDistRule);

    GroundLiteral aHead = createRegLiteral("a");
    ArrayList<FaspFuzzyExpression> aBody = new ArrayList<FaspFuzzyExpression>();
    aBody.add(createNafLiteral("b",new NM()));
    GroundRule aRule = new GroundRegularRule(aHead,aBody,new TW());

    GroundLiteral bHead = createRegLiteral("b");
    ArrayList<FaspFuzzyExpression> bBody = new ArrayList<FaspFuzzyExpression>();
    bBody.add(createNafLiteral("a",new NM()));
    GroundRule bRule = new GroundRegularRule(bHead,bBody,new TW());

    ArrayList<GroundRule> rules = new ArrayList<GroundRule>();
    rules.add(aRule);
    rules.add(bRule);
    GroundProgram prog = new GroundProgram(rules);
View Full Code Here

        System.out.println(ff.toString());
        try{
            GroundProgram gp6 = sb.makeGroundProgram(ff, new MULTIMIN(), new FPROD(), new FPROD());
            ConsequenceOp imcons6 = new ConsequenceOp(gp6);
            FaspInterpretation model6 = imcons6.computeLFP(main_resource_id+"_MULTIMIN_FPROD_FPROD");
            GroundProgram gp5 = sb.makeGroundProgram(ff, new MULTIMIN(), new TW(), new TW());
            ConsequenceOp imcons5 = new ConsequenceOp(gp5);
            FaspInterpretation model5 = imcons5.computeLFP(main_resource_id+"_MULTIMIN_TW_TW");
            GroundProgram gp1 = sb.makeGroundProgram(ff, new MULTIMIN(), new FPROD(), new FPROD());
            ConsequenceOp imcons1 = new ConsequenceOp(gp1);
            FaspInterpretation model1 = imcons1.computeLFP(main_resource_id+"_MULTIMIN_FPROD_TW");
            GroundProgram gp = sb.makeGroundProgram(ff, new WSUM(), new TW(), new FPROD());
            ConsequenceOp imcons = new ConsequenceOp(gp);
            FaspInterpretation model = imcons.computeLFP(main_resource_id+"_WSUM_TW_FPROD");
            GroundProgram gp2 = sb.makeGroundProgram(ff, new MULTIMIN(), new TW(), new FPROD());
            ConsequenceOp imcons2 = new ConsequenceOp(gp2);
            FaspInterpretation model2 = imcons2.computeLFP(main_resource_id+"_MULTIMIN_TW_FPROD");
            GroundProgram gp3 = sb.makeGroundProgram(ff, new WSUM(), new FPROD(), new TW());
            ConsequenceOp imcons3 = new ConsequenceOp(gp3);
            FaspInterpretation model3 = imcons3.computeLFP(main_resource_id+"_WSUM_FPROD_TW");
            GroundProgram gp4 = sb.makeGroundProgram(ff, new MULTIMIN(), new FPROD(), new TW());
            ConsequenceOp imcons4 = new ConsequenceOp(gp4);
            FaspInterpretation model4 = imcons4.computeLFP(main_resource_id+"_MULTIMIN_FPROD_TW");
        }catch(UnsupportedItemException ex){
            System.err.println(ex);
        }
View Full Code Here

            FileOutputStream fos5 = null;
            ObjectOutputStream out5 = null;
            FileOutputStream fos6 = null;
            ObjectOutputStream out6 = null;
            try{
                GroundProgram gp1 = sb.makeGroundProgram(ff, new WSUM(), new TW(), new FPROD());
                fos1 = new FileOutputStream("gp1"+ff.getMain()+"_"+ff.getResources().size()+".ser");
                out1 = new ObjectOutputStream(fos1);
                out1.writeObject(gp1);
                out1.close();
                r.gc();
                GroundProgram gp2 = sb.makeGroundProgram(ff, new MULTIMIN(), new TW(), new FPROD());
                fos2 = new FileOutputStream("gp2"+ff.getMain()+"_"+ff.getResources().size()+".ser");
                out2 = new ObjectOutputStream(fos2);
                out2.writeObject(gp2);
                out2.close();
                r.gc();
                GroundProgram gp3 = sb.makeGroundProgram(ff, new WSUM(), new FPROD(), new TW());
                fos3 = new FileOutputStream("gp3"+ff.getMain()+"_"+ff.getResources().size()+".ser");
                out3 = new ObjectOutputStream(fos3);
                out3.writeObject(gp3);
                out3.close();
                r.gc();
                GroundProgram gp4 = sb.makeGroundProgram(ff, new MULTIMIN(), new FPROD(), new TW());
                fos4 = new FileOutputStream("gp4"+ff.getMain()+"_"+ff.getResources().size()+".ser");
                out4 = new ObjectOutputStream(fos4);
                out4.writeObject(gp4);
                out4.close();
                r.gc();
                GroundProgram gp5 = sb.makeGroundProgram(ff, new MULTIMIN(), new TW(), new TW());
                fos5 = new FileOutputStream("gp5"+ff.getMain()+"_"+ff.getResources().size()+".ser");
                out5 = new ObjectOutputStream(fos5);
                out5.writeObject(gp5);
                out5.close();
                r.gc();
View Full Code Here

TOP

Related Classes of operators.TW

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.