Package graphplan.domain.jason

Examples of graphplan.domain.jason.PropositionImpl


        if(init instanceof NotAtomicFormula){
          p = (NotAtomicFormula) init;
          negated = true;
        } else p = (AtomicFormula) init;
        PropositionImpl proposition = new PropositionImpl(!negated, p.getPredicate());
        Iterator variables = p.iterator();
       
        List<Term> terms = new ArrayList<Term>();
        while(variables.hasNext()){
          Constant var = (Constant) variables.next();
          Atom term = new Atom(var.getImage());
          terms.add(term);
         
          Set<String> setVar = this.types.get(var.getTypeSet().toString());
          setVar.add(var.getImage());
        }
       
        proposition.addTerms(terms);
        initialState.add(proposition);
      }
     
      logger.finest("\n--> Goal\n");
      logger.finest(this.pddlObject.getGoal().toString());
View Full Code Here


                propositionImpls.addAll(getPropositionFromDomainExp(and, false));
              }
              break;
          case ATOMIC_FORMULA:
              AtomicFormula p = (AtomicFormula) exp;
        PropositionImpl proposition = new PropositionImpl(new LiteralImpl(!negated, p.getPredicate()));
       
        Iterator pddlTerms = p.iterator();
       
        List<Term> terms = new ArrayList<Term>();
        while(pddlTerms.hasNext()){
          pddl4j.exp.term.Term var = (pddl4j.exp.term.Term) pddlTerms.next();
          VarTerm term = new VarTerm(var.getImage().replace("?", "").toUpperCase());
          terms.add(term);
         
          Set<String> setVar = this.types.get(var.getTypeSet().toString());
         
          for(Constant c: this.pddlObject.getTypedDomain(var.getTypeSet())){
            if(setVar == null){
              setVar = new HashSet<String>();
              setVar.add(c.toString());
              this.types.put(var.getTypeSet().toString(), setVar);
            } else setVar.add(c.toString());
          }
        }
       
        proposition.addTerms(terms);
        propositionImpls.add(proposition);
       
        break;
          case NOT:
              NotExp notExp = (NotExp) exp;
View Full Code Here

                propositionImpls.addAll(getPropositionFromProblemExp(and, false));
              }
              break;
          case ATOMIC_FORMULA:
              AtomicFormula p = (AtomicFormula) exp;
        PropositionImpl proposition = new PropositionImpl(new LiteralImpl(!negated, p.getPredicate()));
       
        Iterator constants = p.iterator();
       
        List<Term> terms = new ArrayList<Term>();
        while(constants.hasNext()){
          Constant con = (Constant) constants.next();
          Atom term = new Atom(con.getImage());
          terms.add(term);
         
          Set<String> setCon = this.types.get(con.getTypeSet().toString());
         
          for(Constant c: this.pddlObject.getTypedDomain(con.getTypeSet())){
            if(setCon == null){
              setCon = new HashSet<String>();
              setCon.add(c.toString());
              this.types.put(con.getTypeSet().toString(), setCon);
            } else setCon.add(c.toString());
          }
        }
       
        proposition.addTerms(terms);
        propositionImpls.add(proposition);
       
        break;
          case NOT:
              NotExp notExp = (NotExp) exp;
View Full Code Here

   * @param propositionSignature
   * @return
   */
  public final Proposition getProposition(String propositionSignature) {
    if(!propositionInstances.containsKey(propositionSignature)) {
      PropositionImpl proposition = new PropositionImpl(propositionSignature);
      propositionInstances.put(propositionSignature, proposition);
      return proposition;
    }
    return propositionInstances.get(propositionSignature);
  }
View Full Code Here

    Structure oper = Structure.parse(signature);
    ArrayList<Proposition> precondProps = new ArrayList<Proposition>(preconds.length);
    ArrayList<Proposition> effectProps = new ArrayList<Proposition>(effects.length);
   
    for (int i = 0; i < preconds.length; i++) {
      PropositionImpl precond = new PropositionImpl(preconds[i]);
      precondProps.add(precond);
    }
   
    for (int i = 0; i < effects.length; i++) {
      PropositionImpl effect = new PropositionImpl(effects[i]);
      effectProps.add(effect);
    }
   
    OperatorImpl operator = new OperatorImpl(oper, precondProps, effectProps);
   
View Full Code Here

            } else if(!ops1.contains(op.getFunctor())) ops1.add(op.getFunctor());
          }
  }

  private int getIndexProposition(Proposition p, List<Term> terms, boolean positive) {
    PropositionImpl newP = new PropositionImpl(positive, p.getFunctor());
    newP.setTerms(terms);
    if(!existsProposition(newP)) {
      this.propositions.add(newP);
      return this.propositions.indexOf(newP);
    }
   
View Full Code Here

        List<Proposition> templatePreconds = template.getPreconds();
        List<Proposition> concretePreconds = new ArrayList<Proposition>(templatePreconds.size());
        //And apply the unifier to them
        for (Iterator iter = templatePreconds.iterator(); iter
            .hasNext();) {
          PropositionImpl precond = (PropositionImpl) iter.next();
          Literal literal = new LiteralImpl(precond);
          literal.apply(un);
          PropositionImpl concretePrecond = (PropositionImpl)propositionFactory.getProposition(literal.toString());
          // XXX Uncomment the code to debug operator instantiation, it is removed to avoid wasting time here
//          if(!concretePrecond.isGround()) {
//            //throw new OperatorFactoryException("We have a non-concrete precond in operator "+signature+": "+concretePrecond);
//            System.err.println("We have a non-concrete precond in operator "+signature+": "+concretePrecond);
//          }
          concretePreconds.add(concretePrecond);
        }
       
        List<Proposition> templateEffects = template.getEffects();
        List<Proposition> concreteEffects = new ArrayList<Proposition>(templateEffects.size());
       
        for (Iterator iter = templateEffects.iterator(); iter
            .hasNext();) {
          PropositionImpl effect = (PropositionImpl) iter.next();
          Literal literal = new LiteralImpl(effect);
          literal.apply(un);
          PropositionImpl concreteEffect = (PropositionImpl)propositionFactory.getProposition(literal.toString());
          // XXX Uncomment the code to debug operator instantiation, it is removed to avoid wasting time here
//          if(!concreteEffect.isGround()) {
//            //throw new OperatorFactoryException("We have a non-concrete effect in operator "+signature+": "+concreteEffect);
//            System.err.println("We have a non-concrete effect in operator "+signature+": "+concreteEffect);
//          }
View Full Code Here

          } else {
            System.err.println("Big mess!");
          }
         
          for(Proposition proposition : copy.getPreconds()) {
            PropositionImpl realProp = (PropositionImpl) proposition;
            realProp.apply(unifier);
            addInstance = preconds.contains(proposition);
           
            if(proposition.negated() && !addInstance) {
              /*Closed World Assumption*/
              if(initialState != null && initialState.isPropositionLevel()){
                PropositionLevel initial = (PropositionLevel) initialState;
                PropositionImpl positiveProposition = new PropositionImpl(proposition.getFunctor());
                positiveProposition.setTerms(proposition.getTerms());

                if(!initial.hasProposition(positiveProposition)){
                  initial.addProposition(proposition);
                }
              }
View Full Code Here

TOP

Related Classes of graphplan.domain.jason.PropositionImpl

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.