diff options
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend new file mode 100644 index 00000000..b238e64f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend | |||
@@ -0,0 +1,29 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SatelliteQueries | ||
5 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction | ||
6 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution | ||
7 | |||
8 | class PatternMatchConstraint implements IGuidanceFunction { | ||
9 | static val CONSTRAINT_ANNOTATION_NAME = "Constraint" | ||
10 | |||
11 | val queries = ImmutableList.copyOf(SatelliteQueries.instance.specifications.filter [ | ||
12 | allAnnotations.exists[name == CONSTRAINT_ANNOTATION_NAME] | ||
13 | ]) | ||
14 | |||
15 | override getName() { | ||
16 | "PatternMatch" | ||
17 | } | ||
18 | |||
19 | override computeFitness(Solution solution) { | ||
20 | val model = solution.model | ||
21 | val queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model) | ||
22 | var int matchCount = 0 | ||
23 | for (query : queries) { | ||
24 | val matcher = query.getMatcher(queryEngine) | ||
25 | matchCount += matcher.countMatches | ||
26 | } | ||
27 | matchCount | ||
28 | } | ||
29 | } | ||