Wire Neo4j heuristics into the search fitness function - #1731
Wire Neo4j heuristics into the search fitness function#1731andyfelder16 wants to merge 10 commits into
Conversation
# Conflicts: # core/src/main/kotlin/org/evomaster/core/search/service/Statistics.kt
…b and cassandra heuristics
… from its result types
| * @param evaluationFailure whether the evaluation failed | ||
| */ | ||
| public Neo4jDistanceWithMetrics(double distance, int numberOfEvaluatedNodes, boolean evaluationFailure) { | ||
| if (distance < 0.0d || distance > 1.0d || Double.isNaN(distance)) { |
There was a problem hiding this comment.
hi @andyfelder16 .thx ;) but should first request @jgaleotti review, and, then, once that is completed, JP asks for my review. anyway, with a quick look here i can see the naming is confusing. see DistanceHelper for a definition of distance vs heuristic inside EM codebase
There was a problem hiding this comment.
Hi @arcuri82 , I am taking over the review. However, this is indeed a distance since it follows the same model as MongoDistanceWithMetrics, RedisDistanceWithMetrics, DynamoDbDistanceWithMetrics and CqlDistanceWithMetrics (i.e., Cassandra)
| * @param evaluationFailure whether the evaluation failed | ||
| */ | ||
| public Neo4jDistanceWithMetrics(double distance, int numberOfEvaluatedNodes, boolean evaluationFailure) { | ||
| if (distance < 0.0d || distance > 1.0d || Double.isNaN(distance)) { |
There was a problem hiding this comment.
Hi @arcuri82 , I am taking over the review. However, this is indeed a distance since it follows the same model as MongoDistanceWithMetrics, RedisDistanceWithMetrics, DynamoDbDistanceWithMetrics and CqlDistanceWithMetrics (i.e., Cassandra)
| metrics = new Neo4jDistanceWithMetrics(distance, graph.nodeCount(), false); | ||
| } catch (Exception e) { | ||
| SimpleLogger.uniqueWarn("Failed to compute Neo4j heuristic for query: " + query); | ||
| metrics = new Neo4jDistanceWithMetrics(1.0, graph.nodeCount(), true); |
There was a problem hiding this comment.
replace 1.0 with Neo4HeuristicsCalculator.MAX_NEO4J_DISTANCE = 1.0d
| .toList() | ||
|
|
||
| if (toMinimize.isNotEmpty()) { | ||
| fv.setExtraToMinimize(i, toMinimize) |
There was a problem hiding this comment.
this code is behind master
|
@andyfelder16 please update branch and fix conflicts |
Last of the PRs splitting #1641, on top of #1580, #1672, #1647, #1697 and #1715, all of which are merged. It closes the chain: the Cypher queries the SUT runs have been captured since #1460, and this is what finally turns them into search guidance.
Neo4jHandlercollects the queries intercepted fromSession.run, reads the graph once per action rather than once per query, and scores each query against that snapshot. Only MATCH queries are scored; anything that does not parse as one, such as a write, is skippedNeo4jCommandWithDistanceandNeo4jDistanceWithMetricscarry the result to the DTOEnterpriseFitness.handleNeo4jHeuristicsfeeds the distances to the search, behind the newheuristicsForNeo4joption, and reports evaluation counts and the average number of nodes inspected throughStatisticsStatisticsTest, covering the scored path, a write being skipped, no driver, heuristics disabled, and a driver that cannot be reached