Package org.ggp.base.util.propnet.architecture.components

Examples of org.ggp.base.util.propnet.architecture.components.Proposition


    // based on having the same Body proposition.
    for(Set<Proposition> legalProps : legalPropositions.values()) {
      for(Proposition legalProp : legalProps) {
        List<GdlTerm> legalPropBody = (legalProp.getName()).getBody();
        if (inputPropsByBody.containsKey(legalPropBody)) {
            Proposition inputProp = inputPropsByBody.get(legalPropBody);
            legalInputMap.put(inputProp, legalProp);
            legalInputMap.put(legalProp, inputProp);
        }
      }
    }
View Full Code Here


  public void removeComponent(Component c) {


    //Go through all the collections it could appear in
    if(c instanceof Proposition) {
      Proposition p = (Proposition) c;
      GdlSentence name = p.getName();
      if(basePropositions.containsKey(name)) {
        basePropositions.remove(name);
      } else if(inputPropositions.containsKey(name)) {
        inputPropositions.remove(name);
        //The map goes both ways...
        Proposition partner = legalInputMap.get(p);
        if(partner != null) {
          legalInputMap.remove(partner);
          legalInputMap.remove(p);
        }
      } else if(name == GdlPool.getProposition(GdlPool.getConstant("INIT"))) {
        throw new RuntimeException("The INIT component cannot be removed. Consider leaving it and ignoring it.");
      } else if(name == GdlPool.getProposition(GdlPool.getConstant("terminal"))) {
        throw new RuntimeException("The terminal component cannot be removed.");
      } else {
        for(Set<Proposition> propositions : legalPropositions.values()) {
          if(propositions.contains(p)) {
            propositions.remove(p);
            Proposition partner = legalInputMap.get(p);
            if(partner != null) {
              legalInputMap.remove(partner);
              legalInputMap.remove(p);
            }
          }
View Full Code Here

  {
    if ( literal instanceof GdlDistinct )
    {
      GdlDistinct distinct = (GdlDistinct) literal;

      Proposition proposition = new Proposition(GdlPool.getProposition(GdlPool.getConstant("anon")));
      Constant constant = new Constant(!distinct.getArg1().equals(distinct.getArg2()));

      link(constant, proposition);

      components.add(proposition);
      components.add(constant);

      return proposition;
    }
    else if ( literal instanceof GdlNot )
    {
      GdlNot not = (GdlNot) literal;

      Proposition input = convertConjunct(not.getBody());
      Not no = new Not();
      Proposition output = new Proposition(GdlPool.getProposition(GdlPool.getConstant("anon")));

      link(input, no);
      link(no, output);

      components.add(input);
      components.add(no);
      components.add(output);

      return output;
    }
    else
    {
      GdlSentence sentence = (GdlSentence) literal;

      Proposition proposition = getProposition(sentence);
      components.add(proposition);

      return proposition;
    }
  }
View Full Code Here

   */
  private Proposition convertHead(GdlSentence sentence)
  {
    if ( sentence.getName().getValue().equals("next") )
    {
      Proposition head = getProposition(GdlPool.getRelation(GdlPool.getConstant("true"),
                                                            sentence.getBody()));
      Transition transition = new Transition();
      Proposition preTransition = new Proposition(GdlPool.getProposition(GdlPool.getConstant("anon")));

      link(preTransition, transition);
      link(transition, head);

      components.add(head);
      components.add(transition);
      components.add(preTransition);

      return preTransition;
    }
    else
    {
      Proposition proposition = getProposition(sentence);
      components.add(proposition);

      return proposition;
    }
  }
View Full Code Here

   * @param rule
   *            The rule to convert.
   */
  private void convertRule(GdlRule rule)
  {
    Proposition head = convertHead(rule.getHead());
    And and = new And();

    link(and, head);

    components.add(head);
    components.add(and);

    for ( GdlLiteral literal : rule.getBody() )
    {
      Proposition conjunct = convertConjunct(literal);
      link(conjunct, and);
    }
  }
View Full Code Here

   */
  private void convertStatic(GdlSentence sentence)
  {
    if ( sentence.getName().getValue().equals("init") )
    {
      Proposition init = getProposition(GdlPool.getProposition(GdlPool.getConstant("INIT")));
      Transition transition = new Transition();
      Proposition proposition = getProposition(GdlPool.getRelation(GdlPool.getConstant("true"),
                                                                   sentence.getBody()));

      link(init, transition);
      link(transition, proposition);

      components.add(init);
      components.add(transition);
      components.add(proposition);
    }

    Constant constant = new Constant(true);
    Proposition proposition = getProposition(sentence);

    link(constant, proposition);

    components.add(constant);
    components.add(proposition);
View Full Code Here

      int i = 0;
      for ( Component input : fixItem.getInputs() )
      {
          i++;

        Proposition disjunct = null;
        if ( fixItem.getName() instanceof GdlProposition )
        {
          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

   */
  private Proposition getProposition(GdlSentence sentence)
  {
    if ( !propositions.containsKey(sentence) )
    {
      propositions.put(sentence, new Proposition(sentence));
    }
    return propositions.get(sentence);
  }
View Full Code Here

        if(form.getName().equals(LEGAL)
            || form.getName().equals(GOAL)
            || form.getName().equals(INIT)) {
          //Add it
          for (GdlSentence trueSentence : constantChecker.getTrueSentences(form)) {
            Proposition trueProp = new Proposition(trueSentence);
            trueProp.addInput(trueComponent);
            trueComponent.addOutput(trueProp);
            components.put(trueSentence, trueComponent);
          }
        }
View Full Code Here

   * @param componentSet
   */
  private static void normalizePropositions(Set<Component> componentSet) {
    for(Component component : componentSet) {
      if(component instanceof Proposition) {
        Proposition p = (Proposition) component;
        GdlSentence sentence = p.getName();
        if(sentence instanceof GdlRelation) {
          GdlRelation relation = (GdlRelation) sentence;
          if(relation.getName().equals(NEXT)) {
            p.setName(GdlPool.getProposition(GdlPool.getConstant("anon")));
          }
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.ggp.base.util.propnet.architecture.components.Proposition

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.