Package org.ggp.base.util.gdl.grammar

Examples of org.ggp.base.util.gdl.grammar.GdlRule.arity()


            }
            return GdlPool.getRelation(rel.getName(), rval);
        } else if(gdl instanceof GdlRule) {
            GdlRule rule = (GdlRule)gdl;
            List<GdlLiteral> rval = new ArrayList<GdlLiteral>();
            for(int i=0; i<rule.arity(); i++)
            {
                rval.add((GdlLiteral) replaceVariableInternal(rule.get(i), toSubstitute, theReplacement));
            }
            return GdlPool.getRule((GdlSentence) replaceVariableInternal(rule.getHead(), toSubstitute, theReplacement), rval);
        } else if(gdl instanceof GdlConstant) {
View Full Code Here


        {
            GdlRule rule = (GdlRule)gdl;
            GdlSentence head = (GdlSentence)getInstantiationAux(rule.getHead(), varInstantiation);

            List<GdlLiteral> body = new ArrayList<GdlLiteral>();
            for(int i=0; i<rule.arity(); i++)
            {
                body.add((GdlLiteral)getInstantiationAux(rule.get(i), varInstantiation));
            }
            return GdlPool.getRule(head, body);
        }
View Full Code Here

        Substitution thetaPrime = Unifier.unify(r.getHead(), sentence);

        if (thetaPrime != null)
        {
          LinkedList<GdlLiteral> sentenceGoals = new LinkedList<GdlLiteral>();
          for (int i = 0; i < r.arity(); i++)
          {
            sentenceGoals.add(r.get(i));
          }

          isConstant &= ask(sentenceGoals, context, theta.compose(thetaPrime), cache, renamer, false, sentenceResults, alreadyAsking);
View Full Code Here

        //See if there is exactly one update rule, and it is the persistence rule
        Set<GdlRule> rules = model.getRules(nextForm);
        if(rules.size() == 1) {
          GdlRule rule = rules.iterator().next();
          //Persistence rule: Exactly one literal, the "true" form of the sentence
          if(rule.arity() == 1) {
            GdlLiteral literal = rule.get(0);
            if(literal instanceof GdlRelation) {
              //Check that it really is the true form
              SentenceForm trueForm = nextForm.withName(GdlPool.getConstant("true"));
              if(trueForm.matches((GdlRelation) literal)) {
View Full Code Here

    long a1 = AssignmentsImpl.getNumAssignmentsEstimate(r1,
        SentenceDomainModels.getVarDomains(r1, newModel, VarDomainOpts.INCLUDE_HEAD), checker);
    long a2 = AssignmentsImpl.getNumAssignmentsEstimate(r2,
        SentenceDomainModels.getVarDomains(r2, newModel, VarDomainOpts.INCLUDE_HEAD), checker);
    int l1 = r1.arity(); if(l1 > 1) l1++;
    int l2 = r2.arity(); if(l2 > 1) l2++;

    //Whether we split or not depends on what the two heuristics say
    long newRulesHeuristic = a1 * l1 + a2 * l2;
    return newRulesHeuristic < curRuleHeuristic;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.