diff options
author | 2020-08-06 16:07:16 +0200 | |
---|---|---|
committer | 2020-08-06 16:07:16 +0200 | |
commit | a620f07468780778bd55dcffc30245def37ece69 (patch) | |
tree | 57189ad9c8bf15211a05a3cd50ee90e90f434557 /Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | |
parent | Fix time measurement (diff) | |
download | VIATRA-Generator-a620f07468780778bd55dcffc30245def37ece69.tar.gz VIATRA-Generator-a620f07468780778bd55dcffc30245def37ece69.tar.zst VIATRA-Generator-a620f07468780778bd55dcffc30245def37ece69.zip |
MoDeS3 unit propagation WIP
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java')
-rw-r--r-- | Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | 381 |
1 files changed, 381 insertions, 0 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java new file mode 100644 index 00000000..c7364257 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | |||
@@ -0,0 +1,381 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import com.google.common.collect.ImmutableSet; | ||
6 | import com.google.common.collect.Iterables; | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace; | ||
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; | ||
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory; | ||
13 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; | ||
14 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; | ||
18 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext; | ||
19 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion; | ||
20 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff; | ||
21 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage; | ||
22 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration; | ||
23 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue; | ||
24 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TermDescription; | ||
25 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition; | ||
27 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable; | ||
28 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation; | ||
29 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | ||
30 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage; | ||
31 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | ||
32 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | ||
33 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | ||
34 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; | ||
35 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; | ||
36 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
37 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage; | ||
38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod; | ||
39 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints; | ||
40 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver; | ||
41 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy; | ||
42 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | ||
43 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink; | ||
44 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation; | ||
45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | ||
46 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation; | ||
47 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage; | ||
48 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; | ||
49 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | ||
50 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | ||
51 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; | ||
52 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | ||
53 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | ||
54 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | ||
55 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | ||
56 | import java.util.Collections; | ||
57 | import java.util.List; | ||
58 | import java.util.Map; | ||
59 | import java.util.Set; | ||
60 | import java.util.function.Consumer; | ||
61 | import java.util.function.Predicate; | ||
62 | import modes3.Modes3Factory; | ||
63 | import modes3.Modes3ModelRoot; | ||
64 | import modes3.Modes3Package; | ||
65 | import modes3.queries.Modes3Queries; | ||
66 | import org.eclipse.emf.common.util.EList; | ||
67 | import org.eclipse.emf.common.util.URI; | ||
68 | import org.eclipse.emf.ecore.EAttribute; | ||
69 | import org.eclipse.emf.ecore.EClass; | ||
70 | import org.eclipse.emf.ecore.EEnum; | ||
71 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
72 | import org.eclipse.emf.ecore.EObject; | ||
73 | import org.eclipse.emf.ecore.EReference; | ||
74 | import org.eclipse.emf.ecore.EStructuralFeature; | ||
75 | import org.eclipse.emf.ecore.resource.Resource; | ||
76 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
77 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | ||
78 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
79 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; | ||
80 | import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory; | ||
81 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
82 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory; | ||
83 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; | ||
84 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
85 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
86 | import org.eclipse.xtext.xbase.lib.Exceptions; | ||
87 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
88 | import org.eclipse.xtext.xbase.lib.Extension; | ||
89 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
90 | import org.eclipse.xtext.xbase.lib.InputOutput; | ||
91 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
92 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
93 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
94 | |||
95 | @FinalFieldsConstructor | ||
96 | @SuppressWarnings("all") | ||
97 | public class Modes3ModelGenerator { | ||
98 | private enum MonitoringQuery { | ||
99 | closeTrains, | ||
100 | |||
101 | misalignedTurnout; | ||
102 | } | ||
103 | |||
104 | private final Modes3ModelGenerator.MonitoringQuery monitoringQuery; | ||
105 | |||
106 | private final int modelSize; | ||
107 | |||
108 | private final Ecore2Logic ecore2Logic = new Ecore2Logic(); | ||
109 | |||
110 | private final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | ||
111 | |||
112 | private final Viatra2Logic viatra2Logic = new Viatra2Logic(this.ecore2Logic); | ||
113 | |||
114 | private final ViatraReasoner solver = new ViatraReasoner(); | ||
115 | |||
116 | @Extension | ||
117 | private final LogicProblemBuilder _logicProblemBuilder = new LogicProblemBuilder(); | ||
118 | |||
119 | public URI generate() { | ||
120 | try { | ||
121 | URI _xblockexpression = null; | ||
122 | { | ||
123 | final EcoreMetamodelDescriptor metamodel = Modes3ModelGenerator.createMetamodelDescriptor(); | ||
124 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | ||
125 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelLogic = this.ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | ||
126 | final Type segment = this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSegment()); | ||
127 | final RelationDeclaration connectedTo = this.ecore2Logic.relationOfReference(metamodelLogic.getTrace(), | ||
128 | Modes3Package.eINSTANCE.getSegment_ConnectedTo()); | ||
129 | final RelationDeclaration connectedToIndicator = ((EReferenceMapper_RelationsOverTypes_Trace) metamodelLogic.getTrace().referenceMapperTrace).indicators.get( | ||
130 | Modes3Package.eINSTANCE.getSegment_ConnectedTo()); | ||
131 | StringConcatenation _builder = new StringConcatenation(); | ||
132 | _builder.append("oppositeReference "); | ||
133 | String _name = connectedTo.getName(); | ||
134 | _builder.append(_name); | ||
135 | _builder.append(" "); | ||
136 | String _name_1 = connectedTo.getName(); | ||
137 | _builder.append(_name_1); | ||
138 | final Function1<VariableContext, TermDescription> _function = (VariableContext it) -> { | ||
139 | Iff _xblockexpression_1 = null; | ||
140 | { | ||
141 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
142 | _builder_1.append("src"); | ||
143 | final Variable src = it.addVar(_builder_1, segment); | ||
144 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
145 | _builder_2.append("trg"); | ||
146 | final Variable trg = it.addVar(_builder_2, segment); | ||
147 | SymbolicValue _call = this._logicProblemBuilder.call(connectedToIndicator, src, trg); | ||
148 | SymbolicValue _call_1 = this._logicProblemBuilder.call(connectedToIndicator, trg, src); | ||
149 | _xblockexpression_1 = this._logicProblemBuilder.operator_spaceship(_call, _call_1); | ||
150 | } | ||
151 | return _xblockexpression_1; | ||
152 | }; | ||
153 | final Assertion inverseAssertion = this._logicProblemBuilder.Assertion(_builder, | ||
154 | this._logicProblemBuilder.Forall(_function)); | ||
155 | EList<Assertion> _assertions = metamodelLogic.getOutput().getAssertions(); | ||
156 | _assertions.add(inverseAssertion); | ||
157 | InverseRelationAssertion _createInverseRelationAssertion = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion(); | ||
158 | final Procedure1<InverseRelationAssertion> _function_1 = (InverseRelationAssertion it) -> { | ||
159 | it.setTarget(inverseAssertion); | ||
160 | it.setInverseA(connectedTo); | ||
161 | it.setInverseB(connectedTo); | ||
162 | }; | ||
163 | final InverseRelationAssertion inverseAnnotation = ObjectExtensions.<InverseRelationAssertion>operator_doubleArrow(_createInverseRelationAssertion, _function_1); | ||
164 | EList<Annotation> _annotations = metamodelLogic.getOutput().getAnnotations(); | ||
165 | _annotations.add(inverseAnnotation); | ||
166 | final List<EObject> initialModel = Modes3ModelGenerator.loadInitialModel(); | ||
167 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> initialModelLogic = this.instanceModel2Logic.transform(metamodelLogic, initialModel); | ||
168 | final ViatraQuerySetDescriptor queries = this.loadQueries(); | ||
169 | Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration(); | ||
170 | final TracedOutput<LogicProblem, Viatra2LogicTrace> logic = this.viatra2Logic.transformQueries(queries, initialModelLogic, _viatra2LogicConfiguration); | ||
171 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | ||
172 | final Procedure1<ViatraReasonerConfiguration> _function_2 = (ViatraReasonerConfiguration it) -> { | ||
173 | it.runtimeLimit = 3600; | ||
174 | final Procedure1<TypeScopes> _function_3 = (TypeScopes it_1) -> { | ||
175 | it_1.minNewElements = this.modelSize; | ||
176 | it_1.maxNewElements = this.modelSize; | ||
177 | final Procedure1<Map<Type, Integer>> _function_4 = (Map<Type, Integer> it_2) -> { | ||
178 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf(1)); | ||
179 | }; | ||
180 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | ||
181 | it_1.minNewElementsByType, _function_4); | ||
182 | final Procedure1<Map<Type, Integer>> _function_5 = (Map<Type, Integer> it_2) -> { | ||
183 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf(5)); | ||
184 | }; | ||
185 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | ||
186 | it_1.maxNewElementsByType, _function_5); | ||
187 | }; | ||
188 | ObjectExtensions.<TypeScopes>operator_doubleArrow( | ||
189 | it.typeScopes, _function_3); | ||
190 | it.solutionScope.numberOfRequiredSolutions = 1; | ||
191 | it.nameNewElements = false; | ||
192 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; | ||
193 | it.stateCoderStrategy = StateCoderStrategy.Neighbourhood; | ||
194 | ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral( | ||
195 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp); | ||
196 | it.scopePropagatorStrategy = _polyhedral; | ||
197 | it.debugConfiguration.partialInterpretatioVisualiser = null; | ||
198 | }; | ||
199 | final ViatraReasonerConfiguration config = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function_2); | ||
200 | final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", ""); | ||
201 | final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace); | ||
202 | URI _xifexpression = null; | ||
203 | if ((solution instanceof ModelResult)) { | ||
204 | InputOutput.<String>println("Saving generated solutions"); | ||
205 | final EList<Object> representations = ((ModelResult)solution).getRepresentation(); | ||
206 | int _size = representations.size(); | ||
207 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
208 | for (final Integer representationIndex : _doubleDotLessThan) { | ||
209 | { | ||
210 | final Object representation = representations.get((representationIndex).intValue()); | ||
211 | final int representationNumber = ((representationIndex).intValue() + 1); | ||
212 | if ((representation instanceof PartialInterpretation)) { | ||
213 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
214 | _builder_1.append("solution"); | ||
215 | _builder_1.append(representationNumber); | ||
216 | _builder_1.append(".partialinterpretation"); | ||
217 | workspace.writeModel(((EObject)representation), _builder_1.toString()); | ||
218 | final PartialInterpretation2Gml partialInterpretation2GML = new PartialInterpretation2Gml(); | ||
219 | final String gml = partialInterpretation2GML.transform(((PartialInterpretation)representation)); | ||
220 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
221 | _builder_2.append("solution"); | ||
222 | _builder_2.append(representationNumber); | ||
223 | _builder_2.append(".gml"); | ||
224 | workspace.writeText(_builder_2.toString(), gml); | ||
225 | int _size_1 = ((PartialInterpretation)representation).getNewElements().size(); | ||
226 | boolean _lessThan = (_size_1 < 160); | ||
227 | if (_lessThan) { | ||
228 | if ((representation instanceof PartialInterpretation)) { | ||
229 | final Consumer<Type> _function_3 = (Type it) -> { | ||
230 | InputOutput.<String>println(it.getName()); | ||
231 | }; | ||
232 | ((PartialInterpretation)representation).getProblem().getTypes().forEach(_function_3); | ||
233 | final Function1<Type, Boolean> _function_4 = (Type it) -> { | ||
234 | String _name_2 = it.getName(); | ||
235 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); | ||
236 | }; | ||
237 | Type _findFirst = IterableExtensions.<Type>findFirst(((PartialInterpretation)representation).getProblem().getTypes(), _function_4); | ||
238 | final TypeDefinition rootType = ((TypeDefinition) _findFirst); | ||
239 | final Function1<PartialComplexTypeInterpretation, Boolean> _function_5 = (PartialComplexTypeInterpretation it) -> { | ||
240 | String _name_2 = it.getInterpretationOf().getName(); | ||
241 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); | ||
242 | }; | ||
243 | final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.<PartialComplexTypeInterpretation>findFirst(Iterables.<PartialComplexTypeInterpretation>filter(((PartialInterpretation)representation).getPartialtypeinterpratation(), | ||
244 | PartialComplexTypeInterpretation.class), _function_5); | ||
245 | rootIntepretation.getElements().removeAll(rootType.getElements()); | ||
246 | ((PartialInterpretation)representation).getProblem().getElements().removeAll(rootType.getElements()); | ||
247 | EList<PartialRelationInterpretation> _partialrelationinterpretation = ((PartialInterpretation)representation).getPartialrelationinterpretation(); | ||
248 | for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { | ||
249 | final Predicate<RelationLink> _function_6 = (RelationLink link) -> { | ||
250 | boolean _xifexpression_1 = false; | ||
251 | if ((link instanceof BinaryElementRelationLink)) { | ||
252 | _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); | ||
253 | } else { | ||
254 | _xifexpression_1 = false; | ||
255 | } | ||
256 | return _xifexpression_1; | ||
257 | }; | ||
258 | relationInterpretation.getRelationlinks().removeIf(_function_6); | ||
259 | } | ||
260 | rootType.getElements().clear(); | ||
261 | } | ||
262 | final GraphvizVisualiser visualiser = new GraphvizVisualiser(); | ||
263 | final PartialInterpretationVisualisation visualisation = visualiser.visualiseConcretization(((PartialInterpretation)representation)); | ||
264 | StringConcatenation _builder_3 = new StringConcatenation(); | ||
265 | _builder_3.append("solution"); | ||
266 | _builder_3.append(representationNumber); | ||
267 | _builder_3.append(".png"); | ||
268 | visualisation.writeToFile(workspace, _builder_3.toString()); | ||
269 | } | ||
270 | } else { | ||
271 | StringConcatenation _builder_4 = new StringConcatenation(); | ||
272 | _builder_4.append("solution"); | ||
273 | _builder_4.append(representationNumber); | ||
274 | _builder_4.append(".txt"); | ||
275 | workspace.writeText(_builder_4.toString(), representation.toString()); | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | } else { | ||
280 | URI _xblockexpression_1 = null; | ||
281 | { | ||
282 | InputOutput.<String>println("Failed to solver problem"); | ||
283 | final LogicProblem partial = logic.getOutput(); | ||
284 | _xblockexpression_1 = workspace.writeModel(partial, "solution.partialinterpretation"); | ||
285 | } | ||
286 | _xifexpression = _xblockexpression_1; | ||
287 | } | ||
288 | _xblockexpression = _xifexpression; | ||
289 | } | ||
290 | return _xblockexpression; | ||
291 | } catch (Throwable _e) { | ||
292 | throw Exceptions.sneakyThrow(_e); | ||
293 | } | ||
294 | } | ||
295 | |||
296 | public static EcoreMetamodelDescriptor createMetamodelDescriptor() { | ||
297 | EcoreMetamodelDescriptor _xblockexpression = null; | ||
298 | { | ||
299 | final ImmutableList<EClass> eClasses = ImmutableList.<EClass>copyOf(Iterables.<EClass>filter(Modes3Package.eINSTANCE.getEClassifiers(), EClass.class)); | ||
300 | Set<EClass> _emptySet = CollectionLiterals.<EClass>emptySet(); | ||
301 | List<EEnum> _emptyList = CollectionLiterals.<EEnum>emptyList(); | ||
302 | List<EEnumLiteral> _emptyList_1 = CollectionLiterals.<EEnumLiteral>emptyList(); | ||
303 | final Function1<EClass, EList<EReference>> _function = (EClass it) -> { | ||
304 | return it.getEReferences(); | ||
305 | }; | ||
306 | ImmutableList<EReference> _copyOf = ImmutableList.<EReference>copyOf(IterableExtensions.<EClass, EReference>flatMap(eClasses, _function)); | ||
307 | List<EAttribute> _emptyList_2 = CollectionLiterals.<EAttribute>emptyList(); | ||
308 | _xblockexpression = new EcoreMetamodelDescriptor(eClasses, _emptySet, | ||
309 | false, _emptyList, _emptyList_1, _copyOf, _emptyList_2); | ||
310 | } | ||
311 | return _xblockexpression; | ||
312 | } | ||
313 | |||
314 | public static List<EObject> loadInitialModel() { | ||
315 | Modes3ModelRoot _createModes3ModelRoot = Modes3Factory.eINSTANCE.createModes3ModelRoot(); | ||
316 | return Collections.<EObject>unmodifiableList(CollectionLiterals.<EObject>newArrayList(_createModes3ModelRoot)); | ||
317 | } | ||
318 | |||
319 | public ViatraQuerySetDescriptor loadQueries() { | ||
320 | ViatraQuerySetDescriptor _xblockexpression = null; | ||
321 | { | ||
322 | final ImmutableList.Builder<IQuerySpecification<?>> patternsBuilder = ImmutableList.<IQuerySpecification<?>>builder(); | ||
323 | patternsBuilder.addAll(Modes3Queries.instance().getSpecifications()); | ||
324 | final ImmutableList<IQuerySpecification<?>> patterns = patternsBuilder.build(); | ||
325 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> pattern) -> { | ||
326 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it) -> { | ||
327 | String _name = it.getName(); | ||
328 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | ||
329 | }; | ||
330 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(pattern.getAllAnnotations(), _function_1)); | ||
331 | }; | ||
332 | final ImmutableSet<IQuerySpecification<?>> validationPatterns = ImmutableSet.<IQuerySpecification<?>>copyOf(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | ||
333 | Map<IQuerySpecification<?>, EStructuralFeature> _emptyMap = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | ||
334 | _xblockexpression = new ViatraQuerySetDescriptor(patterns, validationPatterns, _emptyMap); | ||
335 | } | ||
336 | return _xblockexpression; | ||
337 | } | ||
338 | |||
339 | public static Object init() { | ||
340 | Object _xblockexpression = null; | ||
341 | { | ||
342 | EMFPatternLanguageStandaloneSetup.doSetup(); | ||
343 | ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, | ||
344 | LocalSearchEMFBackendFactory.INSTANCE); | ||
345 | LogiclanguagePackage.eINSTANCE.getClass(); | ||
346 | LogicproblemPackage.eINSTANCE.getClass(); | ||
347 | PartialinterpretationPackage.eINSTANCE.getClass(); | ||
348 | Ecore2logicannotationsPackage.eINSTANCE.getClass(); | ||
349 | Viatra2LogicAnnotationsPackage.eINSTANCE.getClass(); | ||
350 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
351 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
352 | _extensionToFactoryMap.put("ecore", _xMIResourceFactoryImpl); | ||
353 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
354 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); | ||
355 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); | ||
356 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
357 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); | ||
358 | _xblockexpression = _extensionToFactoryMap_2.put("partialinterpretation", _xMIResourceFactoryImpl_2); | ||
359 | } | ||
360 | return _xblockexpression; | ||
361 | } | ||
362 | |||
363 | public static void main(final String[] args) { | ||
364 | int _length = args.length; | ||
365 | boolean _notEquals = (_length != 2); | ||
366 | if (_notEquals) { | ||
367 | System.err.println("Usage: <query> <model size>"); | ||
368 | } | ||
369 | final Modes3ModelGenerator.MonitoringQuery monitoringQuery = Modes3ModelGenerator.MonitoringQuery.valueOf(args[0]); | ||
370 | final int modelSize = Integer.parseInt(args[1]); | ||
371 | Modes3ModelGenerator.init(); | ||
372 | final Modes3ModelGenerator generator = new Modes3ModelGenerator(monitoringQuery, modelSize); | ||
373 | generator.generate(); | ||
374 | } | ||
375 | |||
376 | public Modes3ModelGenerator(final Modes3ModelGenerator.MonitoringQuery monitoringQuery, final int modelSize) { | ||
377 | super(); | ||
378 | this.monitoringQuery = monitoringQuery; | ||
379 | this.modelSize = modelSize; | ||
380 | } | ||
381 | } | ||