Package graphplan.graph

Examples of graphplan.graph.PropositionLevel


  }
 
  @SuppressWarnings("rawtypes")
  @Override
  public void expandGraph() throws PlanningGraphException {
    PropositionLevel lastLevel = (PropositionLevel) getLastGraphLevelCwa();
    //First we create a new action level from the last proposition level
   
    PropositionLevel initialState = (PropositionLevel) this.getGraphLevel(0);
    int initialStateSize = initialState.size();
    ActionLevel actionLevel = this.actionLevelGeneratorCwa.createNextActionLevel(lastLevel, initialState);
   
    if(initialStateSize != initialState.size()) {
      logger.info("-> Initial State was changed: Maintenance Actions and Mutexes from Level 0 until current Level");
      this.graphLevels = new ArrayList<GraphLevel>();
      this.graphLevels.add(initialState);
      this.closedWorldAssumption = true;
      this.expandGraph();
    } else {
      this.addGraphLevel(actionLevel);
      this.setIndexForOperators(actionLevel);
      //Then we add the action mutexes for these actions
      this.mutexGenerator.addActionMutexes(lastLevel, actionLevel);
      //And then add the subsequent proposition level
      PropositionLevel propositionLevel = this.propositionLevelGenerator.createNextPropositionLevel(actionLevel);
      this.addGraphLevel(propositionLevel);
      this.setIndexForPropositions(propositionLevel);
      //Finally adding the proposition mutexes
      this.mutexGenerator.addPropositionMutexes(actionLevel, propositionLevel);
    }
View Full Code Here


   * @return
   * @throws PlanningGraphException
   * @throws OperatorFactoryException
   */
  public PlanResult plan(DomainDescription domainDescription) throws PlanningGraphException, OperatorFactoryException {
    PropositionLevel initialLevel = new PropositionLevel();
    initialLevel.addPropositions(domainDescription.getInitialState());
    this.solutionExtraction = new SolutionExtractionVisitor(domainDescription.getGoalState());
   
    /*Closed World Assumption - Simple Implementation by goals*/
//    for(Proposition g: domainDescription.getGoalState()){
//      if(!initialLevel.hasProposition(g)){
View Full Code Here

   * @throws PlanningGraphException
   * @throws OperatorFactoryException
   * @throws TimeoutException
   */
  public PlanResult plan(DomainDescription domainDescription, long timeout) throws PlanningGraphException, OperatorFactoryException, TimeoutException {
    PropositionLevel initialLevel = new PropositionLevel();
    initialLevel.addPropositions(domainDescription.getInitialState());
    this.solutionExtraction = new TimeoutSolutionExtractionVisitor(domainDescription.getGoalState());
    ((TimeoutSolutionExtractionVisitor)solutionExtraction).setTimeout(timeout);
   
    this.planningGraph = new PlanningGraph(initialLevel, new StaticMutexesTable(new ArrayList<Operator>(domainDescription.getOperators())));
    OperatorFactory.getInstance().resetOperatorTemplates();
View Full Code Here

        e.printStackTrace();
      }
    }
   
    //Then Create the planning graph with an empty initial state
    PlanningGraph graph = new PlanningGraph(new PropositionLevel());
    //And populate it with action levels and proposition levels containing the obvious
    //preconditions from the subsequent action level
    for (int i = 0; i < concreteOperators.length; i++) {
      //We always assume our graph has a proposition level as its last level
      PropositionLevel propositionLevel = (PropositionLevel) graph.getGraphLevel(graph.size()-1);
      //into which we add the preconditions for this action
      propositionLevel.addPropositions(concreteOperators[i].getPreconds());
      //We then create an action level to contain this action
      ActionLevel actionLevel = new ActionLevel();
      actionLevel.addAction(concreteOperators[i]);
      graph.addGraphLevel(actionLevel);
      //And create another proposition level for its effects
      PropositionLevel propositionLevel2 = new PropositionLevel();
      propositionLevel2.addPropositions(concreteOperators[i].getEffects());
     
      graph.addGraphLevel(propositionLevel2);
    }
   
    //Then walk the graph backwards propagating the preconditions that were not generated
    //by the previous action level using noops
    for(int i = graph.size()-1; i > 0; i=i-2) {
      //We need to get the proposition levels surrounding our action level
      //As in: precond <- action <- effect
      PropositionLevel effectLevel = (PropositionLevel) graph.getGraphLevel(i);
      PropositionLevel precondLevel = (PropositionLevel) graph.getGraphLevel(i-2);
      ActionLevel actionLevel = (ActionLevel) graph.getGraphLevel(i-1);
      //Then see if each proposition in the effectLevel is connected by some action
      //to the precondLevel
      for (Iterator<Proposition> iter = effectLevel.getPropositions(); iter.hasNext();) {
        Proposition proposition = iter.next();
        //If no action is connected to the effect level
        if(actionLevel.getGeneratingActions(proposition).size() == 0) {
          //We need to propagate this action to the previous level
          actionLevel.addNoop(proposition);
          precondLevel.addProposition(proposition);
        }
      }
    }
   
    //this last bit looks rather nasty, I should review this when time allows
    PropositionLevel level = (PropositionLevel) graph.getGraphLevel(0);
    List<Proposition> planPreconditions = new ArrayList<Proposition>(level.size());
   
    for (Iterator<Proposition> iter = level.getPropositions(); iter.hasNext();) {
      planPreconditions.add(iter.next());
    }

    return planPreconditions;
  }
