diff options
author | 2019-06-09 15:13:00 -0400 | |
---|---|---|
committer | 2019-06-09 15:13:00 -0400 | |
commit | cd63ccf6fba2a812a9b115635bbd209c92cebad0 (patch) | |
tree | 6f2a04b6fd274dffe6bb72c1afdf87989c0ba6db /Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.java | |
parent | Simplify satellite metamodel further (diff) | |
download | VIATRA-Generator-cd63ccf6fba2a812a9b115635bbd209c92cebad0.tar.gz VIATRA-Generator-cd63ccf6fba2a812a9b115635bbd209c92cebad0.tar.zst VIATRA-Generator-cd63ccf6fba2a812a9b115635bbd209c92cebad0.zip |
Bump MDEOptimizer version
https://github.com/mde-optimiser/mde_optimiser/issues/49
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.java')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.java new file mode 100644 index 00000000..f089d469 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.java | |||
@@ -0,0 +1,54 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo.LocalSearchEngineManager; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SatelliteQueries; | ||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
9 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
10 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
11 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
13 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
14 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
15 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
16 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
17 | |||
18 | @SuppressWarnings("all") | ||
19 | public class PatternMatchConstraint implements IGuidanceFunction { | ||
20 | private static final String CONSTRAINT_ANNOTATION_NAME = "Constraint"; | ||
21 | |||
22 | private final ImmutableList<IQuerySpecification<?>> queries = ImmutableList.<IQuerySpecification<?>>copyOf(IterableExtensions.<IQuerySpecification<?>>filter(SatelliteQueries.instance().getSpecifications(), ((Function1<IQuerySpecification<?>, Boolean>) (IQuerySpecification<?> it) -> { | ||
23 | final Function1<PAnnotation, Boolean> _function = (PAnnotation it_1) -> { | ||
24 | String _name = it_1.getName(); | ||
25 | return Boolean.valueOf(Objects.equal(_name, PatternMatchConstraint.CONSTRAINT_ANNOTATION_NAME)); | ||
26 | }; | ||
27 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function)); | ||
28 | }))); | ||
29 | |||
30 | @Override | ||
31 | public String getName() { | ||
32 | return "PatternMatch"; | ||
33 | } | ||
34 | |||
35 | @Override | ||
36 | public double computeFitness(final Solution solution) { | ||
37 | int _xblockexpression = (int) 0; | ||
38 | { | ||
39 | final EObject model = solution.getModel(); | ||
40 | final ViatraQueryEngine queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model); | ||
41 | int matchCount = 0; | ||
42 | for (final IQuerySpecification<?> query : this.queries) { | ||
43 | { | ||
44 | final ViatraQueryMatcher<? extends IPatternMatch> matcher = query.getMatcher(queryEngine); | ||
45 | int _matchCount = matchCount; | ||
46 | int _countMatches = matcher.countMatches(); | ||
47 | matchCount = (_matchCount + _countMatches); | ||
48 | } | ||
49 | } | ||
50 | _xblockexpression = matchCount; | ||
51 | } | ||
52 | return _xblockexpression; | ||
53 | } | ||
54 | } | ||