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 Similaritycompute(DataObject queryObjectOrig, DataObject caseObjectOrig, SimilarityValuator valuator)AStarCaseSolutioncreateInitialSolution(Set<NESTNodeObject> originalCaseNodes, Set<NESTEdgeObject> originalCaseEdges, SimilarityValuator simVal)Creates an initial CaseSolution-object based on the information given.protected abstract doubleestimateSimilarity(AStarCaseSolution newSol, AStarGraphItemMapping newMap)Estimates the similarity for the remaining items of the queryGraph based on the concrete AStar-implementation.voidexpand(AStarCaseSolution toExpand, TreeSet<AStarCaseSolution> solutions, SimilarityValuator simVal)Expands the most similar solution with one additional queryItem.intgetMaxQueueSize()Gets the queue size of the AStarSimilaritySet<NESTEdgeObject>getOriginalQueryEdges()Set<NESTNodeObject>getOriginalQueryNodes()intgetTimeout()protected voidinitHeuristic(AStarCaseSolution sol, SimilarityValuator simVal)protected voidinitializeBasedOn(SimilarityMeasure base)Initialize measure based on existing instancebooleanisAllowCaseOrientedMapping()booleanisAllowPreInitializationOfSolution()booleanisOnlyTestForEquality()booleanisReturnLocalEdgeSimilarities()booleanisReturnLocalNodeSimilarities()booleanisReturnLocalSimilarities()booleanisReusable()booleanisSimilarityFor(DataClass dataclass, String orderName)protected abstract NESTGraphItemObjectselectNextItem(AStarCaseSolution toExpand)Retrieves the next item of the queryGraph based on the concrete AStar-implementation.voidsetAllowCaseOrientedMapping(boolean allowCaseOrientedMapping)voidsetAllowPreInitializationOfSolution(boolean allowPreInitializationOfSolution)voidsetMaxQueueSize(int qSize)Sets the maximum size of the queue that stores the (partial) solutions of the A* algorithm.voidsetOnlyTestForEquality(boolean onlyTestForEquality)voidsetOriginalQueryEdges(Set<NESTEdgeObject> originalQueryEdges)The original set of edges of the query.voidsetOriginalQueryNodes(Set<NESTNodeObject> originalQueryNodes)The original set of nodes of the query.voidsetReturnLocalEdgeSimilarities(boolean returnLocalEdgeSimilarities)voidsetReturnLocalNodeSimilarities(boolean returnLocalNodeSimilarities)voidsetReturnLocalSimilarities(boolean returnLocalSimilarities)voidsetTimeout(int timeoutSeconds)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:
getOriginalQueryNodesin interfaceSMGraphAStar- Returns:
- the originalQueryNodes
-
setOriginalQueryNodes
public void setOriginalQueryNodes(Set<NESTNodeObject> originalQueryNodes)
Description copied from interface:SMGraphAStarThe original set of nodes of the query.- Specified by:
setOriginalQueryNodesin interfaceSMGraphAStar- Parameters:
originalQueryNodes- the originalQueryNodes to set
-
getOriginalQueryEdges
public Set<NESTEdgeObject> getOriginalQueryEdges()
- Specified by:
getOriginalQueryEdgesin interfaceSMGraphAStar- Returns:
- the originalQueryEdges
-
setOriginalQueryEdges
public void setOriginalQueryEdges(Set<NESTEdgeObject> originalQueryEdges)
Description copied from interface:SMGraphAStarThe original set of edges of the query.- Specified by:
setOriginalQueryEdgesin interfaceSMGraphAStar- Parameters:
originalQueryEdges- the originalQueryEdges to set
-
getMaxQueueSize
public int getMaxQueueSize()
Description copied from interface:SMGraphAStarGets the queue size of the AStarSimilarity- Specified by:
getMaxQueueSizein interfaceSMGraphAStar- Returns:
- The maximum queue size
-
setMaxQueueSize
public void setMaxQueueSize(int qSize)
Description copied from interface:SMGraphAStarSets 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:
setMaxQueueSizein interfaceSMGraphAStar- Parameters:
qSize- The maximum queue size
-
isReturnLocalNodeSimilarities
public boolean isReturnLocalNodeSimilarities()
- Specified by:
isReturnLocalNodeSimilaritiesin interfaceSMGraphAStar- Returns:
-
setReturnLocalNodeSimilarities
public void setReturnLocalNodeSimilarities(boolean returnLocalNodeSimilarities)
- Specified by:
setReturnLocalNodeSimilaritiesin interfaceSMGraphAStar
-
isReturnLocalSimilarities
public boolean isReturnLocalSimilarities()
- Specified by:
isReturnLocalSimilaritiesin interfaceSMGraphAStar- Returns:
-
setReturnLocalSimilarities
public void setReturnLocalSimilarities(boolean returnLocalSimilarities)
- Specified by:
setReturnLocalSimilaritiesin interfaceSMGraphAStar
-
isReturnLocalEdgeSimilarities
public boolean isReturnLocalEdgeSimilarities()
- Specified by:
isReturnLocalEdgeSimilaritiesin interfaceSMGraphAStar- Returns:
-
setReturnLocalEdgeSimilarities
public void setReturnLocalEdgeSimilarities(boolean returnLocalEdgeSimilarities)
- Specified by:
setReturnLocalEdgeSimilaritiesin interfaceSMGraphAStar
-
isAllowPreInitializationOfSolution
public boolean isAllowPreInitializationOfSolution()
- Specified by:
isAllowPreInitializationOfSolutionin interfaceSMGraphAStar- Returns:
-
setAllowPreInitializationOfSolution
public void setAllowPreInitializationOfSolution(boolean allowPreInitializationOfSolution)
- Specified by:
setAllowPreInitializationOfSolutionin interfaceSMGraphAStar
-
isAllowCaseOrientedMapping
public boolean isAllowCaseOrientedMapping()
- Specified by:
isAllowCaseOrientedMappingin interfaceSMGraphAStar- Returns:
- Whether case-oriented mapping is allowed or not.
-
setAllowCaseOrientedMapping
public void setAllowCaseOrientedMapping(boolean allowCaseOrientedMapping)
- Specified by:
setAllowCaseOrientedMappingin interfaceSMGraphAStar- Parameters:
allowCaseOrientedMapping- flag
-
isOnlyTestForEquality
public boolean isOnlyTestForEquality()
- Specified by:
isOnlyTestForEqualityin interfaceSMGraphAStar- Returns:
- flag
-
setOnlyTestForEquality
public void setOnlyTestForEquality(boolean onlyTestForEquality)
- Specified by:
setOnlyTestForEqualityin interfaceSMGraphAStar- Parameters:
onlyTestForEquality- flag
-
getTimeout
public int getTimeout()
- Specified by:
getTimeoutin interfaceSMGraphAStar- Returns:
- The timeout for terminating the computation.
-
setTimeout
public void setTimeout(int timeoutSeconds)
Description copied from interface:SMGraphAStarSets a timeout in seconds for terminating the computation. Setting a negative value disables timeout.- Specified by:
setTimeoutin interfaceSMGraphAStar- Parameters:
timeoutSeconds- in seconds for terminating the computation
-
compute
public Similarity compute(DataObject queryObjectOrig, DataObject caseObjectOrig, SimilarityValuator valuator)
- Specified by:
computein 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:
isSimilarityForin classSimilarityMeasureImpl
-
isReusable
public boolean isReusable()
- Specified by:
isReusablein interfaceSimilarityMeasure- Overrides:
isReusablein classSimilarityMeasureImpl- Returns:
- true if the measure is reusable
-
initializeBasedOn
protected void initializeBasedOn(SimilarityMeasure base)
Description copied from class:SimilarityMeasureImplInitialize measure based on existing instance- Overrides:
initializeBasedOnin classSimilarityMeasureImpl- Parameters:
base- similarity measure to base on
-
-