|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.jsl.AbstractSearchNode
Adapter of the search library to the domain the search is performed in. You will have to subclass
this class to at least provide information about the depth and the breadth of a node in a the search
graph. Additionally, the cost associated to a specific node - which by default results to its depth -
and the estimated rest cost - default is 0 - can be overloaded.
The most important is to implement mehod is expand()
. Only the domain knows what nodes
may follow another one, so you will have to implement this method accordingly.
Finally, getPath()
will have to be implemented to return the path from the seed to a this search node.
While this path has to be recorded inside the expand()
method you can use
linkForward(java.lang.Object, net.sourceforge.jsl.SearchNode)
and linkBackward(java.lang.Object, net.sourceforge.jsl.SearchNode)
as helper methods.
To actually spit out the path you getPath()
implementation can use
getFirstPathIn()
and getFirstPathOut()
.
Which of the methods to use depends on what type the seed of the search is. If it is a leaf and you simply
search the root your domain, you should use linkBackward(java.lang.Object, net.sourceforge.jsl.SearchNode)
in conjunction with getFirstPathOut()
.
If you start the search with the seed being the root of your domain you should rather use
linkForward(java.lang.Object, net.sourceforge.jsl.SearchNode)
and getFirstPathIn()
.
Constructor Summary | |
AbstractSearchNode()
|
Method Summary | |
boolean |
cutoff()
Indicates if this node should be pruned, i.e. excluded from further calculations. |
static void |
dumpPath(List path)
Helper method to dump a path to stdout. |
static void |
dumpPath(PrintStream ps,
List path)
Helper method to dump a path to the specified print stream. |
boolean |
equals(Object o)
|
abstract Collection |
expand()
Expands this node and returns the search nodes following this one. |
abstract int |
getBreadth()
Returns the breadth of this node in the search graph (tree). |
double |
getCost()
Gets the cost it has taken to get to this node. |
abstract int |
getDepth()
Returns the depth of this node in the search graph (tree). |
Object |
getDomainObject()
Gets the domain object associated to this search node. |
double |
getEstimatedRestCost()
Estimates the cost expected to need to reach a goal from this node. |
protected List |
getFirstPathIn()
Returns the first path that leads from this node to the seed of this search while seed is seen as the root of the search. |
protected List |
getFirstPathOut()
Returns the first path that leads from this node to the seed of this search while seed is seen as a leaf of the search. |
Collection |
getIncomingEdges()
Gets all incoming edges. |
Collection |
getOutgoingEdges()
Gets all outgoing edges. |
abstract List |
getPath()
|
int |
hashCode()
|
protected void |
linkBackward(Object edgeDomainObject,
SearchNode previousSearchNode)
Creates a new edge between this node and the specified predecessor. |
protected void |
linkForward(Object edgeDomainObject,
SearchNode nextSearchNode)
Creates a new edge between this node and the specified successor. |
void |
setDomainObject(Object domainObject)
Sets the domain object associated to this search node. |
void |
setIncomingEdges(Collection incomingEdges)
Sets the incoming edges. |
void |
setOutgoingEdges(Collection outgoingEdges)
Sets the outgoing edges. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sourceforge.jsl.SearchNode |
isGoal |
Constructor Detail |
public AbstractSearchNode()
Method Detail |
public static void dumpPath(List path)
public static void dumpPath(PrintStream ps, List path)
public boolean cutoff()
SearchNode
cutoff
in interface SearchNode
true
if this node shall be excluded from further search, false
otherwisepublic abstract int getBreadth()
SearchNode
getBreadth
in interface SearchNode
public double getCost()
SearchNode
getCost
in interface SearchNode
public abstract int getDepth()
SearchNode
getDepth
in interface SearchNode
public double getEstimatedRestCost()
SearchNode
SearchNode.getCost()
. This is needed for
scoring searches like A*
.
getEstimatedRestCost
in interface SearchNode
public abstract Collection expand()
SearchNode
expand
in interface SearchNode
public Object getDomainObject()
SearchNode
getDomainObject
in interface SearchNode
public Collection getIncomingEdges()
SearchNode
getIncomingEdges
in interface SearchNode
SearchEdge
s.public Collection getOutgoingEdges()
SearchNode
getOutgoingEdges
in interface SearchNode
SearchEdge
s.public void setDomainObject(Object domainObject)
SearchNode
setDomainObject
in interface SearchNode
domainObject
- the domain object associated to this search egdepublic void setIncomingEdges(Collection incomingEdges)
SearchNode
setIncomingEdges
in interface SearchNode
incomingEdges
- the unordered collection of all incoming SearchEdge
s.public void setOutgoingEdges(Collection outgoingEdges)
SearchNode
setOutgoingEdges
in interface SearchNode
outgoingEdges
- the unordered collection of all outgoing SearchEdge
s.public String toString()
toString
in class Object
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public abstract List getPath()
protected List getFirstPathIn()
protected List getFirstPathOut()
protected void linkBackward(Object edgeDomainObject, SearchNode previousSearchNode)
edgeDomainObject
- the domain object associated to this search egdepreviousSearchNode
- the predecessing nodeprotected void linkForward(Object edgeDomainObject, SearchNode nextSearchNode)
edgeDomainObject
- the domain object associated to this search egde
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |