diff options
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen')
2 files changed, 314 insertions, 314 deletions
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 3430ce88..163f84a1 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/GeneratePledgeModels.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/xtend-gen/run/GeneratePledgeModels.java index 35ddb32f..2809679d 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,314 @@ | |||
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 com.google.inject.Injector; |
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.logic2ecore.Logic2Ecore; |
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | 20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; |
21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | 21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | 22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; |
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | 24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; |
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | 27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; |
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
29 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | 29 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; |
30 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | 30 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; |
31 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | 31 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; |
32 | import java.math.BigDecimal; | 32 | import java.math.BigDecimal; |
33 | import java.text.SimpleDateFormat; | 33 | import java.text.SimpleDateFormat; |
34 | import java.util.Collections; | 34 | import java.util.Collections; |
35 | import java.util.Date; | 35 | import java.util.Date; |
36 | import java.util.HashMap; | 36 | import java.util.HashMap; |
37 | import java.util.List; | 37 | import java.util.List; |
38 | import java.util.Map; | 38 | import java.util.Map; |
39 | import java.util.Set; | 39 | import java.util.Set; |
40 | import java.util.TreeSet; | 40 | import java.util.TreeSet; |
41 | import org.eclipse.emf.common.util.EList; | 41 | import org.eclipse.emf.common.util.EList; |
42 | import org.eclipse.emf.ecore.EAttribute; | 42 | import org.eclipse.emf.ecore.EAttribute; |
43 | import org.eclipse.emf.ecore.EClass; | 43 | import org.eclipse.emf.ecore.EClass; |
44 | import org.eclipse.emf.ecore.EEnum; | 44 | import org.eclipse.emf.ecore.EEnum; |
45 | import org.eclipse.emf.ecore.EEnumLiteral; | 45 | import org.eclipse.emf.ecore.EEnumLiteral; |
46 | import org.eclipse.emf.ecore.EObject; | 46 | import org.eclipse.emf.ecore.EObject; |
47 | import org.eclipse.emf.ecore.EPackage; | 47 | import org.eclipse.emf.ecore.EPackage; |
48 | import org.eclipse.emf.ecore.EReference; | 48 | import org.eclipse.emf.ecore.EReference; |
49 | import org.eclipse.emf.ecore.EStructuralFeature; | 49 | import org.eclipse.emf.ecore.EStructuralFeature; |
50 | import org.eclipse.emf.ecore.resource.Resource; | 50 | import org.eclipse.emf.ecore.resource.Resource; |
51 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | 51 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
52 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | 52 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; |
53 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; | 53 | import org.eclipse.viatra.query.runtime.api.IQueryGroup; |
54 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | 54 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; |
55 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 55 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; |
56 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; | 56 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; |
57 | import org.eclipse.xtend2.lib.StringConcatenation; | 57 | import org.eclipse.xtend2.lib.StringConcatenation; |
58 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; | 58 | import org.eclipse.xtext.xbase.lib.CollectionExtensions; |
59 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | 59 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
60 | import org.eclipse.xtext.xbase.lib.Exceptions; | 60 | import org.eclipse.xtext.xbase.lib.Exceptions; |
61 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | 61 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; |
62 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | 62 | import org.eclipse.xtext.xbase.lib.Functions.Function1; |
63 | import org.eclipse.xtext.xbase.lib.InputOutput; | 63 | import org.eclipse.xtext.xbase.lib.InputOutput; |
64 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | 64 | import org.eclipse.xtext.xbase.lib.IterableExtensions; |
65 | import org.eclipse.xtext.xbase.lib.ListExtensions; | 65 | import org.eclipse.xtext.xbase.lib.ListExtensions; |
66 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | 66 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; |
67 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | 67 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; |
68 | 68 | ||
69 | @SuppressWarnings("all") | 69 | @SuppressWarnings("all") |
70 | public class GeneratePledgeModels { | 70 | public class GeneratePledgeModels { |
71 | public static void main(final String[] args) { | 71 | public static void main(final String[] args) { |
72 | try { | 72 | try { |
73 | final Injector x = new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); | 73 | final Injector x = new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); |
74 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 74 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
75 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 75 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
76 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); | 76 | _extensionToFactoryMap.put("xmi", _xMIResourceFactoryImpl); |
77 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 77 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
78 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); | 78 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); |
79 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); | 79 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); |
80 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 80 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
81 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); | 81 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); |
82 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); | 82 | _extensionToFactoryMap_2.put("partialmodel", _xMIResourceFactoryImpl_2); |
83 | ReteEngine.class.getClass(); | 83 | ReteEngine.class.getClass(); |
84 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); | 84 | final Ecore2Logic ecore2Logic = new Ecore2Logic(); |
85 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); | 85 | final Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic); |
86 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); | 86 | final Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic); |
87 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | 87 | final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); |
88 | long _currentTimeMillis = System.currentTimeMillis(); | 88 | long _currentTimeMillis = System.currentTimeMillis(); |
89 | final Date date = new Date(_currentTimeMillis); | 89 | final Date date = new Date(_currentTimeMillis); |
90 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); | 90 | final SimpleDateFormat format = new SimpleDateFormat("dd-HHmm"); |
91 | final String formattedDate = format.format(date); | 91 | final String formattedDate = format.format(date); |
92 | StringConcatenation _builder = new StringConcatenation(); | 92 | StringConcatenation _builder = new StringConcatenation(); |
93 | _builder.append("inputs/"); | 93 | _builder.append("inputs/"); |
94 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); | 94 | final FileSystemWorkspace inputs = new FileSystemWorkspace(_builder.toString(), ""); |
95 | StringConcatenation _builder_1 = new StringConcatenation(); | 95 | StringConcatenation _builder_1 = new StringConcatenation(); |
96 | _builder_1.append("output/"); | 96 | _builder_1.append("output/"); |
97 | String _plus = (_builder_1.toString() + formattedDate); | 97 | String _plus = (_builder_1.toString() + formattedDate); |
98 | StringConcatenation _builder_2 = new StringConcatenation(); | 98 | StringConcatenation _builder_2 = new StringConcatenation(); |
99 | _builder_2.append("/"); | 99 | _builder_2.append("/"); |
100 | String _plus_1 = (_plus + _builder_2); | 100 | String _plus_1 = (_plus + _builder_2); |
101 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_1, ""); | 101 | final FileSystemWorkspace workspace = new FileSystemWorkspace(_plus_1, ""); |
102 | StringConcatenation _builder_3 = new StringConcatenation(); | 102 | StringConcatenation _builder_3 = new StringConcatenation(); |
103 | _builder_3.append("output/"); | 103 | _builder_3.append("output/"); |
104 | String _plus_2 = (_builder_3.toString() + formattedDate); | 104 | String _plus_2 = (_builder_3.toString() + formattedDate); |
105 | StringConcatenation _builder_4 = new StringConcatenation(); | 105 | StringConcatenation _builder_4 = new StringConcatenation(); |
106 | _builder_4.append("/debug/"); | 106 | _builder_4.append("/debug/"); |
107 | String _plus_3 = (_plus_2 + _builder_4); | 107 | String _plus_3 = (_plus_2 + _builder_4); |
108 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_3, ""); | 108 | final FileSystemWorkspace debug = new FileSystemWorkspace(_plus_3, ""); |
109 | workspace.initAndClear(); | 109 | workspace.initAndClear(); |
110 | InputOutput.<String>println("Input and output workspaces are created"); | 110 | InputOutput.<String>println("Input and output workspaces are created"); |
111 | final EcoreMetamodelDescriptor metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); | 111 | final EcoreMetamodelDescriptor metamodel = GeneratePledgeModels.loadMetamodel(TaxationPackage.eINSTANCE); |
112 | final EList<EObject> partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); | 112 | final EList<EObject> partialModel = GeneratePledgeModels.loadPartialModel(inputs, "Household.xmi"); |
113 | InputOutput.<String>println("DSL loaded"); | 113 | InputOutput.<String>println("DSL loaded"); |
114 | final int SIZE = 2; | 114 | final int SIZE = 2; |
115 | int REPS = 1; | 115 | int REPS = 1; |
116 | final int RUNTIME = 600; | 116 | final int RUNTIME = 600; |
117 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | 117 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); |
118 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | 118 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); |
119 | LogicProblem problem = modelGenerationProblem.getOutput(); | 119 | LogicProblem problem = modelGenerationProblem.getOutput(); |
120 | debug.writeModel(problem, "problem.logicproblem"); | 120 | debug.writeModel(problem, "problem.logicproblem"); |
121 | InputOutput.<String>println("Problem created"); | 121 | InputOutput.<String>println("Problem created"); |
122 | for (int i = 0; (i < REPS); i++) { | 122 | for (int i = 0; (i < REPS); i++) { |
123 | { | 123 | { |
124 | ViatraReasoner reasoner = new ViatraReasoner(); | 124 | ViatraReasoner reasoner = new ViatraReasoner(); |
125 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); | 125 | final TreeSet<Integer> knownIntegers = new TreeSet<Integer>(); |
126 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0)); | 126 | CollectionExtensions.<Integer>addAll(knownIntegers, Integer.valueOf(0)); |
127 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); | 127 | final TreeSet<BigDecimal> knownReals = new TreeSet<BigDecimal>(); |
128 | BigDecimal _bigDecimal = new BigDecimal("0.0"); | 128 | BigDecimal _bigDecimal = new BigDecimal("0.0"); |
129 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); | 129 | CollectionExtensions.<BigDecimal>addAll(knownReals, _bigDecimal); |
130 | final TreeSet<String> knownStrings = new TreeSet<String>(); | 130 | final TreeSet<String> knownStrings = new TreeSet<String>(); |
131 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2"); | 131 | CollectionExtensions.<String>addAll(knownStrings, "r0", "r1", "r2"); |
132 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | 132 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); |
133 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { | 133 | final Procedure1<ViatraReasonerConfiguration> _function = (ViatraReasonerConfiguration it) -> { |
134 | it.documentationLevel = DocumentationLevel.FULL; | 134 | it.documentationLevel = DocumentationLevel.FULL; |
135 | DebugConfiguration _debugConfiguration = new DebugConfiguration(); | 135 | DebugConfiguration _debugConfiguration = new DebugConfiguration(); |
136 | final Procedure1<DebugConfiguration> _function_1 = (DebugConfiguration it_1) -> { | 136 | final Procedure1<DebugConfiguration> _function_1 = (DebugConfiguration it_1) -> { |
137 | it_1.logging = true; | 137 | it_1.logging = true; |
138 | }; | 138 | }; |
139 | DebugConfiguration _doubleArrow = ObjectExtensions.<DebugConfiguration>operator_doubleArrow(_debugConfiguration, _function_1); | 139 | DebugConfiguration _doubleArrow = ObjectExtensions.<DebugConfiguration>operator_doubleArrow(_debugConfiguration, _function_1); |
140 | it.debugCongiguration = _doubleArrow; | 140 | it.debugCongiguration = _doubleArrow; |
141 | it.runtimeLimit = RUNTIME; | 141 | it.runtimeLimit = RUNTIME; |
142 | boolean _isEmpty = knownIntegers.isEmpty(); | 142 | boolean _isEmpty = knownIntegers.isEmpty(); |
143 | boolean _not = (!_isEmpty); | 143 | boolean _not = (!_isEmpty); |
144 | if (_not) { | 144 | if (_not) { |
145 | it.typeScopes.knownIntegers = knownIntegers; | 145 | it.typeScopes.knownIntegers = knownIntegers; |
146 | } | 146 | } |
147 | boolean _isEmpty_1 = knownReals.isEmpty(); | 147 | boolean _isEmpty_1 = knownReals.isEmpty(); |
148 | boolean _not_1 = (!_isEmpty_1); | 148 | boolean _not_1 = (!_isEmpty_1); |
149 | if (_not_1) { | 149 | if (_not_1) { |
150 | it.typeScopes.knownReals = knownReals; | 150 | it.typeScopes.knownReals = knownReals; |
151 | } | 151 | } |
152 | }; | 152 | }; |
153 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); | 153 | final ViatraReasonerConfiguration solverConfig = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function); |
154 | InputOutput.<String>println((("Run #" + Integer.valueOf(i)) + ":")); | 154 | InputOutput.<String>println((("Run #" + Integer.valueOf(i)) + ":")); |
155 | final long startTime = System.currentTimeMillis(); | 155 | final long startTime = System.currentTimeMillis(); |
156 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); | 156 | LogicResult solution = reasoner.solve(problem, solverConfig, debug); |
157 | long _currentTimeMillis_1 = System.currentTimeMillis(); | 157 | long _currentTimeMillis_1 = System.currentTimeMillis(); |
158 | final long totalTime = (_currentTimeMillis_1 - startTime); | 158 | final long totalTime = (_currentTimeMillis_1 - startTime); |
159 | InputOutput.<String>println(" Problem Solved"); | 159 | InputOutput.<String>println(" Problem Solved"); |
160 | GeneratePledgeModels.writeStats(solution, totalTime, solverConfig); | 160 | GeneratePledgeModels.writeStats(solution, totalTime, solverConfig); |
161 | if ((solution instanceof ModelResult)) { | 161 | if ((solution instanceof ModelResult)) { |
162 | GeneratePledgeModels.writeRepresentation(solution, workspace, i); | 162 | GeneratePledgeModels.writeRepresentation(solution, workspace, i); |
163 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, workspace, i, reasoner, modelGenerationProblem); | 163 | GeneratePledgeModels.writeInterpretation(solution, logic2Ecore, workspace, i, reasoner, modelGenerationProblem); |
164 | InputOutput.<String>println(" Solution saved and visualised"); | 164 | InputOutput.<String>println(" Solution saved and visualised"); |
165 | } else { | 165 | } else { |
166 | String _string = solution.getClass().getSimpleName().toString(); | 166 | String _string = solution.getClass().getSimpleName().toString(); |
167 | String _plus_4 = (" Returned: " + _string); | 167 | String _plus_4 = (" Returned: " + _string); |
168 | InputOutput.<String>println(_plus_4); | 168 | InputOutput.<String>println(_plus_4); |
169 | } | 169 | } |
170 | final Runtime r = Runtime.getRuntime(); | 170 | final Runtime r = Runtime.getRuntime(); |
171 | r.gc(); | 171 | r.gc(); |
172 | r.gc(); | 172 | r.gc(); |
173 | r.gc(); | 173 | r.gc(); |
174 | Thread.sleep(3000); | 174 | Thread.sleep(3000); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | InputOutput.<String>println("---End---"); | 177 | InputOutput.<String>println("---End---"); |
178 | } catch (Throwable _e) { | 178 | } catch (Throwable _e) { |
179 | throw Exceptions.sneakyThrow(_e); | 179 | throw Exceptions.sneakyThrow(_e); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { | 183 | public static Map<Type, Integer> getTypeMap(final Map<Class, Integer> classMap, final EcoreMetamodelDescriptor metamodel, final Ecore2Logic e2l, final Ecore2Logic_Trace trace) { |
184 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); | 184 | final HashMap<Type, Integer> typeMap = new HashMap<Type, Integer>(); |
185 | final Function1<EClass, String> _function = (EClass s) -> { | 185 | final Function1<EClass, String> _function = (EClass s) -> { |
186 | return s.getName(); | 186 | return s.getName(); |
187 | }; | 187 | }; |
188 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); | 188 | final Map<String, EClass> listMap = IterableExtensions.<String, EClass>toMap(metamodel.getClasses(), _function); |
189 | Set<Class> _keySet = classMap.keySet(); | 189 | Set<Class> _keySet = classMap.keySet(); |
190 | for (final Class elem : _keySet) { | 190 | for (final Class elem : _keySet) { |
191 | typeMap.put( | 191 | typeMap.put( |
192 | e2l.TypeofEClass(trace, | 192 | e2l.TypeofEClass(trace, |
193 | listMap.get(elem.getSimpleName())), classMap.get(elem)); | 193 | listMap.get(elem.getSimpleName())), classMap.get(elem)); |
194 | } | 194 | } |
195 | return typeMap; | 195 | return typeMap; |
196 | } | 196 | } |
197 | 197 | ||
198 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { | 198 | public static EcoreMetamodelDescriptor loadMetamodel(final EPackage pckg) { |
199 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); | 199 | final List<EClass> classes = IterableExtensions.<EClass>toList(Iterables.<EClass>filter(pckg.getEClassifiers(), EClass.class)); |
200 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); | 200 | final List<EEnum> enums = IterableExtensions.<EEnum>toList(Iterables.<EEnum>filter(pckg.getEClassifiers(), EEnum.class)); |
201 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { | 201 | final Function1<EEnum, EList<EEnumLiteral>> _function = (EEnum it) -> { |
202 | return it.getELiterals(); | 202 | return it.getELiterals(); |
203 | }; | 203 | }; |
204 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); | 204 | final List<EEnumLiteral> literals = IterableExtensions.<EEnumLiteral>toList(Iterables.<EEnumLiteral>concat(ListExtensions.<EEnum, EList<EEnumLiteral>>map(enums, _function))); |
205 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { | 205 | final Function1<EClass, EList<EReference>> _function_1 = (EClass it) -> { |
206 | return it.getEReferences(); | 206 | return it.getEReferences(); |
207 | }; | 207 | }; |
208 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); | 208 | final List<EReference> references = IterableExtensions.<EReference>toList(Iterables.<EReference>concat(ListExtensions.<EClass, EList<EReference>>map(classes, _function_1))); |
209 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { | 209 | final Function1<EClass, EList<EAttribute>> _function_2 = (EClass it) -> { |
210 | return it.getEAttributes(); | 210 | return it.getEAttributes(); |
211 | }; | 211 | }; |
212 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); | 212 | final List<EAttribute> attributes = IterableExtensions.<EAttribute>toList(Iterables.<EAttribute>concat(ListExtensions.<EClass, EList<EAttribute>>map(classes, _function_2))); |
213 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); | 213 | return new EcoreMetamodelDescriptor(classes, Collections.<EClass>unmodifiableSet(CollectionLiterals.<EClass>newHashSet()), false, enums, literals, references, attributes); |
214 | } | 214 | } |
215 | 215 | ||
216 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { | 216 | public static EList<EObject> loadPartialModel(final ReasonerWorkspace inputs, final String path) { |
217 | EList<EObject> _xblockexpression = null; | 217 | EList<EObject> _xblockexpression = null; |
218 | { | 218 | { |
219 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 219 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
220 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 220 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
221 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | 221 | _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); |
222 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); | 222 | _xblockexpression = inputs.<EObject>readModel(EObject.class, path).eResource().getContents(); |
223 | } | 223 | } |
224 | return _xblockexpression; | 224 | return _xblockexpression; |
225 | } | 225 | } |
226 | 226 | ||
227 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { | 227 | public static ViatraQuerySetDescriptor loadQueries(final EcoreMetamodelDescriptor metamodel, final IQueryGroup i) { |
228 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); | 228 | final List<IQuerySpecification<?>> patterns = IterableExtensions.<IQuerySpecification<?>>toList(i.getSpecifications()); |
229 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { | 229 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> it) -> { |
230 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { | 230 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it_1) -> { |
231 | String _name = it_1.getName(); | 231 | String _name = it_1.getName(); |
232 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | 232 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); |
233 | }; | 233 | }; |
234 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); | 234 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(it.getAllAnnotations(), _function_1)); |
235 | }; | 235 | }; |
236 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | 236 | final Set<IQuerySpecification<?>> wfPatterns = IterableExtensions.<IQuerySpecification<?>>toSet(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); |
237 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | 237 | final Map<IQuerySpecification<?>, EStructuralFeature> derivedFeatures = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); |
238 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); | 238 | final ViatraQuerySetDescriptor res = new ViatraQuerySetDescriptor(patterns, wfPatterns, derivedFeatures); |
239 | return res; | 239 | return res; |
240 | } | 240 | } |
241 | 241 | ||
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 | 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) { |
243 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); | 243 | final List<? extends LogicModelInterpretation> interpretations = reasoner.getInterpretations(((ModelResult) solution)); |
244 | int _size = interpretations.size(); | 244 | int _size = interpretations.size(); |
245 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 245 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); |
246 | for (final Integer interpIndex : _doubleDotLessThan) { | 246 | for (final Integer interpIndex : _doubleDotLessThan) { |
247 | { | 247 | { |
248 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); | 248 | final LogicModelInterpretation interpretation = interpretations.get((interpIndex).intValue()); |
249 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); | 249 | final EObject model = logic2Ecore.transformInterpretation(interpretation, mgProb.getTrace()); |
250 | StringConcatenation _builder = new StringConcatenation(); | 250 | StringConcatenation _builder = new StringConcatenation(); |
251 | _builder.append("solution"); | 251 | _builder.append("solution"); |
252 | _builder.append(i); | 252 | _builder.append(i); |
253 | _builder.append("_"); | 253 | _builder.append("_"); |
254 | _builder.append(interpIndex); | 254 | _builder.append(interpIndex); |
255 | _builder.append(".xmi"); | 255 | _builder.append(".xmi"); |
256 | workspace.writeModel(model, _builder.toString()); | 256 | workspace.writeModel(model, _builder.toString()); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final int i) { | 261 | public static void writeRepresentation(final LogicResult solution, final ReasonerWorkspace workspace, final int i) { |
262 | final EList<Object> representations = solution.getRepresentation(); | 262 | final EList<Object> representations = solution.getRepresentation(); |
263 | int _size = representations.size(); | 263 | int _size = representations.size(); |
264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | 264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); |
265 | for (final Integer representationIndex : _doubleDotLessThan) { | 265 | for (final Integer representationIndex : _doubleDotLessThan) { |
266 | { | 266 | { |
267 | final Object representation = representations.get((representationIndex).intValue()); | 267 | final Object representation = representations.get((representationIndex).intValue()); |
268 | if ((representation instanceof PartialInterpretation)) { | 268 | if ((representation instanceof PartialInterpretation)) { |
269 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); | 269 | final String gml = new PartialInterpretation2Gml().transform(((PartialInterpretation)representation)); |
270 | StringConcatenation _builder = new StringConcatenation(); | 270 | StringConcatenation _builder = new StringConcatenation(); |
271 | _builder.append("solution"); | 271 | _builder.append("solution"); |
272 | _builder.append(i); | 272 | _builder.append(i); |
273 | _builder.append("_"); | 273 | _builder.append("_"); |
274 | _builder.append(representationIndex); | 274 | _builder.append(representationIndex); |
275 | _builder.append(".gml"); | 275 | _builder.append(".gml"); |
276 | workspace.writeText(_builder.toString(), gml); | 276 | workspace.writeText(_builder.toString(), gml); |
277 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); | 277 | final PartialInterpretationVisualisation png = new GraphvizVisualiser().visualiseConcretization(((PartialInterpretation)representation)); |
278 | StringConcatenation _builder_1 = new StringConcatenation(); | 278 | StringConcatenation _builder_1 = new StringConcatenation(); |
279 | _builder_1.append("solution"); | 279 | _builder_1.append("solution"); |
280 | _builder_1.append(i); | 280 | _builder_1.append(i); |
281 | _builder_1.append("_"); | 281 | _builder_1.append("_"); |
282 | _builder_1.append(representationIndex); | 282 | _builder_1.append(representationIndex); |
283 | _builder_1.append(".png"); | 283 | _builder_1.append(".png"); |
284 | png.writeToFile(workspace, _builder_1.toString()); | 284 | png.writeToFile(workspace, _builder_1.toString()); |
285 | } else { | 285 | } else { |
286 | StringConcatenation _builder_2 = new StringConcatenation(); | 286 | StringConcatenation _builder_2 = new StringConcatenation(); |
287 | _builder_2.append("solution"); | 287 | _builder_2.append("solution"); |
288 | _builder_2.append(representationIndex); | 288 | _builder_2.append(representationIndex); |
289 | _builder_2.append(".txt"); | 289 | _builder_2.append(".txt"); |
290 | workspace.writeText(_builder_2.toString(), representation.toString()); | 290 | workspace.writeText(_builder_2.toString(), representation.toString()); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { | 296 | public static String writeStats(final LogicResult solution, final long time, final ViatraReasonerConfiguration config) { |
297 | String _xblockexpression = null; | 297 | String _xblockexpression = null; |
298 | { | 298 | { |
299 | final Statistics stats = solution.getStatistics(); | 299 | final Statistics stats = solution.getStatistics(); |
300 | InputOutput.<String>println(" Statistics:"); | 300 | InputOutput.<String>println(" Statistics:"); |
301 | Object _xifexpression = null; | 301 | Object _xifexpression = null; |
302 | if ((config.typeScopes.maxNewElements == 2147483647)) { | 302 | if ((config.typeScopes.maxNewElements == 2147483647)) { |
303 | _xifexpression = "*"; | 303 | _xifexpression = "*"; |
304 | } else { | 304 | } else { |
305 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); | 305 | _xifexpression = Integer.valueOf(config.typeScopes.maxNewElements); |
306 | } | 306 | } |
307 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); | 307 | String _plus = (((" #new nodes : [" + Integer.valueOf(config.typeScopes.minNewElements)) + "..") + _xifexpression); |
308 | String _plus_1 = (_plus + "]"); | 308 | String _plus_1 = (_plus + "]"); |
309 | InputOutput.<String>println(_plus_1); | 309 | InputOutput.<String>println(_plus_1); |
310 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); | 310 | _xblockexpression = InputOutput.<String>println(((" \"solve\" time: " + Double.valueOf((((double) time) / 1000))) + " s")); |
311 | } | 311 | } |
312 | return _xblockexpression; | 312 | return _xblockexpression; |
313 | } | 313 | } |
314 | } | 314 | } |