diff options
author | 2020-05-11 10:18:54 -0400 | |
---|---|---|
committer | 2020-05-11 10:18:54 -0400 | |
commit | cc64c325bc12888b76cb93e814e6b46347d5c4cb (patch) | |
tree | 6a33a60039ae469cd4a552ae1b18fcfa236142ab /Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run | |
parent | Remove derived features from the PLEDGE MM (diff) | |
download | VIATRA-Generator-cc64c325bc12888b76cb93e814e6b46347d5c4cb.tar.gz VIATRA-Generator-cc64c325bc12888b76cb93e814e6b46347d5c4cb.tar.zst VIATRA-Generator-cc64c325bc12888b76cb93e814e6b46347d5c4cb.zip |
Fine Tune PLEDGE Case Study Project and Main Method
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GenerateFromConfig.xtendbin | bin | 14906 -> 10678 bytes | |||
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin | bin | 16725 -> 16725 bytes | |||
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GenerateFromConfig.java | 160 |
3 files changed, 4 insertions, 156 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GenerateFromConfig.xtendbin b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GenerateFromConfig.xtendbin index a68e4de3..87d1cc1e 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GenerateFromConfig.xtendbin +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GenerateFromConfig.xtendbin | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin index 499149a8..e7e5d9f0 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/.GeneratePledgeModels.xtendbin | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GenerateFromConfig.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GenerateFromConfig.java index 3015d4dd..35f173be 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GenerateFromConfig.java +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GenerateFromConfig.java | |||
@@ -1,7 +1,5 @@ | |||
1 | package run; | 1 | package run; |
2 | 2 | ||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.Iterables; | ||
5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.Command; | 3 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.Command; |
6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.Config; | 4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.Config; |
7 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigEntry; | 5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigEntry; |
@@ -19,68 +17,31 @@ import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ScopeSpec | |||
19 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.TypeScope; | 17 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.TypeScope; |
20 | import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor; | 18 | import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor; |
21 | import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; | 19 | import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; |
22 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
23 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
24 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
25 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | ||
27 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
28 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | ||
29 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | 20 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; |
30 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | ||
31 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; | 21 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; |
32 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; | ||
33 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | ||
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | ||
36 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | ||
37 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | ||
38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
39 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | ||
40 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | 23 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; |
41 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | ||
42 | import java.io.PrintWriter; | 24 | import java.io.PrintWriter; |
43 | import java.math.BigDecimal; | 25 | import java.math.BigDecimal; |
44 | import java.text.SimpleDateFormat; | 26 | import java.text.SimpleDateFormat; |
45 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
46 | import java.util.Collections; | ||
47 | import java.util.Date; | 28 | import java.util.Date; |
48 | import java.util.HashMap; | ||
49 | import java.util.List; | ||
50 | import java.util.Map; | 29 | import java.util.Map; |
51 | import java.util.Set; | ||
52 | import org.eclipse.core.runtime.NullProgressMonitor; | 30 | import org.eclipse.core.runtime.NullProgressMonitor; |
53 | import org.eclipse.emf.common.util.EList; | ||
54 | import org.eclipse.emf.common.util.URI; | 31 | import org.eclipse.emf.common.util.URI; |
55 | import org.eclipse.emf.ecore.EAttribute; | ||
56 | import org.eclipse.emf.ecore.EClass; | ||
57 | import org.eclipse.emf.ecore.EEnum; | ||
58 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
59 | import org.eclipse.emf.ecore.EObject; | ||
60 | import org.eclipse.emf.ecore.EPackage; | ||
61 | import org.eclipse.emf.ecore.EReference; | ||
62 | import org.eclipse.emf.ecore.EStructuralFeature; | ||
63 | import org.eclipse.emf.ecore.resource.Resource; | 32 | import org.eclipse.emf.ecore.resource.Resource; |
64 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | 33 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
65 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; | ||
66 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
67 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
68 | import org.eclipse.xtend2.lib.StringConcatenation; | 34 | import org.eclipse.xtend2.lib.StringConcatenation; |
69 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; | 35 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; |
70 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
71 | import org.eclipse.xtext.xbase.lib.Exceptions; | 36 | import org.eclipse.xtext.xbase.lib.Exceptions; |
72 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
73 | import org.eclipse.xtext.xbase.lib.Functions.Function0; | 37 | import org.eclipse.xtext.xbase.lib.Functions.Function0; |
74 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
75 | import org.eclipse.xtext.xbase.lib.InputOutput; | 38 | import org.eclipse.xtext.xbase.lib.InputOutput; |
76 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
77 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
78 | 39 | ||
79 | @SuppressWarnings("all") | 40 | @SuppressWarnings("all") |
80 | public class GenerateFromConfig { | 41 | public class GenerateFromConfig { |
81 | private static final int SIZE_LB = 1; | 42 | private static final int SIZE_LB = 20; |
82 | 43 | ||
83 | private static final int SIZE_UB = 1; | 44 | private static final int SIZE_UB = 20; |
84 | 45 | ||
85 | private static final int SIZE_MUL = 1; | 46 | private static final int SIZE_MUL = 1; |
86 | 47 | ||
@@ -96,9 +57,9 @@ public class GenerateFromConfig { | |||
96 | 57 | ||
97 | private static final boolean INITIAL = true; | 58 | private static final boolean INITIAL = true; |
98 | 59 | ||
99 | private static final boolean INDIV_WRT = true; | 60 | private static final boolean INDIV_WRT = false; |
100 | 61 | ||
101 | private static final boolean GLOBAL_WRT = true; | 62 | private static final boolean GLOBAL_WRT = false; |
102 | 63 | ||
103 | private static final String q2t = new Function0<String>() { | 64 | private static final String q2t = new Function0<String>() { |
104 | @Override | 65 | @Override |
@@ -262,119 +223,6 @@ public class GenerateFromConfig { | |||
262 | } | 223 | } |
263 | } | 224 | } |
264 | 225 | ||
265 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | ||
266 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | ||
267 | final Function1<EClass, String> _function = (EClass s) -> { | ||
268 | return s.getName(); | ||
269 | }; | ||
270 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | ||
271 | Set<Class> _keySet = classMap.keySet(); | ||
272 | for (final Class elem : _keySet) { | ||
273 | typeMap.put( | ||
274 | e2l.TypeofEClass(trace, | ||
275 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | ||
276 | } | ||
277 | return typeMap; | ||
278 | } | ||
279 | |||
280 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | ||
281 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | ||
282 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | ||
283 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | ||
284 | return it.getELiterals(); | ||
285 | }; | ||
286 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | ||
287 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | ||
288 | return it.getEReferences(); | ||
289 | }; | ||
290 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | ||
291 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | ||
292 | return it.getEAttributes(); | ||
293 | }; | ||
294 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | ||
295 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | ||
296 | } | ||
297 | |||
298 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | ||
299 | EList<EObject> _xblockexpression = null; | ||
300 | { | ||
301 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
302 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
303 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | ||
304 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | ||
305 | } | ||
306 | return _xblockexpression; | ||
307 | } | ||
308 | |||
309 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | ||
310 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | ||
311 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | ||
312 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | ||
313 | String _name = it_1.getName(); | ||
314 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | ||
315 | }; | ||
316 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | ||
317 | }; | ||
318 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | ||
319 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | ||
320 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | ||
321 | return res; | ||
322 | } | ||
323 | |||
324 | public static void writeInterpretation(final LogicResult solution, final Logic2Ecore logic2Ecore, final ReasonerWorkspace workspace, final String id, final ViatraReasoner reasoner, final TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | ||
325 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | ||
326 | int _size = interpretations.size(); | ||
327 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
328 | for (final Integer interpIndex : _doubleDotLessThan) { | ||
329 | { | ||
330 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | ||
331 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | ||
332 | StringConcatenation _builder = new StringConcatenation(); | ||
333 | _builder.append("sol-"); | ||
334 | _builder.append(id); | ||
335 | _builder.append("_"); | ||
336 | _builder.append(interpIndex); | ||
337 | _builder.append(".xmi"); | ||
338 | workspace.writeModel(model, _builder.toString()); | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | |||
343 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final String id) { | ||
344 | final EList<Object> representations = solution.getRepresentation(); | ||
345 | int _size = representations.size(); | ||
346 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
347 | for (final Integer representationIndex : _doubleDotLessThan) { | ||
348 | { | ||
349 | final Object representation = representations.get((representationIndex).intValue()); | ||
350 | if ((representation instanceof PartialInterpretation)) { | ||
351 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | ||
352 | StringConcatenation _builder = new StringConcatenation(); | ||
353 | _builder.append("sol-"); | ||
354 | _builder.append(id); | ||
355 | _builder.append("_"); | ||
356 | _builder.append(representationIndex); | ||
357 | _builder.append(".gml"); | ||
358 | workspace.writeText(_builder.toString(), gml); | ||
359 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | ||
360 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
361 | _builder_1.append("sol-"); | ||
362 | _builder_1.append(id); | ||
363 | _builder_1.append("_"); | ||
364 | _builder_1.append(representationIndex); | ||
365 | _builder_1.append(".png"); | ||
366 | png.writeToFile(workspace, _builder_1.toString()); | ||
367 | } else { | ||
368 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
369 | _builder_2.append("sol-"); | ||
370 | _builder_2.append(representationIndex); | ||
371 | _builder_2.append(".txt"); | ||
372 | workspace.writeText(_builder_2.toString(), representation.toString()); | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | } | ||
377 | |||
378 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | 226 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { |
379 | String _xblockexpression = null; | 227 | String _xblockexpression = null; |
380 | { | 228 | { |