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/MetricBasedGuidanceFunction.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/MetricBasedGuidanceFunction.java')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.java new file mode 100644 index 00000000..f3dae715 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.java | |||
@@ -0,0 +1,72 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo.LocalSearchEngineManager; | ||
4 | import java.util.Iterator; | ||
5 | import org.eclipse.emf.ecore.EObject; | ||
6 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
7 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
8 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
9 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
10 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
11 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
12 | |||
13 | @SuppressWarnings("all") | ||
14 | public abstract class MetricBasedGuidanceFunction implements IGuidanceFunction { | ||
15 | private final IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> querySpecification; | ||
16 | |||
17 | protected MetricBasedGuidanceFunction(final IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> querySpecification) { | ||
18 | this.querySpecification = querySpecification; | ||
19 | int _size = querySpecification.getParameters().size(); | ||
20 | boolean _notEquals = (_size != 1); | ||
21 | if (_notEquals) { | ||
22 | throw new IllegalArgumentException("Metric must have a single parameter"); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | @Override | ||
27 | public double computeFitness(final Solution model) { | ||
28 | double _xblockexpression = (double) 0; | ||
29 | { | ||
30 | final double value = this.getMetricValue(model); | ||
31 | _xblockexpression = this.computeFitness(value); | ||
32 | } | ||
33 | return _xblockexpression; | ||
34 | } | ||
35 | |||
36 | protected double computeFitness(final double metricValue) { | ||
37 | return metricValue; | ||
38 | } | ||
39 | |||
40 | private double getMetricValue(final Solution solution) { | ||
41 | double _xblockexpression = (double) 0; | ||
42 | { | ||
43 | final EObject model = solution.getModel(); | ||
44 | final ViatraQueryEngine queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model); | ||
45 | final ViatraQueryMatcher<? extends IPatternMatch> matcher = this.querySpecification.getMatcher(queryEngine); | ||
46 | final Iterator<? extends IPatternMatch> iterator = matcher.getAllMatches().iterator(); | ||
47 | boolean _hasNext = iterator.hasNext(); | ||
48 | boolean _not = (!_hasNext); | ||
49 | if (_not) { | ||
50 | throw new IllegalStateException("Too few matches"); | ||
51 | } | ||
52 | final Object objectValue = iterator.next().get(0); | ||
53 | double _xifexpression = (double) 0; | ||
54 | if ((objectValue instanceof Number)) { | ||
55 | double _xblockexpression_1 = (double) 0; | ||
56 | { | ||
57 | final double doubleValue = ((Number)objectValue).doubleValue(); | ||
58 | boolean _hasNext_1 = iterator.hasNext(); | ||
59 | if (_hasNext_1) { | ||
60 | throw new IllegalStateException("Too many matches"); | ||
61 | } | ||
62 | _xblockexpression_1 = doubleValue; | ||
63 | } | ||
64 | _xifexpression = _xblockexpression_1; | ||
65 | } else { | ||
66 | throw new IllegalStateException("Metric value must be a number"); | ||
67 | } | ||
68 | _xblockexpression = _xifexpression; | ||
69 | } | ||
70 | return _xblockexpression; | ||
71 | } | ||
72 | } | ||