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

Examples of org.ggp.base.util.gdl.grammar.GdlRelation


    List<Proposition> addList = new ArrayList<Proposition>();
    for ( Proposition proposition : propositions.values() )
    {
      if ( proposition.getName() instanceof GdlRelation )
      {
        GdlRelation relation = (GdlRelation) proposition.getName();
        if ( relation.getName().getValue().equals("legal") )
        {
          addList.add(proposition);
        }
      }
    }

    for ( Proposition addItem : addList )
    {
      GdlRelation relation = (GdlRelation) addItem.getName();
      components.add(getProposition(GdlPool.getRelation(GdlPool.getConstant("does"), relation.getBody())));
    }
  }
View Full Code Here


          GdlProposition proposition = (GdlProposition) fixItem.getName();
          disjunct = new Proposition(GdlPool.getProposition(GdlPool.getConstant(proposition.getName().getValue() + "-" + i)));
        }
        else
        {
          GdlRelation relation = (GdlRelation) fixItem.getName();
          disjunct = new Proposition(GdlPool.getRelation(GdlPool.getConstant(relation.getName().getValue() + "-" + i), relation.getBody()));
        }

        input.getOutputs().clear();

        link(input, disjunct);
View Full Code Here

        results.put(form, CartesianSentenceFormDomain.create(form, ImmutableList.<Set<GdlConstant>>of()));
      } else {
        List<Set<GdlTerm>> sampleTerms = toSampleTerms(bodyModels);
        for (List<GdlTerm> terms : Sets.cartesianProduct(sampleTerms)) {
          ConcurrencyUtils.checkForInterruption();
          GdlRelation sentence = GdlPool.getRelation(name, terms);
          SimpleSentenceForm form = SimpleSentenceForm.create(sentence);
          SentenceFormDomain domain = getDomain(form, sentence);
          results.put(form, domain);
        }
      }
View Full Code Here

      //Go through the rules and relations, making replacements as needed
      for(int i = 0; i < newDescription.size(); i++) {
        Gdl gdl = newDescription.get(i);
        if(gdl instanceof GdlRelation) {
          //Replace initForm
          GdlRelation relation = (GdlRelation) gdl;
          if(initForm.matches(relation)) {
            GdlSentence newSentence = relation.get(0).toSentence();
            newDescription.set(i, newSentence);
          }
        } else if(gdl instanceof GdlRule) {
          GdlRule rule = (GdlRule) gdl;
          //Remove persistence rule (i.e. rule with next form as head)
View Full Code Here

          //For now, we take a strict definition of that
          //Compare its size with the product of the domains
          //of the variables it defines
          //In the future, we could require a certain ratio
          //to decide that this is worthwhile
          GdlRelation relation = (GdlRelation) conjunct;
          int maxSize = 1;
          Set<GdlVariable> vars = new HashSet<GdlVariable>(GdlUtils.getVariables(relation));
          for(GdlVariable var : vars) {
            int domainSize = varDomainSizes.get(var);
            maxSize *= domainSize;
View Full Code Here

   * @param goalProposition
   * @return the integer value of the goal proposition
   */
    private int getGoalValue(Proposition goalProposition)
  {
    GdlRelation relation = (GdlRelation) goalProposition.getName();
    GdlConstant constant = (GdlConstant) relation.get(1);
    return Integer.parseInt(constant.toString());
  }
View Full Code Here

        for(Gdl gdl : description)
        {
            if(gdl instanceof GdlRelation)
            {
                GdlRelation relation = (GdlRelation) gdl;
                String name = relation.getName().toString();
                if(name.equals("base"))
                    continue;

                rval.add(GdlPool.getRule(relation));
            }
View Full Code Here

    }

    private Gdl getInstantiationAux(Gdl gdl, Map<GdlVariable, GdlConstant> varInstantiation) {
        if(gdl instanceof GdlRelation)
        {
            GdlRelation relation = (GdlRelation) gdl;

            List<GdlTerm> body = new ArrayList<GdlTerm>();
            for(int i=0; i<relation.arity(); i++)
            {
                body.add((GdlTerm)getInstantiationAux(relation.get(i), varInstantiation));
            }
            return GdlPool.getRelation(relation.getName(), body);
        }
        else if(gdl instanceof GdlRule)
        {
            GdlRule rule = (GdlRule)gdl;
            GdlSentence head = (GdlSentence)getInstantiationAux(rule.getHead(), varInstantiation);
View Full Code Here

    void initializeDomains(Gdl gdl)
    {
        if(gdl instanceof GdlRelation)
        {
            GdlRelation relation = (GdlRelation) gdl;
            String name = relation.getName().toString();
            if(!name.equals("base"))
            {
                GdlTerm term = relation.toTerm();
                GdlTerm generified = findGenericForm(term);
                Assignment instantiation = getConstantList(term);
                if(!domains.containsKey(generified))
                    domains.put(generified, new Domain(generified, term));
                Domain dom = domains.get(generified);
                dom.assignments.add(instantiation);
            }
        }
        else if(gdl instanceof GdlRule)
        {
            GdlRule rule = (GdlRule)gdl;
            GdlSentence head = rule.getHead();
            if(head instanceof GdlRelation)
            {
                GdlRelation rel = (GdlRelation)head;
                GdlTerm term = rel.toTerm();

                GdlTerm generified = findGenericForm(term);
                if(!domains.containsKey(generified))
                    domains.put(generified, new Domain(generified, term));
                Domain dom = domains.get(generified);
View Full Code Here

TOP

Related Classes of org.ggp.base.util.gdl.grammar.GdlRelation

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.