Examples of GdlConstant


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

      List<GdlConstant> tuple = GdlUtils.getTupleFromGroundSentence(sentence);
      if (tuple.size() != form.getTupleSize()) {
        throw new IllegalArgumentException();
      }
      for (int i = 0; i < tuple.size(); i++) {
        GdlConstant constant = tuple.get(i);
        domainsForSlotsBuilder.get(i).add(constant);
      }
    }
    ImmutableList.Builder<ImmutableSet<GdlConstant>> domainsForSlots = ImmutableList.builder();
    for (ImmutableSet.Builder<GdlConstant> builder : domainsForSlotsBuilder) {
View Full Code Here

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

    private Set<GdlRelation> mergeBaseRelations(Set<GdlRelation> rels) {
        HashMap<GdlConstant,List<Set<GdlConstant>>> merges = new HashMap<GdlConstant, List<Set<GdlConstant>>>();
        for(GdlRelation rel : rels)
        {
            GdlConstant name = (GdlConstant)rel.get(0);
            if(!merges.containsKey(name))
                merges.put(name, new ArrayList<Set<GdlConstant>>());
            List<Set<GdlConstant>> merge = merges.get(name);
            addRelToMerge(rel, merge);
        }

        Set<GdlRelation> rval = new HashSet<GdlRelation>();

        GdlConstant valConst = GdlPool.getConstant("val");
        for(GdlConstant c : merges.keySet())
        {
            List<Set<GdlConstant>> merge = merges.get(c);
            List<GdlTerm> body = new ArrayList<GdlTerm>();
            body.add(c);
View Full Code Here

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

        if(!domains.containsKey(loc))
            domains.put(loc, new Domain(loc));
        Domain dom = domains.get(loc);
        if(term instanceof GdlConstant)
        {
            GdlConstant constant = (GdlConstant)term;
            dom.values.add(constant);
        }
        else if(term instanceof GdlFunction)
        {
            GdlFunction func = (GdlFunction)term;
View Full Code Here

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

    //We're looking for things that would be outputs of "true" or "false",
    //but we would still want to keep as propositions to be read by the
    //state machine
    Proposition prop = (Proposition) component;
    GdlConstant name = prop.getName().getName();

    return name.equals(LEGAL) /*|| name.equals(NEXT)*/ || name.equals(GOAL)
        || name.equals(INIT) || name.equals(TERMINAL);
  }
View Full Code Here

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

      if(sentence instanceof GdlProposition) {
        if(sentence.getName() == TERMINAL || sentence.getName() == INIT_CAPS)
          continue;
      } else {
        GdlRelation relation = (GdlRelation) sentence;
        GdlConstant name = relation.getName();
        if(name == LEGAL || name == GOAL || name == DOES
            || name == INIT)
          continue;
      }
      if(p.getInputs().size() < 1) {
View Full Code Here

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

    }

    private static final String renderGdlToXML(Gdl gdl) {
        String rval = "";
        if(gdl instanceof GdlConstant) {
            GdlConstant c = (GdlConstant)gdl;
            return c.getValue();
        } else if(gdl instanceof GdlFunction) {
            GdlFunction f = (GdlFunction)gdl;
            if(f.getName().toString().equals("true"))
            {
                return "<fact>"+renderGdlToXML(f.get(0))+"</fact>";
View Full Code Here

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

    // If the term model is part of a keyword-named sentence,
    // then it is needed. This includes base and init.
    for (SentenceForm form : model.getSentenceForms()) {
      ConcurrencyUtils.checkForInterruption();

      GdlConstant name = form.getName();
      if (ALWAYS_NEEDED_SENTENCE_NAMES.contains(name)) {
        newNeededConstantsByForm.get(form).putAll(curDomains.get(form));
      }
    }
View Full Code Here

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

      //Find the pair with the earliest var. that needs to be changed
      List<GdlVariable> varsToChange = new ArrayList<GdlVariable>();
      for(int d = 0; d < plan.getDistincts().size(); d++) {
        GdlDistinct distinct = plan.getDistincts().get(d);
        //The assignments must use the assignments implied by nextAssignment
        GdlConstant term1 = replaceVariables(distinct.getArg1());
        GdlConstant term2 = replaceVariables(distinct.getArg2());
        if(term1.equals(term2)) {
          //need to change one of these
          varsToChange.add(plan.getVarsToChangePerDistinct().get(d));
        }
      }
View Full Code Here

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

        }
        List<GdlConstant> tuple = tuples.get(curIndex);
        List<Integer> varsChosen = plan.getVarsChosenBySource().get(s);
        List<Boolean> putDontCheckTuple = plan.getPutDontCheckBySource().get(s);
        for(int i = 0; i < tuple.size(); i++) {
          GdlConstant value = tuple.get(i);
          boolean putDontCheck = putDontCheckTuple.get(i);
          int varSlotChosen = varsChosen.get(i);
          if(putDontCheck) {
            nextAssignment.set(varSlotChosen, value);
          } else {
            //It's only at this point that we get to check...
            if(!nextAssignment.get(varSlotChosen).equals(value)) {
              //We need to correct the value
              //This is wrong! The current tuple may be the constraining tuple.
              //But we might need it for performance reasons when there isn't that case...
              //TODO: Restore this when we can tell it's appropriate
              //incrementSourceToGetValueInSlot(s, nextAssignment.get(varSlotChosen), i);
              incrementSource(s);
              //updateNextAssignment(); (should be included at end of calling function)
              return;
            }
          }
        }
      }

      for(int i = 0; i < valueIndices.size(); i++) {
        if((plan.getValuesToCompute() == null || !plan.getValuesToCompute().containsKey(i))
            && plan.getSourceDefiningSlot().get(i) == -1) {
          nextAssignment.set(i, plan.getValuesToIterate().get(i).get(valueIndices.get(i)));
        } else if(plan.getSourceDefiningSlot().get(i) == -1) {
          //Fill in based on a function
          //Note that the values on the left must already be filled in
          GdlConstant valueFromFunction = plan.getValuesToCompute().get(i).getValue(nextAssignment);
//          System.out.println("Setting based on a function: slot " + i + " to value " + valueFromFunction);
          nextAssignment.set(i, valueFromFunction);
        }
      }
    }
View Full Code Here

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

      //First, we stop and see if any of these have already been
      //changed (in nextAssignment)
      for (GdlVariable varToChange : varsToChange) {
        int index = plan.getVarsToAssign().indexOf(varToChange);
        if (index != -1) {
          GdlConstant assignedValue = assignment.get(varToChange);
          if (assignedValue == null) {
            throw new IllegalArgumentException("assignedValue is null; " +
                "varToChange is " + varToChange +
                " and assignment is " + assignment);
          }
          if (nextAssignment == null) {
            throw new IllegalStateException("nextAssignment is null");
          }
          if (!assignedValue.equals(nextAssignment.get(index))) {
            //We've already changed one of these
            return;
          }
        }
      }
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.