Examples of GdlConstant


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

      if (!(proposition.getName() instanceof GdlRelation))
          continue;

      GdlRelation relation = (GdlRelation) proposition.getName();
      if (relation.getName().getValue().equals("legal")) {
        GdlConstant name = (GdlConstant) relation.get(0);
        Role r = new Role(name);
        if (!legalPropositions.containsKey(r)) {
          legalPropositions.put(r, new HashSet<Proposition>());
        }
        legalPropositions.get(r).add(proposition);
View Full Code Here

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

  {
    for ( Proposition proposition : propositions )
    {
      if ( proposition.getName() instanceof GdlProposition )
      {
        GdlConstant constant = ((GdlProposition) proposition.getName()).getName();
        if ( constant.getValue().equals("terminal") )
        {
          return proposition;
        }
      }
    }
View Full Code Here

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

  private Map<SentenceForm, SentenceFormDomain> getCartesianDomainsFromModel() throws InterruptedException {
    Map<SentenceForm, SentenceFormDomain> results = Maps.newHashMap();
    for (Entry<NameAndArity, List<TermModel>> sentenceEntry : sentencesModel.entrySet()) {
      ConcurrencyUtils.checkForInterruption();
      NameAndArity nameAndArity = sentenceEntry.getKey();
      GdlConstant name = nameAndArity.getName();
      List<TermModel> bodyModels = sentenceEntry.getValue();
      // We'll end up taking the Cartesian product of the different
      // types of terms we have available
      if (nameAndArity.getArity() == 0) {
        GdlSentence sentence = GdlPool.getProposition(name);
View Full Code Here

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

  private Set<SentenceForm> getSentenceFormsFromModel() {
    Set<SentenceForm> results = Sets.newHashSet();
    for (Entry<NameAndArity, List<TermModel>> sentenceEntry : sentencesModel.entrySet()) {
      NameAndArity nameAndArity = sentenceEntry.getKey();
      GdlConstant name = nameAndArity.getName();
      List<TermModel> bodyModels = sentenceEntry.getValue();
      // We'll end up taking the Cartesian product of the different
      // types of terms we have available
      if (nameAndArity.getArity() == 0) {
        GdlSentence sentence = GdlPool.getProposition(name);
View Full Code Here

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

        //Either add to that entry, or invalidate the slot
        Map<ImmutableList<GdlConstant>, GdlConstant> valueMap = valueMaps.get(i);
        List<GdlConstant> lookupTuple = Lists.newArrayList(sentenceTuple);
        lookupTuple.remove(i);

        GdlConstant curValue = valueMap.get(lookupTuple);
        GdlConstant newValue = sentenceTuple.get(i);
        if (curValue == null) {
          //Just add to the map
          valueMap.put(ImmutableList.copyOf(lookupTuple), newValue);
        } else {
          //If this isn't the existing sentence, invalidate this slot
View Full Code Here

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

   * these statements are instead transformed into sentences.
   * @throws InterruptedException
   */
  public static List<Gdl> run(List<Gdl> description) throws InterruptedException {
    SentenceFormModel model = SentenceFormModelFactory.create(description);
    GdlConstant NEXT = GdlPool.getConstant("next");

    List<SentenceForm> nextFormsToReplace = new ArrayList<SentenceForm>();
    //Find the update rules for each "true" statement
    for(SentenceForm nextForm : model.getSentenceForms()) {
      if(nextForm.getName().equals(NEXT)) {
View Full Code Here

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

        }
        List<GdlConstant> longTuple = GdlUtils.getTupleFromGroundSentence(sentence);
        List<GdlConstant> shortTuple = new ArrayList<GdlConstant>(varsChosen.size());
        for(int c = 0; c < constraintSlots.size(); c++) {
          int slot = constraintSlots.get(c);
          GdlConstant value = constraintValues.get(c);
          if(!longTuple.get(slot).equals(value))
            continue byTuple;
        }
        int c = 0;
        for(int s = 0; s < longTuple.size(); s++) {
View Full Code Here

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

        if(!refTerm.equals(headTerm))
          //The rule can't produce this sentence
          return false;
      } else if(headTerm instanceof GdlVariable) {
        GdlVariable var = (GdlVariable) headTerm;
        GdlConstant curValue = assignment.get(var);
        if(curValue != null && !curValue.equals(refTerm)) {
          //inconsistent assignment (e.g. head is (rel ?x ?x), sentence is (rel 1 2))
          return false;
        }
        assignment.put(var, (GdlConstant)refTerm);
      } else if(headTerm instanceof GdlFunction) {
View Full Code Here

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

  //The tuple size is the total number of constants and/or variables
  //within the entire sentence, including inside functions.
  private final int tupleSize;

  public static SimpleSentenceForm create(GdlSentence sentence) {
    GdlConstant name = sentence.getName();
    int arity = sentence.arity();
    int tupleSize = 0;
    Map<Integer, SimpleSentenceForm> functions = Maps.newHashMap();
    for (int i = 0; i < arity; i++) {
      GdlTerm term = sentence.get(i);
View Full Code Here

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

        ImmutableMap.copyOf(functions),
        tupleSize);
  }

  private static SimpleSentenceForm create(GdlFunction function) {
    GdlConstant name = function.getName();
    int arity = function.arity();
    int tupleSize = 0;
    Map<Integer, SimpleSentenceForm> functions = Maps.newHashMap();
    for (int i = 0; i < arity; i++) {
      GdlTerm term = function.get(i);
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.