diff options
author | 2020-05-10 20:13:33 +0200 | |
---|---|---|
committer | 2020-05-10 20:13:33 +0200 | |
commit | 021a46f4feb6503effb612ce154d3568c3d64b4f (patch) | |
tree | fcf6ddf76d1fc346e7c7d5d40c75304b463ec284 /Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java | |
parent | measurement time statistics + activation selection strategies (diff) | |
parent | Adjust PLEDEG Java Case Study file (diff) | |
download | VIATRA-Generator-021a46f4feb6503effb612ce154d3568c3d64b4f.tar.gz VIATRA-Generator-021a46f4feb6503effb612ce154d3568c3d64b4f.tar.zst VIATRA-Generator-021a46f4feb6503effb612ce154d3568c3d64b4f.zip |
Merge branch 'master' of https://github.com/viatra/VIATRA-Generator
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java | 812 |
1 files changed, 498 insertions, 314 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java index 2809679d..84232a13 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java | |||
@@ -1,314 +1,498 @@ | |||
1 | package run; | 1 | package run; |
2 | 2 | ||
3 | import Taxation.TaxationPackage; | 3 | import Taxation.TaxationPackage; |
4 | import com.google.common.base.Objects; | 4 | import com.google.common.base.Objects; |
5 | import com.google.common.collect.Iterables; | 5 | import com.google.common.collect.Iterables; |
6 | import com.google.inject.Injector; | 6 | import familytree.FamilytreePackage; |
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | 7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; |
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; | 8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; |
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | 9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; |
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | 10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; |
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | 15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; |
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | 16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; |
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | 17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; |
18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; | 18 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics; |
19 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; | 19 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.impl.ModelResultImpl; |
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | 20 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; |
21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | 21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | 22 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; |
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 23 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; |
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | 24 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; |
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; |
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | 27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; |
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
29 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | 29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; |
30 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | 30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
31 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | 31 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; |
32 | import java.math.BigDecimal; | 32 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; |
33 | import java.text.SimpleDateFormat; | 33 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; |
34 | import java.util.Collections; | 34 | import java.io.PrintWriter; |
35 | import java.util.Date; | 35 | import java.math.BigDecimal; |
36 | import java.util.HashMap; | 36 | import java.text.SimpleDateFormat; |
37 | import java.util.List; | 37 | import java.util.Collections; |
38 | import java.util.Map; | 38 | import java.util.Date; |
39 | import java.util.Set; | 39 | import java.util.HashMap; |
40 | import java.util.TreeSet; | 40 | import java.util.List; |
41 | import org.eclipse.emf.common.util.EList; | 41 | import java.util.Map; |
42 | import org.eclipse.emf.ecore.EAttribute; | 42 | import java.util.Set; |
43 | import org.eclipse.emf.ecore.EClass; | 43 | import java.util.TreeSet; |
44 | import org.eclipse.emf.ecore.EEnum; | 44 | import org.eclipse.emf.common.util.EList; |
45 | import org.eclipse.emf.ecore.EEnumLiteral; | 45 | import org.eclipse.emf.common.util.URI; |
46 | import org.eclipse.emf.ecore.EObject; | 46 | import org.eclipse.emf.ecore.EAttribute; |
47 | import org.eclipse.emf.ecore.EPackage; | 47 | import org.eclipse.emf.ecore.EClass; |
48 | import org.eclipse.emf.ecore.EReference; | 48 | import org.eclipse.emf.ecore.EEnum; |
49 | import org.eclipse.emf.ecore.EStructuralFeature; | 49 | import org.eclipse.emf.ecore.EEnumLiteral; |
50 | import org.eclipse.emf.ecore.resource.Resource; | 50 | import org.eclipse.emf.ecore.EObject; |
51 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | 51 | import org.eclipse.emf.ecore.EPackage; |
52 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | 52 | import org.eclipse.emf.ecore.EReference; |
53 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; | 53 | import org.eclipse.emf.ecore.EStructuralFeature; |
54 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 54 | import org.eclipse.emf.ecore.resource.Resource; |
55 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 55 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
56 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; | 56 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; |
57 | import org.eclipse.xtend2.lib.StringConcatenation; | 57 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; |
58 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; | 58 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
59 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | 59 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
60 | import org.eclipse.xtext.xbase.lib.Exceptions; | 60 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; |
61 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | 61 | import org.eclipse.xtend2.lib.StringConcatenation; |
62 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | 62 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; |
63 | import org.eclipse.xtext.xbase.lib.InputOutput; | 63 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
64 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | 64 | import org.eclipse.xtext.xbase.lib.Exceptions; |
65 | import org.eclipse.xtext.xbase.lib.ListExtensions; | 65 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; |
66 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | 66 | import org.eclipse.xtext.xbase.lib.Functions.Function0; |
67 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | 67 | import org.eclipse.xtext.xbase.lib.Functions.Function1; |
68 | 68 | import org.eclipse.xtext.xbase.lib.InputOutput; | |
69 | @SuppressWarnings("all") | 69 | import org.eclipse.xtext.xbase.lib.IterableExtensions; |
70 | public class GeneratePledgeModels { | 70 | import org.eclipse.xtext.xbase.lib.ListExtensions; |
71 | public static void main(final String[] args) { | 71 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; |
72 | try { | 72 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
73 | final Injector x = new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); | 73 | import queries.Case_study_A; |
74 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 74 | import queries.FamilyTreeConstraints; |
75 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 75 | |
76 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); | 76 | @SuppressWarnings("all") |
77 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 77 | public class GeneratePledgeModels { |
78 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); | 78 | private static final int SIZE_LB = 20; |
79 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); | 79 | |
80 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 80 | private static final int SIZE_UB = 20; |
81 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); | 81 | |
82 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); | 82 | private static final int SIZE_MUL = 1; |
83 | ReteEngine.class.getClass(); | 83 | |
84 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); | 84 | private static final int SIZE_INC = 5; |
85 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); | 85 | |
86 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); | 86 | private static int REPS = 1; |
87 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | 87 | |
88 | long _currentTimeMillis = System.currentTimeMillis(); | 88 | private static final int RUNTIME = 600; |
89 | final Date date = new Date(_currentTimeMillis); | 89 | |
90 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); | 90 | private static final String DOMAIN = "FamilyTree"; |
91 | final String formattedDate = format.format(date); | 91 | |
92 | StringConcatenation _builder = new StringConcatenation(); | 92 | private static final boolean QUERIES = false; |
93 | _builder.append("inputs/"); | 93 | |
94 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); | 94 | private static final boolean INDIV_WRT = true; |
95 | StringConcatenation _builder_1 = new StringConcatenation(); | 95 | |
96 | _builder_1.append("output/"); | 96 | private static final boolean GLOBAL_WRT = true; |
97 | String _plus = (_builder_1.toString() + formattedDate); | 97 | |
98 | StringConcatenation _builder_2 = new StringConcatenation(); | 98 | private static final String q2t = new Function0<String>() { |
99 | _builder_2.append("/"); | 99 | @Override |
100 | String _plus_1 = (_plus + _builder_2); | 100 | public String apply() { |
101 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_1, ""); | 101 | String _xifexpression = null; |
102 | StringConcatenation _builder_3 = new StringConcatenation(); | 102 | if (GeneratePledgeModels.QUERIES) { |
103 | _builder_3.append("output/"); | 103 | _xifexpression = "Y"; |
104 | String _plus_2 = (_builder_3.toString() + formattedDate); | 104 | } else { |
105 | StringConcatenation _builder_4 = new StringConcatenation(); | 105 | _xifexpression = "N"; |
106 | _builder_4.append("/debug/"); | 106 | } |
107 | String _plus_3 = (_plus_2 + _builder_4); | 107 | return _xifexpression; |
108 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_3, ""); | 108 | } |
109 | workspace.initAndClear(); | 109 | }.apply(); |
110 | InputOutput.<String>println("Input and output workspaces are created"); | 110 | |
111 | final EcoreMetamodelDescriptor metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); | 111 | public static void main(final String[] args) { |
112 | final EList<EObject> partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); | 112 | try { |
113 | InputOutput.<String>println("DSL loaded"); | 113 | new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); |
114 | final int SIZE = 2; | 114 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
115 | int REPS = 1; | 115 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
116 | final int RUNTIME = 600; | 116 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); |
117 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | 117 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
118 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | 118 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); |
119 | LogicProblem problem = modelGenerationProblem.getOutput(); | 119 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); |
120 | debug.writeModel(problem, "problem.logicproblem"); | 120 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
121 | InputOutput.<String>println("Problem created"); | 121 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); |
122 | for (int i = 0; (i < REPS); i++) { | 122 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); |
123 | { | 123 | ReteEngine.class.getClass(); |
124 | ViatraReasoner reasoner = new ViatraReasoner(); | 124 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); |
125 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); | 125 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); |
126 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0)); | 126 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); |
127 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); | 127 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); |
128 | BigDecimal _bigDecimal = new BigDecimal("0.0"); | 128 | long _currentTimeMillis = System.currentTimeMillis(); |
129 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); | 129 | final Date date = new Date(_currentTimeMillis); |
130 | final TreeSet<String> knownStrings = new TreeSet<String>(); | 130 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); |
131 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2"); | 131 | final String formattedDate = format.format(date); |
132 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | 132 | StringConcatenation _builder = new StringConcatenation(); |
133 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { | 133 | _builder.append("inputs/"); |
134 | it.documentationLevel = DocumentationLevel.FULL; | 134 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); |
135 | DebugConfiguration _debugConfiguration = new DebugConfiguration(); | 135 | StringConcatenation _builder_1 = new StringConcatenation(); |
136 | final Procedure1<DebugConfiguration> _function_1 = (DebugConfiguration it_1) -> { | 136 | _builder_1.append("output/"); |
137 | it_1.logging = true; | 137 | final FileSystemWorkspace dataws = new FileSystemWorkspace(_builder_1.toString(), ""); |
138 | }; | 138 | StringConcatenation _builder_2 = new StringConcatenation(); |
139 | DebugConfiguration _doubleArrow = ObjectExtensions.<DebugConfiguration>operator_doubleArrow(_debugConfiguration, _function_1); | 139 | _builder_2.append("output/"); |
140 | it.debugCongiguration = _doubleArrow; | 140 | String _plus = (_builder_2.toString() + formattedDate); |
141 | it.runtimeLimit = RUNTIME; | 141 | StringConcatenation _builder_3 = new StringConcatenation(); |
142 | boolean _isEmpty = knownIntegers.isEmpty(); | 142 | _builder_3.append("/models/"); |
143 | boolean _not = (!_isEmpty); | 143 | String _plus_1 = (_plus + _builder_3); |
144 | if (_not) { | 144 | final FileSystemWorkspace modelsws = new FileSystemWorkspace(_plus_1, ""); |
145 | it.typeScopes.knownIntegers = knownIntegers; | 145 | StringConcatenation _builder_4 = new StringConcatenation(); |
146 | } | 146 | _builder_4.append("output/"); |
147 | boolean _isEmpty_1 = knownReals.isEmpty(); | 147 | String _plus_2 = (_builder_4.toString() + formattedDate); |
148 | boolean _not_1 = (!_isEmpty_1); | 148 | StringConcatenation _builder_5 = new StringConcatenation(); |
149 | if (_not_1) { | 149 | _builder_5.append("/"); |
150 | it.typeScopes.knownReals = knownReals; | 150 | String _plus_3 = (_plus_2 + _builder_5); |
151 | } | 151 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_3, ""); |
152 | }; | 152 | StringConcatenation _builder_6 = new StringConcatenation(); |
153 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); | 153 | _builder_6.append("output/"); |
154 | InputOutput.<String>println((("Run #" + Integer.valueOf(i)) + ":")); | 154 | String _plus_4 = (_builder_6.toString() + GeneratePledgeModels.DOMAIN); |
155 | final long startTime = System.currentTimeMillis(); | 155 | String _plus_5 = (_plus_4 + "-"); |
156 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); | 156 | String _plus_6 = (_plus_5 + formattedDate); |
157 | long _currentTimeMillis_1 = System.currentTimeMillis(); | 157 | StringConcatenation _builder_7 = new StringConcatenation(); |
158 | final long totalTime = (_currentTimeMillis_1 - startTime); | 158 | _builder_7.append("/debug/"); |
159 | InputOutput.<String>println(" Problem Solved"); | 159 | String _plus_7 = (_plus_6 + _builder_7); |
160 | GeneratePledgeModels.writeStats(solution, totalTime, solverConfig); | 160 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_7, ""); |
161 | if ((solution instanceof ModelResult)) { | 161 | workspace.initAndClear(); |
162 | GeneratePledgeModels.writeRepresentation(solution, workspace, i); | 162 | modelsws.initAndClear(); |
163 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, workspace, i, reasoner, modelGenerationProblem); | 163 | InputOutput.<String>println("Input and output workspaces are created"); |
164 | InputOutput.<String>println(" Solution saved and visualised"); | 164 | EcoreMetamodelDescriptor metamodel = null; |
165 | } else { | 165 | EList<EObject> partialModel = null; |
166 | String _string = solution.getClass().getSimpleName().toString(); | 166 | ViatraQuerySetDescriptor queries = null; |
167 | String _plus_4 = (" Returned: " + _string); | 167 | final String DOMAIN = GeneratePledgeModels.DOMAIN; |
168 | InputOutput.<String>println(_plus_4); | 168 | if (DOMAIN != null) { |
169 | } | 169 | switch (DOMAIN) { |
170 | final Runtime r = Runtime.getRuntime(); | 170 | case "Taxation": |
171 | r.gc(); | 171 | metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); |
172 | r.gc(); | 172 | partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); |
173 | r.gc(); | 173 | queries = GeneratePledgeModels.loadQueries(metamodel, Case_study_A.instance()); |
174 | Thread.sleep(3000); | 174 | break; |
175 | } | 175 | case "FamilyTree": |
176 | } | 176 | metamodel = GeneratePledgeModels.loadMetamodel(FamilytreePackage.eINSTANCE); |
177 | InputOutput.<String>println("---End---"); | 177 | partialModel = GeneratePledgeModels.loadPartialModel(inputs, "FamilyTree.xmi"); |
178 | } catch (Throwable _e) { | 178 | queries = GeneratePledgeModels.loadQueries(metamodel, FamilyTreeConstraints.instance()); |
179 | throw Exceptions.sneakyThrow(_e); | 179 | break; |
180 | } | 180 | default: |
181 | } | 181 | { |
182 | 182 | System.err.println("Unsupported Domain"); | |
183 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | 183 | throw new Exception(); |
184 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | 184 | } |
185 | final Function1<EClass, String> _function = (EClass s) -> { | 185 | } |
186 | return s.getName(); | 186 | } else { |
187 | }; | 187 | { |
188 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | 188 | System.err.println("Unsupported Domain"); |
189 | Set<Class> _keySet = classMap.keySet(); | 189 | throw new Exception(); |
190 | for (final Class elem : _keySet) { | 190 | } |
191 | typeMap.put( | 191 | } |
192 | e2l.TypeofEClass(trace, | 192 | InputOutput.<String>println("DSL loaded"); |
193 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | 193 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); |
194 | } | 194 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); |
195 | return typeMap; | 195 | LogicProblem problem = modelGenerationProblem.getOutput(); |
196 | } | 196 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelExtensionProblem = instanceModel2Logic.transform(modelGenerationProblem, partialModel); |
197 | 197 | problem = modelExtensionProblem.getOutput(); | |
198 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | 198 | if (GeneratePledgeModels.QUERIES) { |
199 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | 199 | Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration(); |
200 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | 200 | final TracedOutput<LogicProblem, Viatra2LogicTrace> validModelExtensionProblem = viatra2Logic.transformQueries(queries, modelExtensionProblem, _viatra2LogicConfiguration); |
201 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | 201 | problem = validModelExtensionProblem.getOutput(); |
202 | return it.getELiterals(); | 202 | } |
203 | }; | 203 | InputOutput.<String>println("Problem created"); |
204 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | 204 | PrintWriter global_writer = null; |
205 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | 205 | final String header = "domain, queries?,size,model?,timeout,measuredTime,TransformatonTime,SolverTime\n"; |
206 | return it.getEReferences(); | 206 | if (GeneratePledgeModels.GLOBAL_WRT) { |
207 | }; | 207 | URI _workspaceURI = workspace.getWorkspaceURI(); |
208 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | 208 | String _plus_8 = (_workspaceURI + "//_"); |
209 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | 209 | String _plus_9 = (_plus_8 + GeneratePledgeModels.DOMAIN); |
210 | return it.getEAttributes(); | 210 | String _plus_10 = (_plus_9 + Integer.valueOf(GeneratePledgeModels.SIZE_LB)); |
211 | }; | 211 | String _plus_11 = (_plus_10 + "to"); |
212 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | 212 | String _plus_12 = (_plus_11 + Integer.valueOf(GeneratePledgeModels.SIZE_UB)); |
213 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | 213 | String _plus_13 = (_plus_12 + "x"); |
214 | } | 214 | String _plus_14 = (_plus_13 + Integer.valueOf(GeneratePledgeModels.REPS)); |
215 | 215 | String _plus_15 = (_plus_14 + "q"); | |
216 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | 216 | String _plus_16 = (_plus_15 + GeneratePledgeModels.q2t); |
217 | EList<EObject> _xblockexpression = null; | 217 | String _plus_17 = (_plus_16 + "-"); |
218 | { | 218 | String _plus_18 = (_plus_17 + formattedDate); |
219 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 219 | String _plus_19 = (_plus_18 + ".csv"); |
220 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 220 | PrintWriter _printWriter = new PrintWriter(_plus_19); |
221 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | 221 | global_writer = _printWriter; |
222 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | 222 | global_writer.append(header); |
223 | } | 223 | } |
224 | return _xblockexpression; | 224 | int NEXT_INC = GeneratePledgeModels.SIZE_INC; |
225 | } | 225 | { |
226 | 226 | int size = GeneratePledgeModels.SIZE_LB; | |
227 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | 227 | boolean _while = (size <= GeneratePledgeModels.SIZE_UB); |
228 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | 228 | while (_while) { |
229 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | 229 | { |
230 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | 230 | int _NEXT_INC = NEXT_INC; |
231 | String _name = it_1.getName(); | 231 | NEXT_INC = (_NEXT_INC * GeneratePledgeModels.SIZE_MUL); |
232 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | 232 | PrintWriter indiv_writer = null; |
233 | }; | 233 | if (GeneratePledgeModels.INDIV_WRT) { |
234 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | 234 | URI _workspaceURI_1 = workspace.getWorkspaceURI(); |
235 | }; | 235 | String _plus_20 = (_workspaceURI_1 + "//__"); |
236 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | 236 | String _plus_21 = (_plus_20 + GeneratePledgeModels.DOMAIN); |
237 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | 237 | String _plus_22 = (_plus_21 + "Sz"); |
238 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | 238 | String _plus_23 = (_plus_22 + Integer.valueOf(size)); |
239 | return res; | 239 | String _plus_24 = (_plus_23 + "x"); |
240 | } | 240 | String _plus_25 = (_plus_24 + Integer.valueOf(GeneratePledgeModels.REPS)); |
241 | 241 | String _plus_26 = (_plus_25 + "q"); | |
242 | public static void writeInterpretation(final LogicResult solution, final Logic2Ecore logic2Ecore, final ReasonerWorkspace workspace, final int i, final ViatraReasoner reasoner, final TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | 242 | String _plus_27 = (_plus_26 + GeneratePledgeModels.q2t); |
243 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | 243 | String _plus_28 = (_plus_27 + "-"); |
244 | int _size = interpretations.size(); | 244 | String _plus_29 = (_plus_28 + formattedDate); |
245 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 245 | String _plus_30 = (_plus_29 + |
246 | for (final Integer interpIndex : _doubleDotLessThan) { | 246 | ".csv"); |
247 | { | 247 | PrintWriter _printWriter_1 = new PrintWriter(_plus_30); |
248 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | 248 | indiv_writer = _printWriter_1; |
249 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | 249 | indiv_writer.append(header); |
250 | StringConcatenation _builder = new StringConcatenation(); | 250 | } |
251 | _builder.append("solution"); | 251 | InputOutput.println(); |
252 | _builder.append(i); | 252 | InputOutput.<String>println(((("DOMAIN: " + GeneratePledgeModels.DOMAIN) + ", SIZE=") + Integer.valueOf(size))); |
253 | _builder.append("_"); | 253 | for (int i = 0; (i < GeneratePledgeModels.REPS); i++) { |
254 | _builder.append(interpIndex); | 254 | { |
255 | _builder.append(".xmi"); | 255 | InputOutput.<String>print((("<<Run number " + Integer.valueOf(i)) + ">> : ")); |
256 | workspace.writeModel(model, _builder.toString()); | 256 | ViatraReasoner reasoner = new ViatraReasoner(); |
257 | } | 257 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); |
258 | } | 258 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0), Integer.valueOf(10), Integer.valueOf(20), Integer.valueOf(30), Integer.valueOf(40), Integer.valueOf(50)); |
259 | } | 259 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); |
260 | 260 | BigDecimal _bigDecimal = new BigDecimal("0.0"); | |
261 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final int i) { | 261 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); |
262 | final EList<Object> representations = solution.getRepresentation(); | 262 | final TreeSet<String> knownStrings = new TreeSet<String>(); |
263 | int _size = representations.size(); | 263 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2", "r3", "r4", "r5", "r6"); |
264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 264 | final int curSize = size; |
265 | for (final Integer representationIndex : _doubleDotLessThan) { | 265 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); |
266 | { | 266 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { |
267 | final Object representation = representations.get((representationIndex).intValue()); | 267 | it.documentationLevel = DocumentationLevel.NONE; |
268 | if ((representation instanceof PartialInterpretation)) { | 268 | it.runtimeLimit = GeneratePledgeModels.RUNTIME; |
269 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | 269 | it.typeScopes.minNewElements = curSize; |
270 | StringConcatenation _builder = new StringConcatenation(); | 270 | boolean _isEmpty = knownReals.isEmpty(); |
271 | _builder.append("solution"); | 271 | boolean _not = (!_isEmpty); |
272 | _builder.append(i); | 272 | if (_not) { |
273 | _builder.append("_"); | 273 | it.typeScopes.knownReals = knownReals; |
274 | _builder.append(representationIndex); | 274 | } |
275 | _builder.append(".gml"); | 275 | }; |
276 | workspace.writeText(_builder.toString(), gml); | 276 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); |
277 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | 277 | final long startTime = System.currentTimeMillis(); |
278 | StringConcatenation _builder_1 = new StringConcatenation(); | 278 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); |
279 | _builder_1.append("solution"); | 279 | long _currentTimeMillis_1 = System.currentTimeMillis(); |
280 | _builder_1.append(i); | 280 | final long measuredTime = (_currentTimeMillis_1 - startTime); |
281 | _builder_1.append("_"); | 281 | InputOutput.<String>print("<<END"); |
282 | _builder_1.append(representationIndex); | 282 | Class<? extends LogicResult> _class = solution.getClass(); |
283 | _builder_1.append(".png"); | 283 | String _string = Boolean.valueOf(Objects.equal(_class, ModelResultImpl.class)).toString(); |
284 | png.writeToFile(workspace, _builder_1.toString()); | 284 | String _plus_31 = ((((((GeneratePledgeModels.DOMAIN + ",") + Boolean.valueOf(GeneratePledgeModels.QUERIES)) + ",") + Integer.valueOf(size)) + ",") + _string); |
285 | } else { | 285 | String _plus_32 = (_plus_31 + |
286 | StringConcatenation _builder_2 = new StringConcatenation(); | 286 | ","); |
287 | _builder_2.append("solution"); | 287 | String _plus_33 = (_plus_32 + Integer.valueOf(GeneratePledgeModels.RUNTIME)); |
288 | _builder_2.append(representationIndex); | 288 | String _plus_34 = (_plus_33 + ","); |
289 | _builder_2.append(".txt"); | 289 | String _plus_35 = (_plus_34 + Double.valueOf((measuredTime / 1000.0))); |
290 | workspace.writeText(_builder_2.toString(), representation.toString()); | 290 | String _plus_36 = (_plus_35 + ","); |
291 | } | 291 | int _transformationTime = solution.getStatistics().getTransformationTime(); |
292 | } | 292 | double _divide = (_transformationTime / 1000.0); |
293 | } | 293 | String _plus_37 = (_plus_36 + Double.valueOf(_divide)); |
294 | } | 294 | String _plus_38 = (_plus_37 + |
295 | 295 | ","); | |
296 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | 296 | int _solverTime = solution.getStatistics().getSolverTime(); |
297 | String _xblockexpression = null; | 297 | double _divide_1 = (_solverTime / 1000.0); |
298 | { | 298 | String _plus_39 = (_plus_38 + Double.valueOf(_divide_1)); |
299 | final Statistics stats = solution.getStatistics(); | 299 | final String toAddtoCSV = (_plus_39 + "\n"); |
300 | InputOutput.<String>println(" Statistics:"); | 300 | if (GeneratePledgeModels.GLOBAL_WRT) { |
301 | Object _xifexpression = null; | 301 | global_writer.append(toAddtoCSV); |
302 | if ((config.typeScopes.maxNewElements == 2147483647)) { | 302 | } |
303 | _xifexpression = "*"; | 303 | if (GeneratePledgeModels.INDIV_WRT) { |
304 | } else { | 304 | indiv_writer.append(toAddtoCSV); |
305 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); | 305 | } |
306 | } | 306 | InputOutput.<String>println((("->" + Double.valueOf((measuredTime / 1000.0))) + "s")); |
307 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); | 307 | try { |
308 | String _plus_1 = (_plus + "]"); | 308 | if ((solution instanceof ModelResult)) { |
309 | InputOutput.<String>println(_plus_1); | 309 | String _plus_40 = (Integer.valueOf(size) + "_"); |
310 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); | 310 | String _plus_41 = (_plus_40 + Integer.valueOf(i)); |
311 | } | 311 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, modelsws, _plus_41, reasoner, modelGenerationProblem); |
312 | return _xblockexpression; | 312 | InputOutput.<String>println(" (XMI Success)"); |
313 | } | 313 | } |
314 | } | 314 | } catch (final Throwable _t) { |
315 | if (_t instanceof Exception) { | ||
316 | final Exception e = (Exception)_t; | ||
317 | String _message = e.getMessage(); | ||
318 | String _plus_42 = (" (XMI Error)" + _message); | ||
319 | System.err.println(_plus_42); | ||
320 | } else { | ||
321 | throw Exceptions.sneakyThrow(_t); | ||
322 | } | ||
323 | } | ||
324 | try { | ||
325 | if ((solution instanceof ModelResult)) { | ||
326 | String _plus_40 = (Integer.valueOf(size) + "_"); | ||
327 | String _plus_41 = (_plus_40 + Integer.valueOf(i)); | ||
328 | GeneratePledgeModels.writeRepresentation(solution, modelsws, _plus_41); | ||
329 | InputOutput.<String>println(" (VIZ Success) >>"); | ||
330 | } | ||
331 | } catch (final Throwable _t) { | ||
332 | if (_t instanceof Exception) { | ||
333 | final Exception e = (Exception)_t; | ||
334 | String _message = e.getMessage(); | ||
335 | String _plus_42 = (" (VIZ Error)" + _message); | ||
336 | String _plus_43 = (_plus_42 + ">>"); | ||
337 | System.err.println(_plus_43); | ||
338 | } else { | ||
339 | throw Exceptions.sneakyThrow(_t); | ||
340 | } | ||
341 | } | ||
342 | InputOutput.println(); | ||
343 | final Runtime r = Runtime.getRuntime(); | ||
344 | r.gc(); | ||
345 | r.gc(); | ||
346 | r.gc(); | ||
347 | Thread.sleep(3000); | ||
348 | } | ||
349 | } | ||
350 | if (GeneratePledgeModels.INDIV_WRT) { | ||
351 | indiv_writer.close(); | ||
352 | } | ||
353 | } | ||
354 | int _size = size; | ||
355 | size = (_size + NEXT_INC); | ||
356 | _while = (size <= GeneratePledgeModels.SIZE_UB); | ||
357 | } | ||
358 | } | ||
359 | if (GeneratePledgeModels.GLOBAL_WRT) { | ||
360 | global_writer.close(); | ||
361 | } | ||
362 | } catch (Throwable _e) { | ||
363 | throw Exceptions.sneakyThrow(_e); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | ||
368 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | ||
369 | final Function1<EClass, String> _function = (EClass s) -> { | ||
370 | return s.getName(); | ||
371 | }; | ||
372 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | ||
373 | Set<Class> _keySet = classMap.keySet(); | ||
374 | for (final Class elem : _keySet) { | ||
375 | typeMap.put( | ||
376 | e2l.TypeofEClass(trace, | ||
377 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | ||
378 | } | ||
379 | return typeMap; | ||
380 | } | ||
381 | |||
382 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | ||
383 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | ||
384 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | ||
385 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | ||
386 | return it.getELiterals(); | ||
387 | }; | ||
388 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | ||
389 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | ||
390 | return it.getEReferences(); | ||
391 | }; | ||
392 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | ||
393 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | ||
394 | return it.getEAttributes(); | ||
395 | }; | ||
396 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | ||
397 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | ||
398 | } | ||
399 | |||
400 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | ||
401 | EList<EObject> _xblockexpression = null; | ||
402 | { | ||
403 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
404 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
405 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | ||
406 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | ||
407 | } | ||
408 | return _xblockexpression; | ||
409 | } | ||
410 | |||
411 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | ||
412 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | ||
413 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | ||
414 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | ||
415 | String _name = it_1.getName(); | ||
416 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | ||
417 | }; | ||
418 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | ||
419 | }; | ||
420 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | ||
421 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | ||
422 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | ||
423 | return res; | ||
424 | } | ||
425 | |||
426 | 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) { | ||
427 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | ||
428 | int _size = interpretations.size(); | ||
429 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
430 | for (final Integer interpIndex : _doubleDotLessThan) { | ||
431 | { | ||
432 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | ||
433 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | ||
434 | StringConcatenation _builder = new StringConcatenation(); | ||
435 | _builder.append("sol-"); | ||
436 | _builder.append(id); | ||
437 | _builder.append("_"); | ||
438 | _builder.append(interpIndex); | ||
439 | _builder.append(".xmi"); | ||
440 | workspace.writeModel(model, _builder.toString()); | ||
441 | } | ||
442 | } | ||
443 | } | ||
444 | |||
445 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final String id) { | ||
446 | final EList<Object> representations = solution.getRepresentation(); | ||
447 | int _size = representations.size(); | ||
448 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
449 | for (final Integer representationIndex : _doubleDotLessThan) { | ||
450 | { | ||
451 | final Object representation = representations.get((representationIndex).intValue()); | ||
452 | if ((representation instanceof PartialInterpretation)) { | ||
453 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | ||
454 | StringConcatenation _builder = new StringConcatenation(); | ||
455 | _builder.append("sol-"); | ||
456 | _builder.append(id); | ||
457 | _builder.append("_"); | ||
458 | _builder.append(representationIndex); | ||
459 | _builder.append(".gml"); | ||
460 | workspace.writeText(_builder.toString(), gml); | ||
461 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | ||
462 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
463 | _builder_1.append("sol-"); | ||
464 | _builder_1.append(id); | ||
465 | _builder_1.append("_"); | ||
466 | _builder_1.append(representationIndex); | ||
467 | _builder_1.append(".png"); | ||
468 | png.writeToFile(workspace, _builder_1.toString()); | ||
469 | } else { | ||
470 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
471 | _builder_2.append("sol-"); | ||
472 | _builder_2.append(representationIndex); | ||
473 | _builder_2.append(".txt"); | ||
474 | workspace.writeText(_builder_2.toString(), representation.toString()); | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | |||
480 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | ||
481 | String _xblockexpression = null; | ||
482 | { | ||
483 | final Statistics stats = solution.getStatistics(); | ||
484 | InputOutput.<String>println(" Statistics:"); | ||
485 | Object _xifexpression = null; | ||
486 | if ((config.typeScopes.maxNewElements == 2147483647)) { | ||
487 | _xifexpression = "*"; | ||
488 | } else { | ||
489 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); | ||
490 | } | ||
491 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); | ||
492 | String _plus_1 = (_plus + "]"); | ||
493 | InputOutput.<String>println(_plus_1); | ||
494 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); | ||
495 | } | ||
496 | return _xblockexpression; | ||
497 | } | ||
498 | } | ||