Class SMGraphAStarImpl
- java.lang.Object
-
- de.uni_trier.wi2.procake.similarity.impl.SimilarityMeasureImpl
-
- de.uni_trier.wi2.procake.similarity.nest.astar.impl.SMGraphAStarImpl
-
- All Implemented Interfaces:
SMGraphAStar
,SimilarityMeasure
- Direct Known Subclasses:
SMGraphAStarOneImpl
,SMGraphAStarTwoImpl
public abstract class SMGraphAStarImpl extends SimilarityMeasureImpl implements SMGraphAStar
Abstract implementation of the AStar-Similarity Measure.- Author:
- Alexander Stromer, Christian Zeyen
-
-
Field Summary
-
Fields inherited from interface de.uni_trier.wi2.procake.similarity.SimilarityMeasure
COMPONENT, COMPONENT_KEY, LOG_ORDER_NAME_NOT_FOUND
-
Fields inherited from interface de.uni_trier.wi2.procake.similarity.nest.astar.SMGraphAStar
DEFAULT_ALLOW_CASE_ORIENTED_MAPPING, DEFAULT_ALLOW_PRE_INITIALIZATION, DEFAULT_MAX_QUEUE_SIZE, DEFAULT_ONLY_TEST_FOR_EQUALITY, DEFAULT_RETURN_LOCAL_EDGE_SIMILARITIES, DEFAULT_RETURN_LOCAL_NODE_SIMILARITIES, DEFAULT_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description SMGraphAStarImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Similarity
compute(DataObject queryObjectOrig, DataObject caseObjectOrig, SimilarityValuator valuator)
AStarCaseSolution
createInitialSolution(Set<NESTNodeObject> originalCaseNodes, Set<NESTEdgeObject> originalCaseEdges, SimilarityValuator simVal)
Creates an initial CaseSolution-object based on the information given.protected abstract double
estimateSimilarity(AStarCaseSolution newSol, AStarGraphItemMapping newMap)
Estimates the similarity for the remaining items of the queryGraph based on the concrete AStar-implementation.void
expand(AStarCaseSolution toExpand, TreeSet<AStarCaseSolution> solutions, SimilarityValuator simVal)
Expands the most similar solution with one additional queryItem.int
getMaxQueueSize()
Gets the queue size of the AStarSimilaritySet<NESTEdgeObject>
getOriginalQueryEdges()
Set<NESTNodeObject>
getOriginalQueryNodes()
int
getTimeout()
protected void
initHeuristic(AStarCaseSolution sol, SimilarityValuator simVal)
protected void
initializeBasedOn(SimilarityMeasure base)
Initialize measure based on existing instanceboolean
isAllowCaseOrientedMapping()
boolean
isAllowPreInitializationOfSolution()
boolean
isOnlyTestForEquality()
boolean
isReturnLocalEdgeSimilarities()
boolean
isReturnLocalNodeSimilarities()
boolean
isReturnLocalSimilarities()
boolean
isReusable()
boolean
isSimilarityFor(DataClass dataclass, String orderName)
protected abstract NESTGraphItemObject
selectNextItem(AStarCaseSolution toExpand)
Retrieves the next item of the queryGraph based on the concrete AStar-implementation.void
setAllowCaseOrientedMapping(boolean allowCaseOrientedMapping)
void
setAllowPreInitializationOfSolution(boolean allowPreInitializationOfSolution)
void
setMaxQueueSize(int qSize)
Sets the maximum size of the queue that stores the (partial) solutions of the A* algorithm.void
setOnlyTestForEquality(boolean onlyTestForEquality)
void
setOriginalQueryEdges(Set<NESTEdgeObject> originalQueryEdges)
The original set of edges of the query.void
setOriginalQueryNodes(Set<NESTNodeObject> originalQueryNodes)
The original set of nodes of the query.void
setReturnLocalEdgeSimilarities(boolean returnLocalEdgeSimilarities)
void
setReturnLocalNodeSimilarities(boolean returnLocalNodeSimilarities)
void
setReturnLocalSimilarities(boolean returnLocalSimilarities)
void
setTimeout(int timeout)
Sets a timeout in seconds for terminating the computation.-
Methods inherited from class de.uni_trier.wi2.procake.similarity.impl.SimilarityMeasureImpl
getDataClass, getName, initialize, isAggregate, isForceOverride, isInterval, isNumeric, isObject, isSet, isTable, isTaxonomy, isText, setDataClass, setForceOverride, setName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.uni_trier.wi2.procake.similarity.SimilarityMeasure
getDataClass, getName, getSystemName, isForceOverride, setForceOverride
-
-
-
-
Method Detail
-
getOriginalQueryNodes
public Set<NESTNodeObject> getOriginalQueryNodes()
- Specified by:
getOriginalQueryNodes
in interfaceSMGraphAStar
- Returns:
- the originalQueryNodes
-
setOriginalQueryNodes
public void setOriginalQueryNodes(Set<NESTNodeObject> originalQueryNodes)
Description copied from interface:SMGraphAStar
The original set of nodes of the query.- Specified by:
setOriginalQueryNodes
in interfaceSMGraphAStar
- Parameters:
originalQueryNodes
- the originalQueryNodes to set
-
getOriginalQueryEdges
public Set<NESTEdgeObject> getOriginalQueryEdges()
- Specified by:
getOriginalQueryEdges
in interfaceSMGraphAStar
- Returns:
- the originalQueryEdges
-
setOriginalQueryEdges
public void setOriginalQueryEdges(Set<NESTEdgeObject> originalQueryEdges)
Description copied from interface:SMGraphAStar
The original set of edges of the query.- Specified by:
setOriginalQueryEdges
in interfaceSMGraphAStar
- Parameters:
originalQueryEdges
- the originalQueryEdges to set
-
getMaxQueueSize
public int getMaxQueueSize()
Description copied from interface:SMGraphAStar
Gets the queue size of the AStarSimilarity- Specified by:
getMaxQueueSize
in interfaceSMGraphAStar
- Returns:
- The maximum queue size
-
setMaxQueueSize
public void setMaxQueueSize(int qSize)
Description copied from interface:SMGraphAStar
Sets the maximum size of the queue that stores the (partial) solutions of the A* algorithm. If the current queue grows larger than the set maximum, the lowest ranked solutions will be removed. Setting a negative value disables pruning of the queue.- Specified by:
setMaxQueueSize
in interfaceSMGraphAStar
- Parameters:
qSize
- The maximum queue size
-
isReturnLocalNodeSimilarities
public boolean isReturnLocalNodeSimilarities()
- Specified by:
isReturnLocalNodeSimilarities
in interfaceSMGraphAStar
- Returns:
-
setReturnLocalNodeSimilarities
public void setReturnLocalNodeSimilarities(boolean returnLocalNodeSimilarities)
- Specified by:
setReturnLocalNodeSimilarities
in interfaceSMGraphAStar
-
isReturnLocalSimilarities
public boolean isReturnLocalSimilarities()
- Specified by:
isReturnLocalSimilarities
in interfaceSMGraphAStar
- Returns:
-
setReturnLocalSimilarities
public void setReturnLocalSimilarities(boolean returnLocalSimilarities)
- Specified by:
setReturnLocalSimilarities
in interfaceSMGraphAStar
-
isReturnLocalEdgeSimilarities
public boolean isReturnLocalEdgeSimilarities()
- Specified by:
isReturnLocalEdgeSimilarities
in interfaceSMGraphAStar
- Returns:
-
setReturnLocalEdgeSimilarities
public void setReturnLocalEdgeSimilarities(boolean returnLocalEdgeSimilarities)
- Specified by:
setReturnLocalEdgeSimilarities
in interfaceSMGraphAStar
-
isAllowPreInitializationOfSolution
public boolean isAllowPreInitializationOfSolution()
- Specified by:
isAllowPreInitializationOfSolution
in interfaceSMGraphAStar
- Returns:
-
setAllowPreInitializationOfSolution
public void setAllowPreInitializationOfSolution(boolean allowPreInitializationOfSolution)
- Specified by:
setAllowPreInitializationOfSolution
in interfaceSMGraphAStar
-
isAllowCaseOrientedMapping
public boolean isAllowCaseOrientedMapping()
- Specified by:
isAllowCaseOrientedMapping
in interfaceSMGraphAStar
- Returns:
- Whether case-oriented mapping is allowed or not.
-
setAllowCaseOrientedMapping
public void setAllowCaseOrientedMapping(boolean allowCaseOrientedMapping)
- Specified by:
setAllowCaseOrientedMapping
in interfaceSMGraphAStar
- Parameters:
allowCaseOrientedMapping
- flag
-
isOnlyTestForEquality
public boolean isOnlyTestForEquality()
- Specified by:
isOnlyTestForEquality
in interfaceSMGraphAStar
- Returns:
- flag
-
setOnlyTestForEquality
public void setOnlyTestForEquality(boolean onlyTestForEquality)
- Specified by:
setOnlyTestForEquality
in interfaceSMGraphAStar
- Parameters:
onlyTestForEquality
- flag
-
getTimeout
public int getTimeout()
- Specified by:
getTimeout
in interfaceSMGraphAStar
- Returns:
- The timeout for terminating the computation.
-
setTimeout
public void setTimeout(int timeout)
Description copied from interface:SMGraphAStar
Sets a timeout in seconds for terminating the computation. Setting a negative value disables timeout.- Specified by:
setTimeout
in interfaceSMGraphAStar
- Parameters:
timeout
- in seconds for terminating the computation
-
compute
public Similarity compute(DataObject queryObjectOrig, DataObject caseObjectOrig, SimilarityValuator valuator)
- Specified by:
compute
in interfaceSimilarityMeasure
- Returns:
-
expand
public void expand(AStarCaseSolution toExpand, TreeSet<AStarCaseSolution> solutions, SimilarityValuator simVal)
Expands the most similar solution with one additional queryItem. Be sure to set the Fields originalQueryNodes and originalQueryEdges before calling this method.- Parameters:
toExpand
- the solution to expandsolutions
- Complete list of current CaseSolutions for the comparison of a queryGraph with a caseGraph.simVal
-
-
initHeuristic
protected void initHeuristic(AStarCaseSolution sol, SimilarityValuator simVal)
- Parameters:
sol
-simVal
-
-
createInitialSolution
public AStarCaseSolution createInitialSolution(Set<NESTNodeObject> originalCaseNodes, Set<NESTEdgeObject> originalCaseEdges, SimilarityValuator simVal)
Creates an initial CaseSolution-object based on the information given.- Parameters:
originalCaseNodes
-originalCaseEdges
-simVal
-- Returns:
- initial solution object
-
estimateSimilarity
protected abstract double estimateSimilarity(AStarCaseSolution newSol, AStarGraphItemMapping newMap)
Estimates the similarity for the remaining items of the queryGraph based on the concrete AStar-implementation.- Parameters:
newSol
-newMap
-- Returns:
-
selectNextItem
protected abstract NESTGraphItemObject selectNextItem(AStarCaseSolution toExpand)
Retrieves the next item of the queryGraph based on the concrete AStar-implementation.- Parameters:
toExpand
- The item which should be expanded.- Returns:
- Selected item.
-
isSimilarityFor
public boolean isSimilarityFor(DataClass dataclass, String orderName)
- Specified by:
isSimilarityFor
in classSimilarityMeasureImpl
-
isReusable
public boolean isReusable()
- Specified by:
isReusable
in interfaceSimilarityMeasure
- Overrides:
isReusable
in classSimilarityMeasureImpl
- Returns:
- true if the measure is reusable
-
initializeBasedOn
protected void initializeBasedOn(SimilarityMeasure base)
Description copied from class:SimilarityMeasureImpl
Initialize measure based on existing instance- Overrides:
initializeBasedOn
in classSimilarityMeasureImpl
- Parameters:
base
- similarity measure to base on
-
-