Package graphplan.flyweight

Examples of graphplan.flyweight.OperatorFactory


   * @return        The minimum set of propositions that must be true before execution
   */
  public List<Proposition> getPlanPreconditions(List<String> plan, DomainDescription description) {
    // XXX This variable has been placed here to give us a slight speed up and to ease debug
    // XXX But this might not be a good idea if we try and change the singleton at runtime
    OperatorFactory operatorFactory = OperatorFactory.getInstance();
   
    for(Iterator<Operator> iter = description.getOperators().iterator(); iter.hasNext(); ) {
      try {
        //OperatorFactory.getInstance().addOperatorTemplate(iter.next());
        operatorFactory.addOperatorTemplate(iter.next());
      } catch (OperatorFactoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
   
    Operator concreteOperators[] = new Operator[plan.size()];
   
    //First, get operator instances corresponing to the operator invocations
    //in the parameter
    for (int i = 0; i < concreteOperators.length; i++) {
      try {
        //concreteOperators[i] = OperatorFactory.getInstance().getOperator(plan.get(i));
        concreteOperators[i] = operatorFactory.getOperator(plan.get(i));
      } catch (OperatorFactoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
View Full Code Here


  public LevelGeneratorImpl(Map<String, Set<String>> types, Map<String, List<String>> parameterTypes){
    this.types = types;
    this.parameterTypes = parameterTypes;
    this.usingTypes = true;
    // Felipe: Moved the code here
    OperatorFactory opFactory = OperatorFactory.getInstance();
    opFactory.setTypes(this.types);
    opFactory.setParameterTypes(this.parameterTypes);
  }
View Full Code Here

    opFactory.setParameterTypes(this.parameterTypes);
  }
 
  public LevelGeneratorImpl(){
    if (usingTypes) {
      OperatorFactory opFactory = OperatorFactory.getInstance();
      opFactory.setTypes(this.types);
      opFactory.setParameterTypes(this.parameterTypes);
    }   
  }
View Full Code Here

   */
  @Override
  public ActionLevel createNextActionLevel(PropositionLevel propositionLevel) throws PlanningGraphException {
    final ActionLevel actionLevel = new ActionLevel();
   
    final OperatorFactory opFactory = OperatorFactory.getInstance();

    final HashSet<Operator> opTemplateSet = new HashSet<Operator>();
    final Set<Operator> opSet = new HashSet<Operator>();
    final ArrayList<Proposition> preconds = new ArrayList<Proposition>();
   
    //TODO Change this to scan by operator rather than by proposition
   
    // For every proposition
    for (Proposition proposition : propositionLevel) {
      final List<Operator> templates;
      //Gather potential operator templates
      templates = opFactory.getRequiringOperatorTemplates(proposition);
      opTemplateSet.addAll(templates);
      //Add all noops
      opSet.add(opFactory.getNoop(proposition));
      //And prepare the list of preconditons for later
      preconds.add(proposition);
    }
   
    // XXX Why the hell do we use a null parameter here?
    opTemplateSet.addAll(opFactory.getRequiringOperatorTemplates(null));

    /*for (Proposition proposition : propositionLevel) {
      preconds.add(proposition);
    }*/
   
    //Piece of crap algorithm used before has been replaced by this call
   
    try {
      opSet.addAll(opFactory.getAllPossibleInstantiations(new ArrayList<Operator>(opTemplateSet), preconds));
    } catch (OperatorFactoryException e) {
      throw new PlanningGraphException(e.getMessage(),propositionLevel.getIndex()+1);
    }
   
    for (Operator operator : opSet) {
View Full Code Here

  @SuppressWarnings("rawtypes")
  @Override
  public ActionLevel createNextActionLevel(PropositionLevel propositionLevel, GraphLevel initialState) throws PlanningGraphException {
    final ActionLevel actionLevel = new ActionLevel();
   
    final OperatorFactory opFactory = OperatorFactory.getInstance();

    final HashSet<Operator> opTemplateSet = new HashSet<Operator>();
    final Set<Operator> opSet = new HashSet<Operator>();
    final ArrayList<Proposition> preconds = new ArrayList<Proposition>();
   
    // For every proposition
    for (Proposition proposition : propositionLevel) {
      final List<Operator> templates;
      //Gather potential operator templates
      templates = opFactory.getRequiringOperatorTemplates(proposition);
      opTemplateSet.addAll(templates);
      //Add all noops
      opSet.add(opFactory.getNoop(proposition));
      //And prepare the list of preconditons for later
      preconds.add(proposition);
    }
   
    opTemplateSet.addAll(opFactory.getRequiringOperatorTemplates(null));

    try {
      if(this.isUsingTypes())  {
        opFactory.setTypes(this.getTypes());
        opFactory.setParameterTypes(this.getParameterTypes());
        opSet.addAll(opFactory.getAllPossibleInstantiations(new ArrayList<Operator>(opTemplateSet), preconds, initialState));
      } else opSet.addAll(opFactory.getAllPossibleInstantiations(new ArrayList<Operator>(opTemplateSet), preconds));
    } catch (OperatorFactoryException e) {
      throw new PlanningGraphException(e.getMessage(),propositionLevel.getIndex()+1);
    }
   
    for (Operator operator : opSet) {
View Full Code Here

    this.mutexesTable.put(op1.getFunctor(), mutexOp);
  }

  private Set<Operator> getNoops(List<Operator> operators){
    Set<Operator> noops = new HashSet<Operator>();
    OperatorFactory opFac = OperatorFactory.getInstance();
   
    for (Operator operator : operators) {
      for (Proposition effect : operator.getEffects()) {
        noops.add(opFac.getNoop(effect));
      }
      for (Proposition precond : operator.getPreconds()) {
        noops.add(opFac.getNoop(precond));
      }
    }
    return noops;
  }
View Full Code Here

    initialState.addProposition(proposition);
    Proposition proposition2 = PropositionFactory.getInstance()
        .getProposition("~at(a)");
    initialState.addProposition(proposition2);

    OperatorFactory operatorFactory = OperatorFactory.getInstance();
    Operator operTemplate = operatorFactory.createOperatorTemplate("move(A,B)",
        new String[] { "~at(B)", "at(A)" },
        new String[] { "at(B)", "~at(A)" });
   
    operatorFactory.addOperatorTemplate(operTemplate);
   
    planningGraph = new PlanningGraph(initialState);
   
    ActionLevel actionLevel = new ActionLevel();
    Operator operator = null;
View Full Code Here

TOP

Related Classes of graphplan.flyweight.OperatorFactory

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.