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

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


      List<Set<GdlConstant>> domainContents) {
    if (body.size() != bodyModel.size()) {
      throw new IllegalStateException("Should have same arity in example as in model");
    }
    for (int i = 0; i < body.size(); i++) {
      GdlTerm term = body.get(i);
      TermModel termModel = bodyModel.get(i);
      if (term instanceof GdlConstant) {
        domainContents.add(termModel.getPossibleConstants());
      } else if (term instanceof GdlFunction) {
        GdlFunction function = (GdlFunction) term;
View Full Code Here


      Map<GdlVariable, TermModel> varsToModelsMap) {
    if (body.size() != model.size()) {
      throw new IllegalArgumentException("The term model and body sizes don't match: model is " + model + ", body is: " + body);
    }
    for (int i = 0; i < body.size(); i++) {
      GdlTerm term = body.get(i);
      TermModel termModel = model.get(i);
      if (term instanceof GdlVariable) {
        GdlVariable var = (GdlVariable) term;
        if (varsToModelsMap.containsKey(var)) {
          varsToModelsMap.get(var).mergeIn(termModel);
View Full Code Here

    if (model.size() != body.size()) {
      throw new IllegalArgumentException("The term model and body sizes don't match: model is " + model + ", body is: " + body);
    }
    for (int i = 0; i < model.size(); i++) {
      TermModel termModel = model.get(i);
      GdlTerm term = body.get(i);
      changesMade |= termModel.addTerm(term, varsToModelsMap);
    }
    return changesMade;
  }
View Full Code Here

      List<Integer> constraintSlots = new ArrayList<Integer>();
      List<GdlConstant> constraintValues = new ArrayList<GdlConstant>();
      List<Integer> varsChosen = new ArrayList<Integer>();
      List<Boolean> putDontCheck = new ArrayList<Boolean>();
      for(int i = 0; i < conjunctTuple.size(); i++) {
        GdlTerm term = conjunctTuple.get(i);
        if(term instanceof GdlConstant) {
          constraintSlots.add(i);
          constraintValues.add((GdlConstant) term);
          //TODO: What if tuple size ends up being 0?
          //Need to keep that in mind
View Full Code Here

    this(Collections.EMPTY_MAP, rule, varDomains, functionInfoMap, completedSentenceFormValues);
  }

  private void checkDistinctsAgainstHead() {
    for(GdlDistinct distinct : distincts) {
      GdlTerm term1 = CommonTransforms.replaceVariables(distinct.getArg1(), headAssignment);
      GdlTerm term2 = CommonTransforms.replaceVariables(distinct.getArg2(), headAssignment);
      if(term1.equals(term2)) {
        //This fails
        empty = true;
        allDone = true;
      }
View Full Code Here

    return setVariablesInHead(head.getBody(), sentence.getBody(), assignment);
  }
  private static boolean setVariablesInHead(List<GdlTerm> head,
      List<GdlTerm> sentence, Map<GdlVariable, GdlConstant> assignment) {
    for(int i = 0; i < head.size(); i++) {
      GdlTerm headTerm = head.get(i);
      GdlTerm refTerm = sentence.get(i);
      if(headTerm instanceof 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);
View Full Code Here

    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);
      if (term instanceof GdlFunction) {
        SimpleSentenceForm functionForm = create((GdlFunction) term);
        functions.put(i, functionForm);
        tupleSize += functionForm.getTupleSize();
      } else {
View Full Code Here

    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);
      if (term instanceof GdlFunction) {
        SimpleSentenceForm functionForm = create((GdlFunction) term);
        functions.put(i, functionForm);
        tupleSize += functionForm.getTupleSize();
      } else {
View Full Code Here

    }
    if (sentence.arity() != arity) {
      return false;
    }
    for (int i = 0; i < sentence.arity(); i++) {
      GdlTerm term = sentence.get(i);
      if (functions.containsKey(i) && !(term instanceof GdlFunction)) {
        return false;
      } else if (term instanceof GdlFunction) {
        if (!functions.containsKey(i)) {
          return false;
View Full Code Here

    }
    if (function.arity() != arity) {
      return false;
    }
    for (int i = 0; i < function.arity(); i++) {
      GdlTerm term = function.get(i);
      if (functions.containsKey(i) && !(term instanceof GdlFunction)) {
        return false;
      } else if (term instanceof GdlFunction) {
        if (!functions.containsKey(i)) {
          return false;
View Full Code Here

TOP

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

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.