ai.planning.strips
Class Goal

java.lang.Object
  extended by ai.planning.strips.Goal
All Implemented Interfaces:
Goal<ai.krr.fol.Atom>

public class Goal
extends java.lang.Object
implements Goal<ai.krr.fol.Atom>

A goal is defined as a set of Atoms in propositional planning. Implicitly defined is the set of goal states which are exactly those WorldStates in which the Goal is satisfied.

Author:
Gerhard Wickler

Nested Class Summary
protected  class Goal.UgConditions
           
 
Field Summary
protected  java.util.Set<ai.krr.fol.Atom> negativeGoals
          the sets of Atoms that define this Goal
protected  java.util.Set<ai.krr.fol.Atom> positiveGoals
          the sets of Atoms that define this Goal
 
Constructor Summary
Goal(java.util.Collection<ai.krr.fol.Literal> goalLits)
           This constructor creates a new Goal in which the given positive Literals are to be achieved and the given negative Literals must not hold.
Goal(java.util.Set<ai.krr.fol.Atom> posG, java.util.Set<ai.krr.fol.Atom> negG)
           This constructor creates a new Goal in which the Atoms from the first given Set are to be achieved and the Atoms from the second given Set must not hold.
 
Method Summary
 Goal clone()
           This function creates a copy of this Goal.
 boolean equals(Goal goal)
           
 boolean equals(java.lang.Object obj)
           This function tests whether this and the given Goal are equal.
 java.util.Set<ai.krr.fol.Atom> getNegativeGoals()
           This function returns the set of negative goal conditions that define this Goal.
 java.util.Set<Goal.UgConditions> getPartialSubGoals(ActionType op, Problem p)
           This function computes the regression set of this Goal.
 java.util.Set<ai.krr.fol.Atom> getPositiveGoals()
           This function returns the set of positive goal conditions that define this Goal.
 int hashCode()
           This function returns a hash value for this Goal.
 boolean isRelevant(Action<ai.krr.fol.Atom> action)
           This function tests whether the given Action is relevant for this Goal.
 Goal<ai.krr.fol.Atom> regress(Action<ai.krr.fol.Atom> action)
           This function computes a new Goal that is the result of regressing this Goal through the given Action.
 Goal regress(Action action, Domain domain)
           This function computes a new Goal that is the result of regressing this Goal through the given Action.
 boolean satisfiedIn(WorldState<ai.krr.fol.Atom> state)
           This function tests whether this Goal is achieved in the given state.
 java.lang.String toString()
           This function creates a String representation for this Goal.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

positiveGoals

protected java.util.Set<ai.krr.fol.Atom> positiveGoals
the sets of Atoms that define this Goal


negativeGoals

protected java.util.Set<ai.krr.fol.Atom> negativeGoals
the sets of Atoms that define this Goal

Constructor Detail

Goal

public Goal(java.util.Set<ai.krr.fol.Atom> posG,
            java.util.Set<ai.krr.fol.Atom> negG)

This constructor creates a new Goal in which the Atoms from the first given Set are to be achieved and the Atoms from the second given Set must not hold. All the given Atoms must be ground and function-free.

Parameters:
posG - the Atoms that must hold for this Goal to be achieved
negG - the Atoms that must not hold for this Goal to be achieved

Goal

public Goal(java.util.Collection<ai.krr.fol.Literal> goalLits)

This constructor creates a new Goal in which the given positive Literals are to be achieved and the given negative Literals must not hold. All the given Atoms must be ground and function-free.

Parameters:
goals - the goal conditions to be achieved in some WorldState
Method Detail

clone

public Goal clone()

This function creates a copy of this Goal. Subsequent modifications will not change the original Goal.

Overrides:
clone in class java.lang.Object
Returns:
a new Goal with the same Atoms

isRelevant

public boolean isRelevant(Action<ai.krr.fol.Atom> action)

This function tests whether the given Action is relevant for this Goal. An Action is relevant for this Goal iff:

Specified by:
isRelevant in interface Goal<ai.krr.fol.Atom>
Parameters:
action - the Action to be tested for relevance
Returns:
whether the given Action may contribute to achieving this Goal

regress

public Goal<ai.krr.fol.Atom> regress(Action<ai.krr.fol.Atom> action)

This function computes a new Goal that is the result of regressing this Goal through the given Action. The given Action should be relevant.

The new Goal is computed by first removing the positve effects from the positve goal and the negative effects from the negative goal. Then the positive and negative preconditions are added to the positive and negative goals respectively. Note that static preconditions will be added to the goal here as there is no way to determine whether a relation is static in the current context.

Specified by:
regress in interface Goal<ai.krr.fol.Atom>
Parameters:
action - the (relevant) Action used for regression in this Goal
Returns:
a new Goal that is the result of the reverse state transition function applied to this Goal

satisfiedIn

public boolean satisfiedIn(WorldState<ai.krr.fol.Atom> state)

This function tests whether this Goal is achieved in the given state.

Specified by:
satisfiedIn in interface Goal<ai.krr.fol.Atom>
Parameters:
state - the WorldState in which this Goal may be satisfied
Returns:
whether all the goal conditions are satisfied in the state

getPositiveGoals

public java.util.Set<ai.krr.fol.Atom> getPositiveGoals()

This function returns the set of positive goal conditions that define this Goal.

Specified by:
getPositiveGoals in interface Goal<ai.krr.fol.Atom>
Returns:
the set of Atoms to be achieved for this Goal

getNegativeGoals

public java.util.Set<ai.krr.fol.Atom> getNegativeGoals()

This function returns the set of negative goal conditions that define this Goal.

Specified by:
getNegativeGoals in interface Goal<ai.krr.fol.Atom>
Returns:
the set of Atoms that must not be achieved for this Goal

regress

public Goal regress(Action action,
                    Domain domain)

This function computes a new Goal that is the result of regressing this Goal through the given Action. The given Action should be relevant.

The new Goal is computed by first removing the positve effects from the positve goal and the negative effects from the negative goal. Then the positive and negative preconditions are added to the positive and negative goals respectively. Note, however, that static preconditions will not be added to the goal!

Parameters:
action - the (relevant) Action used for regression in this Goal
domain - the Domain in which this Goal is defined
Returns:
a new Goal that is the result of the reverse state transition function applied to this Goal

getPartialSubGoals

public java.util.Set<Goal.UgConditions> getPartialSubGoals(ActionType op,
                                                           Problem p)

This function computes the regression set of this Goal. If a WorldState satisfies any one of these sub-goals then a state in which this Goal is satisfied is reachable. The given domain defines the ActionTypes that may be used to generate the sub-goals.

Parameters:
domain - the Domain defining the possible ActionTypes
Returns:
the Set of all the sub-goals that may lead to this Goal being achieved

equals

public boolean equals(java.lang.Object obj)

This function tests whether this and the given Goal are equal. It returns true iff the two Goals contain exactly the same positive and negative Atoms.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object this Goal is compared to
Returns:
whether the same Atoms must/must not hold in both Goals

equals

public boolean equals(Goal goal)

hashCode

public int hashCode()

This function returns a hash value for this Goal.

Overrides:
hashCode in class java.lang.Object
Returns:
an integer that can be used for hashing

toString

public java.lang.String toString()

This function creates a String representation for this Goal. This is simply the String representing the contained Set of Atoms.

Overrides:
toString in class java.lang.Object
Returns:
the String representing this Goal