diff options
author | 2019-05-04 17:56:18 -0400 | |
---|---|---|
committer | 2019-05-04 17:56:18 -0400 | |
commit | b9aaa826e1e7504958b6e75f35e9dcd09086a13e (patch) | |
tree | df7b83804e74efb86fb845862c5523d04d7edeb1 /Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java | |
parent | Merge remote-tracking branch 'origin/master' into kris (diff) | |
download | VIATRA-Generator-b9aaa826e1e7504958b6e75f35e9dcd09086a13e.tar.gz VIATRA-Generator-b9aaa826e1e7504958b6e75f35e9dcd09086a13e.tar.zst VIATRA-Generator-b9aaa826e1e7504958b6e75f35e9dcd09086a13e.zip |
Metrics for satellite case study
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java new file mode 100644 index 00000000..65fed74a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java | |||
@@ -0,0 +1,215 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; | ||
5 | |||
6 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind; | ||
10 | import java.util.Arrays; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Set; | ||
14 | import org.eclipse.emf.ecore.EClass; | ||
15 | import org.eclipse.emf.ecore.EDataType; | ||
16 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
17 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; | ||
18 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
19 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
20 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
38 | |||
39 | /** | ||
40 | * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. | ||
41 | * | ||
42 | * <p>Original source: | ||
43 | * <code><pre> | ||
44 | * private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spacecraft, Cost : java Double) { | ||
45 | * ConstellationMission.spacecraft(Mission, Spacecraft); | ||
46 | * Spacecraft.kind(Spacecraft, Kind); | ||
47 | * KindCount == count find spacecraftOfKind(_, Kind); | ||
48 | * find basePrice(Spacecraft, BasePrice); | ||
49 | * find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost); | ||
50 | * find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost); | ||
51 | * Cost == eval(BasePrice Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see GenericPatternMatcher | ||
56 | * @see GenericPatternMatch | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class SpacecraftCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { | ||
61 | private SpacecraftCost() { | ||
62 | super(GeneratedPQuery.INSTANCE); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * @return the singleton instance of the query specification | ||
67 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
68 | * | ||
69 | */ | ||
70 | public static SpacecraftCost instance() { | ||
71 | try{ | ||
72 | return LazyHolder.INSTANCE; | ||
73 | } catch (ExceptionInInitializerError err) { | ||
74 | throw processInitializerError(err); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost (visibility: PUBLIC, simpleName: SpacecraftCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created | ||
80 | * <b>not</b> at the class load time of the outer class, | ||
81 | * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost (visibility: PUBLIC, simpleName: SpacecraftCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. | ||
82 | * | ||
83 | * <p> This workaround is required e.g. to support recursion. | ||
84 | * | ||
85 | */ | ||
86 | private static class LazyHolder { | ||
87 | private static final SpacecraftCost INSTANCE = new SpacecraftCost(); | ||
88 | |||
89 | /** | ||
90 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
91 | * This initialization order is required to support indirect recursion. | ||
92 | * | ||
93 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
94 | * | ||
95 | */ | ||
96 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
97 | |||
98 | public static Object ensureInitialized() { | ||
99 | INSTANCE.ensureInitializedInternal(); | ||
100 | return null; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
105 | private static final SpacecraftCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
106 | |||
107 | private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); | ||
108 | |||
109 | private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); | ||
110 | |||
111 | private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); | ||
112 | |||
113 | private final List<PParameter> parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft, parameter_Cost); | ||
114 | |||
115 | private GeneratedPQuery() { | ||
116 | super(PVisibility.PRIVATE); | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String getFullyQualifiedName() { | ||
121 | return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftCost"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> getParameterNames() { | ||
126 | return Arrays.asList("Mission","Spacecraft","Cost"); | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public List<PParameter> getParameters() { | ||
131 | return parameters; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public Set<PBody> doGetContainedBodies() { | ||
136 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
137 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
138 | { | ||
139 | PBody body = new PBody(this); | ||
140 | PVariable var_Mission = body.getOrCreateVariableByName("Mission"); | ||
141 | PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); | ||
142 | PVariable var_Cost = body.getOrCreateVariableByName("Cost"); | ||
143 | PVariable var_Kind = body.getOrCreateVariableByName("Kind"); | ||
144 | PVariable var_KindCount = body.getOrCreateVariableByName("KindCount"); | ||
145 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
146 | PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); | ||
147 | PVariable var_InterferometryPayloadCost = body.getOrCreateVariableByName("InterferometryPayloadCost"); | ||
148 | PVariable var_AdditionalCommSubsystemCost = body.getOrCreateVariableByName("AdditionalCommSubsystemCost"); | ||
149 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); | ||
150 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
151 | new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); | ||
152 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
153 | new ExportedParameter(body, var_Mission, parameter_Mission), | ||
154 | new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), | ||
155 | new ExportedParameter(body, var_Cost, parameter_Cost) | ||
156 | )); | ||
157 | // ConstellationMission.spacecraft(Mission, Spacecraft) | ||
158 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); | ||
159 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
160 | new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); | ||
161 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
162 | new Equality(body, var__virtual_0_, var_Spacecraft); | ||
163 | // Spacecraft.kind(Spacecraft, Kind) | ||
164 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); | ||
165 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
166 | new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); | ||
167 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); | ||
168 | new Equality(body, var__virtual_1_, var_Kind); | ||
169 | // KindCount == count find spacecraftOfKind(_, Kind) | ||
170 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
171 | new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_, var_Kind), SpacecraftOfKind.instance().getInternalQueryRepresentation(), var__virtual_2_); | ||
172 | new Equality(body, var_KindCount, var__virtual_2_); | ||
173 | // find basePrice(Spacecraft, BasePrice) | ||
174 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_BasePrice), BasePrice.instance().getInternalQueryRepresentation()); | ||
175 | // find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost) | ||
176 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_InterferometryPayloadCost), InterferometryPayloadCost.instance().getInternalQueryRepresentation()); | ||
177 | // find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost) | ||
178 | new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_AdditionalCommSubsystemCost), AdditionalCommSubsystemCost.instance().getInternalQueryRepresentation()); | ||
179 | // Cost == eval(BasePrice * Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost) | ||
180 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
181 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
182 | |||
183 | @Override | ||
184 | public String getShortDescription() { | ||
185 | return "Expression evaluation from pattern spacecraftCost"; | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | public Iterable<String> getInputParameterNames() { | ||
190 | return Arrays.asList("AdditionalCommSubsystemCost", "BasePrice", "InterferometryPayloadCost", "KindCount");} | ||
191 | |||
192 | @Override | ||
193 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
194 | Double AdditionalCommSubsystemCost = (Double) provider.getValue("AdditionalCommSubsystemCost"); | ||
195 | Double BasePrice = (Double) provider.getValue("BasePrice"); | ||
196 | Double InterferometryPayloadCost = (Double) provider.getValue("InterferometryPayloadCost"); | ||
197 | Integer KindCount = (Integer) provider.getValue("KindCount"); | ||
198 | return evaluateExpression_1_1(AdditionalCommSubsystemCost, BasePrice, InterferometryPayloadCost, KindCount); | ||
199 | } | ||
200 | }, var__virtual_3_ ); | ||
201 | new Equality(body, var_Cost, var__virtual_3_); | ||
202 | bodies.add(body); | ||
203 | } | ||
204 | return bodies; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | private static double evaluateExpression_1_1(final Double AdditionalCommSubsystemCost, final Double BasePrice, final Double InterferometryPayloadCost, final Integer KindCount) { | ||
209 | double _pow = Math.pow((KindCount).intValue(), (-0.25)); | ||
210 | double _multiply = ((BasePrice).doubleValue() * _pow); | ||
211 | double _plus = (_multiply + (InterferometryPayloadCost).doubleValue()); | ||
212 | double _plus_1 = (_plus + (AdditionalCommSubsystemCost).doubleValue()); | ||
213 | return _plus_1; | ||
214 | } | ||
215 | } | ||