View Full Code Here

    return actionLevel;
  }
 
  @Override
  public PropositionLevel createNextPropositionLevel(ActionLevel actionLevel) throws PlanningGraphException {
    PropositionLevel propositionLevel = new PropositionLevel();
    for (Operator operator : actionLevel) {
      propositionLevel.addPropositions(operator.getEffects());
    }
    return propositionLevel;
  }
View Full Code Here

      //of actions to the support action stack to be
      //used in the iteration of the proposition level
      boolean planFound = graphLevel.getPrevLevel().accept(this);
      return planFound;
    } else {
      PropositionLevel propositionLevel = (PropositionLevel) graphLevel;
      Set<Proposition> subGoals = new TreeSet<Proposition>(subGoalStack.peek());
      //If the goals are possible in this level
      if(propositionLevel.goalsPossible(subGoals)){
        //Then push a set of potential actions for them
        //And try to fill this up with operators
        supportActionStack.push(new TreeSet<Operator>());
        logger.fine("At level "+propositionLevel.getIndex()+", trying to achieve "+subGoalStack.peek());
        boolean planFound = this.visitPropositionLevel(propositionLevel, subGoals);
        if(!planFound) {
          this.supportActionStack.pop();
        }
        return planFound;
View Full Code Here

  private PropositionLevel initialState = null;

  @Before
  public void setUp() throws Exception {
    initialState = new PropositionLevel();
    Proposition proposition = PropositionFactory.getInstance()
        .getProposition("at(a)");
    initialState.addProposition(proposition);
    Proposition proposition2 = PropositionFactory.getInstance()
        .getProposition("~at(a)");
View Full Code Here

   * @param goals
   * @return
   */
  public boolean goalsPossible(List<Proposition> goals, int level) {
    if (graphLevels.get(level).isPropositionLevel()) {
      PropositionLevel propositionLevel = (PropositionLevel) this.graphLevels.get(level);
      return propositionLevel.goalsPossible(goals);
    } else {
      return false;
    }
  }
View Full Code Here

   * level.
   *
   */
  public void expandGraph() throws PlanningGraphException {
    if (getLastGraphLevel().isPropositionLevel()) {
      PropositionLevel lastLevel = (PropositionLevel) getLastGraphLevel();
      //First we create a new action level from the last proposition level
      ActionLevel actionLevel = actionLevelGenerator.createNextActionLevel(lastLevel);
      this.addGraphLevel(actionLevel);
      this.setIndexForOperators(actionLevel);
      //Then we add the action mutexes for these actions
      this.mutexGenerator.addActionMutexes(lastLevel, actionLevel);
      //And then add the subsequent proposition level
      PropositionLevel propositionLevel = propositionLevelGenerator.createNextPropositionLevel(actionLevel);
      this.addGraphLevel(propositionLevel);
      this.setIndexForPropositions(propositionLevel);
      //Finally adding the proposition mutexes
      this.mutexGenerator.addPropositionMutexes(actionLevel, propositionLevel);
    } else {
View Full Code Here

    } else {
      if(graphLevel.getPrevLevel() == null) {
        //We hit the first level, return
        return true;
      }
      PropositionLevel propositionLevel = (PropositionLevel) graphLevel;
      Set<Proposition> subGoals = new TreeSet<Proposition>(this.subGoalStack.peek());
     
      //First, check the no goods table
      if(this.memoizationTable.isNoGood(this.subGoalStack.peek(), propositionLevel.getIndex())) {
        //And not even creep if the goals are no good
        return false;
      }
     
      //Then check if the goals are conceptually possible
      //If the goals are possible in this level
      if(propositionLevel.goalsPossible(subGoals)){
        //Then push a set of potential actions for them
        //And try to fill this up with operators
        //supportActionStack.push(new LinkedHashSet<Operator>());
        //logger.fine("At level "+propositionLevel.getIndex()+", trying to achieve "+subGoalStack.peek());
       
View Full Code Here

TOP

Related Classes of graphplan.graph.PropositionLevel

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.