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
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
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_MAX_SIM, DEFAULT_RETURN_LOCAL_EDGE_SIMILARITIES, DEFAULT_RETURN_LOCAL_NODE_SIMILARITIES, DEFAULT_TIMEOUT, DEFAULT_USE_EQUALITY_INSTEAD_OF_SIMILARITY, DEFAULT_WEIGHT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears all weights for graph item classes.compute
(DataObject queryObjectOrig, DataObject caseObjectOrig, SimilarityValuator valuator) computeUserGraphItemWeightsNormalized
(NESTGraphObject graphObject) 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.void
filterNodesAndEdges
(Set<NESTNodeObject> caseNodes, Set<NESTEdgeObject> caseEdges) double
int
Gets the queue size of the AStarSimilarityint
double
protected void
initHeuristic
(AStarCaseSolution sol, SimilarityValuator simVal) protected void
Initialize measure based on existing instanceboolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isSimilarityFor
(DataClass dataclass, String orderName) boolean
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
setDefaultWeight
(double defaultWeight) void
setMaxQueueSize
(int qSize) Sets the maximum size of the queue that stores the (partial) solutions of the A* algorithm.void
setOnlyTestForMaxSim
(boolean onlyTestForMaxSim) 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 timeoutSeconds) Sets a timeout in seconds for terminating the computation.void
setUseEqualityInsteadOfSimilarity
(boolean useEqualityInsteadOfSimilarity) void
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
-
Constructor Details
-
SMGraphAStarImpl
public SMGraphAStarImpl()
-
-
Method Details
-
getOriginalQueryNodes
- Specified by:
getOriginalQueryNodes
in interfaceSMGraphAStar
- Returns:
- the originalQueryNodes
-
setOriginalQueryNodes
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
- Specified by:
getOriginalQueryEdges
in interfaceSMGraphAStar
- Returns:
- the originalQueryEdges
-
setOriginalQueryEdges
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
-
isOnlyTestForMaxSim
public boolean isOnlyTestForMaxSim()- Specified by:
isOnlyTestForMaxSim
in interfaceSMGraphAStar
- Returns:
- flag
-
setOnlyTestForMaxSim
public void setOnlyTestForMaxSim(boolean onlyTestForMaxSim) - Specified by:
setOnlyTestForMaxSim
in interfaceSMGraphAStar
- Parameters:
onlyTestForMaxSim
- flag
-
isUseEqualityInsteadOfSimilarity
public boolean isUseEqualityInsteadOfSimilarity()- Specified by:
isUseEqualityInsteadOfSimilarity
in interfaceSMGraphAStar
- Returns:
- flag
-
setUseEqualityInsteadOfSimilarity
public void setUseEqualityInsteadOfSimilarity(boolean useEqualityInsteadOfSimilarity) - Specified by:
setUseEqualityInsteadOfSimilarity
in interfaceSMGraphAStar
- Parameters:
useEqualityInsteadOfSimilarity
- flag
-
getTimeout
public int getTimeout()- Specified by:
getTimeout
in interfaceSMGraphAStar
- Returns:
- The timeout for terminating the computation.
-
setTimeout
public void setTimeout(int timeoutSeconds) 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:
timeoutSeconds
- 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
- 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
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
- 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
Description copied from class:SimilarityMeasureImpl
Initialize measure based on existing instance- Overrides:
initializeBasedOn
in classSimilarityMeasureImpl
- Parameters:
base
- similarity measure to base on
-
getWeight
- Specified by:
getWeight
in interfaceSMGraphAStar
- Returns:
- the weight of the given graph item class. If the weight is not set, the default weight will be returned.
- Throws:
InvalidParameterException
-
setWeight
- Specified by:
setWeight
in interfaceSMGraphAStar
- Parameters:
graphItemClassName
- is the name of the graph item class whose weight should be setweight
- is the weight of the attribute. The values will be normalized automatically.- Throws:
InvalidParameterException
-
clearWeights
public void clearWeights()Description copied from interface:SMGraphAStar
Clears all weights for graph item classes.- Specified by:
clearWeights
in interfaceSMGraphAStar
-
computeUserGraphItemWeightsNormalized
public Map<NESTGraphItemObject,Double> computeUserGraphItemWeightsNormalized(NESTGraphObject graphObject) -
filterNodesAndEdges
-
getDefaultWeight
public double getDefaultWeight()- Specified by:
getDefaultWeight
in interfaceSMGraphAStar
- Returns:
- default weight
-
setDefaultWeight
public void setDefaultWeight(double defaultWeight) - Specified by:
setDefaultWeight
in interfaceSMGraphAStar
- Parameters:
defaultWeight
- is the default weight for each graph item class which hasn't an own weight
-