diff options
author | 2019-08-01 18:38:15 +0200 | |
---|---|---|
committer | 2019-08-01 18:38:15 +0200 | |
commit | 6eb760ee960cd3efe51ca6e4107153c09838a1da (patch) | |
tree | 2edd0e21be50265f65f0cfd2fd43f18a252aef02 /Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.java | |
parent | Dump required Xbase version down to 2.17 (diff) | |
download | VIATRA-Generator-6eb760ee960cd3efe51ca6e4107153c09838a1da.tar.gz VIATRA-Generator-6eb760ee960cd3efe51ca6e4107153c09838a1da.tar.zst VIATRA-Generator-6eb760ee960cd3efe51ca6e4107153c09838a1da.zip |
Clean up CPS and Satellite domains
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, 0 insertions, 72 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 deleted file mode 100644 index f3dae715..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.java +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
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 | } | ||