public abstract class PropositionalFunction
extends java.lang.Object
isTrue(OOState, String...)
, which takes an input state,
identifiers to one or more objects in the state, and returns true or false depending on whether the relationship
of the object arguments this propositional function evaluates are satisfied.
isTrue(OOState, String...)
method can be evaluated, use the allGroundings(OOState)
method, which takes as input an OOState
, and detemrines
which combinations of objects in the state can be applied to this object's typed parameters. The returned list will be a list of
GroundedProp
objects, where each GroundedProp
object contains a reference to this PropositionalFunction
and a list of the object reference on which to evaluate it. Similarly, if you want all possible groundings for a list of different
PropositionalFunction
objects, you can use the static allGroundingsFromList(List, OOState)
method, which
calls the allGroundings(OOState)
method on each of the PropositionalFunction
objects in the list, and concatenates
their results into a single List of GroundedProp
objects.
allGroundings(OOState)
method, so that different groundings that necessarily have the same value will only have
one of the groundings included in the returned list.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
name |
protected java.lang.String[] |
parameterClasses |
protected java.lang.String[] |
parameterOrderGroup |
Constructor and Description |
---|
PropositionalFunction(java.lang.String name,
java.lang.String[] parameterClasses)
Initializes a propositional function with the given name and parameter object classes.
|
PropositionalFunction(java.lang.String name,
java.lang.String[] parameterClasses,
java.lang.String[] parameterOrderGroup)
Initializes a propositional function with the given name, parameter object classes, and the parameter order groups of the parameters.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<GroundedProp> |
allGroundings(OOState s)
Returns all possible groundings of this
PropositionalFunction for the given State |
static java.util.List<GroundedProp> |
allGroundingsFromList(java.util.List<PropositionalFunction> pfs,
OOState s)
Returns all possible groundings for all of the
PropositionalFunction s in the provided list for the given State . |
boolean |
equals(java.lang.Object obj) |
static PropositionalFunction |
findPF(java.util.List<PropositionalFunction> pfs,
java.lang.String pfName)
Used to retrieve a
PropositionalFunction with a specified name from a list of them. |
java.lang.String |
getName()
Returns the name of this propositional function.
|
java.lang.String[] |
getParameterClasses()
Returns the object classes of the parameters for this propositional function
|
java.lang.String[] |
getParameterOrderGroups()
Returns the parameter order group names for the parameters of this propositional function.
|
int |
hashCode() |
protected void |
init(java.lang.String name,
java.lang.String[] parameterClasses,
java.lang.String[] parameterOrderGroup) |
abstract boolean |
isTrue(OOState s,
java.lang.String... params)
Returns whether the propositional function is true for the given state with the given parameters
This version is preferred to the comma delimited version.
|
boolean |
someGroundingIsTrue(OOState s)
|
java.lang.String |
toString() |
protected java.lang.String name
protected java.lang.String[] parameterClasses
protected java.lang.String[] parameterOrderGroup
public PropositionalFunction(java.lang.String name, java.lang.String[] parameterClasses)
name
- the name of the propositional functionparameterClasses
- an array of strings specifying the name of object classes that the parameters must satisfy.public PropositionalFunction(java.lang.String name, java.lang.String[] parameterClasses, java.lang.String[] parameterOrderGroup)
name
- the name of the propositional functionparameterClasses
- an array of strings specifying the name of object classes that the parameters must satisfy.parameterOrderGroup
- an array of strings specifying order group names for the parametersprotected final void init(java.lang.String name, java.lang.String[] parameterClasses, java.lang.String[] parameterOrderGroup)
public final java.lang.String getName()
public final java.lang.String[] getParameterClasses()
public final java.lang.String[] getParameterOrderGroups()
public abstract boolean isTrue(OOState s, java.lang.String... params)
s
- the state that is being checkedparams
- the parameters being passed in to the propositional functionpublic java.util.List<GroundedProp> allGroundings(OOState s)
PropositionalFunction
for the given State
s
- the State
in which all groundings will be returnedList
of all possible groundings of this PropositionalFunction
for the given State
public boolean someGroundingIsTrue(OOState s)
s
- the State
to test.GroundedProp
for the provided State
that is in true in the State
; false otherwise.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static java.util.List<GroundedProp> allGroundingsFromList(java.util.List<PropositionalFunction> pfs, OOState s)
PropositionalFunction
s in the provided list for the given State
.pfs
- The list of PropositionalFunction
s for which all groundings will be returned.s
- the State
in which the groundings should be produced.List
of all possible groundings for all of the PropositionalFunction
s in the provided list for the given State
public static PropositionalFunction findPF(java.util.List<PropositionalFunction> pfs, java.lang.String pfName)
PropositionalFunction
with a specified name from a list of them.pfs
- The list of PropositionalFunction
objects to search.pfName
- The name of the PropositionalFunction
PropositionalFunction
with the name or null if it does not exist