diff options
6 files changed, 225 insertions, 5 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql index a4c3125d..afee1332 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql | |||
@@ -40,6 +40,7 @@ pattern multipleTransitionFromEntry(e : Entry, t1 : Transition, t2: Transition) | |||
40 | t1!=t2; | 40 | t1!=t2; |
41 | } | 41 | } |
42 | 42 | ||
43 | |||
43 | @Constraint(severity="error", message="error", key = {s}) | 44 | @Constraint(severity="error", message="error", key = {s}) |
44 | pattern hasNoOutgoing(s : Synchronization) { | 45 | pattern hasNoOutgoing(s : Synchronization) { |
45 | neg find transition(_, s, _); | 46 | neg find transition(_, s, _); |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend index dac5630b..cac614ad 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend | |||
@@ -30,7 +30,7 @@ import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | |||
30 | } | 30 | } |
31 | 31 | ||
32 | class PatternProvider { | 32 | class PatternProvider { |
33 | val ParseUtil parseUtil = new ParseUtil | 33 | |
34 | val TypeAnalysis typeAnalysis = new TypeAnalysis | 34 | val TypeAnalysis typeAnalysis = new TypeAnalysis |
35 | 35 | ||
36 | public def generateQueries( | 36 | public def generateQueries( |
@@ -54,6 +54,7 @@ class PatternProvider { | |||
54 | } | 54 | } |
55 | val baseIndexerFile = patternGenerator.transformBaseProperties(problem,emptySolution,fqn2Query,typeAnalysisResult) | 55 | val baseIndexerFile = patternGenerator.transformBaseProperties(problem,emptySolution,fqn2Query,typeAnalysisResult) |
56 | writeQueries(baseIndexerFile,"GeneratedQueries",workspace) | 56 | writeQueries(baseIndexerFile,"GeneratedQueries",workspace) |
57 | val ParseUtil parseUtil = new ParseUtil | ||
57 | val generatedQueries = parseUtil.parse(baseIndexerFile) | 58 | val generatedQueries = parseUtil.parse(baseIndexerFile) |
58 | val runtimeQueries = calclulateRuntimeQueries(patternGenerator,problem,emptySolution,typeAnalysisResult,generatedQueries); | 59 | val runtimeQueries = calclulateRuntimeQueries(patternGenerator,problem,emptySolution,typeAnalysisResult,generatedQueries); |
59 | return runtimeQueries | 60 | return runtimeQueries |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend index 38cc9459..5d8859bd 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend | |||
@@ -128,6 +128,12 @@ class ViatraReasoner extends LogicReasoner{ | |||
128 | //it.solverTime = viatraConfig.runtimeLimit | 128 | //it.solverTime = viatraConfig.runtimeLimit |
129 | it.solverTime = (solverTime/1000000) as int | 129 | it.solverTime = (solverTime/1000000) as int |
130 | it.transformationTime = (transformationTime/1000000) as int | 130 | it.transformationTime = (transformationTime/1000000) as int |
131 | for(x : 0..<strategy.solutionStoreWithCopy.allRuntimes.size) { | ||
132 | it.entries += createIntStatisticEntry => [ | ||
133 | it.name = '''_Sulution«x»FoundAt''' | ||
134 | it.value = strategy.solutionStoreWithCopy.allRuntimes.get(x).intValue | ||
135 | ] | ||
136 | } | ||
131 | it.entries += createIntStatisticEntry => [ | 137 | it.entries += createIntStatisticEntry => [ |
132 | it.name = "TransformationExecutionTime" it.value = (method.statistics.transformationExecutionTime/1000000) as int | 138 | it.name = "TransformationExecutionTime" it.value = (method.statistics.transformationExecutionTime/1000000) as int |
133 | ] | 139 | ] |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionStoreWithCopy.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionStoreWithCopy.xtend index 2892723b..679b9600 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionStoreWithCopy.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionStoreWithCopy.xtend | |||
@@ -9,11 +9,13 @@ import org.eclipse.emf.ecore.util.EcoreUtil | |||
9 | import org.eclipse.viatra.dse.base.ThreadContext | 9 | import org.eclipse.viatra.dse.base.ThreadContext |
10 | 10 | ||
11 | class SolutionStoreWithCopy { | 11 | class SolutionStoreWithCopy { |
12 | |||
12 | long runtime = 0 | 13 | long runtime = 0 |
13 | List<PartialInterpretation> solutions = new LinkedList | 14 | List<PartialInterpretation> solutions = new LinkedList |
14 | List<Map<EObject,EObject>> copyTraces = new LinkedList | 15 | List<Map<EObject,EObject>> copyTraces = new LinkedList |
15 | 16 | ||
16 | long initTime = System.nanoTime | 17 | long sartTime = System.nanoTime |
18 | List<Long> solutionTimes = new LinkedList | ||
17 | 19 | ||
18 | def newSolution(ThreadContext context) { | 20 | def newSolution(ThreadContext context) { |
19 | //print(System.nanoTime-initTime + ";") | 21 | //print(System.nanoTime-initTime + ";") |
@@ -25,10 +27,14 @@ class SolutionStoreWithCopy { | |||
25 | solutions.add(solutionCopy) | 27 | solutions.add(solutionCopy) |
26 | copyTraces.add(copier) | 28 | copyTraces.add(copier) |
27 | runtime += System.nanoTime - copyStart | 29 | runtime += System.nanoTime - copyStart |
30 | solutionTimes.add(System.nanoTime-sartTime) | ||
28 | } | 31 | } |
29 | def getSumRuntime() { | 32 | def getSumRuntime() { |
30 | return runtime | 33 | return runtime |
31 | } | 34 | } |
35 | def getAllRuntimes() { | ||
36 | return solutionTimes | ||
37 | } | ||
32 | def getSolutions() { | 38 | def getSolutions() { |
33 | solutions | 39 | solutions |
34 | } | 40 | } |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/DiverseMeasurementRunner.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/DiverseMeasurementRunner.xtend new file mode 100644 index 00000000..f2a70552 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/DiverseMeasurementRunner.xtend | |||
@@ -0,0 +1,206 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage | ||
8 | import org.eclipse.emf.ecore.resource.Resource | ||
9 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | ||
11 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy | ||
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod | ||
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DiversityDescriptor | ||
16 | import org.eclipse.xtend.lib.annotations.Data | ||
17 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | ||
18 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | ||
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | ||
21 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
22 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | ||
23 | import org.eclipse.emf.ecore.EObject | ||
24 | import java.util.List | ||
25 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult | ||
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
28 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | ||
29 | import hu.bme.mit.inf.dslreasoner.logic.model.statistics.StatisticSections2Print | ||
30 | |||
31 | enum Metamodel { | ||
32 | FAM, YakinduWOSynch, Yakindu | ||
33 | } | ||
34 | enum Constraints { | ||
35 | None, PlusOne, MinusOne | ||
36 | } | ||
37 | enum StateCoder { | ||
38 | ID, R1, R2, R3; | ||
39 | } | ||
40 | |||
41 | @Data | ||
42 | class Scenario { | ||
43 | int number | ||
44 | int size | ||
45 | public Metamodel metamodel | ||
46 | Constraints constraints | ||
47 | StateCoder statecoder | ||
48 | int runs | ||
49 | } | ||
50 | |||
51 | class ScenarioRunner { | ||
52 | |||
53 | // Workspace | ||
54 | private val FileSystemWorkspace inputs = new FileSystemWorkspace('''initialModels/''',"") | ||
55 | private val ViatraReasoner viatraSolver = new ViatraReasoner | ||
56 | private var MetamodelLoader loader | ||
57 | |||
58 | val Ecore2Logic ecore2Logic = new Ecore2Logic | ||
59 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | ||
60 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | ||
61 | |||
62 | |||
63 | public def runScenario(Scenario scenario) { | ||
64 | init() | ||
65 | initLoader(scenario.metamodel) | ||
66 | val mm = loader.loadMetamodel() | ||
67 | val vq = loader.loadQueries(mm) | ||
68 | val ps = loader.loadPartialModel() | ||
69 | |||
70 | // printHeader(scenario) | ||
71 | |||
72 | if(scenario.constraints == Constraints.None) { | ||
73 | |||
74 | mm.attributes.forEach[it.lowerBound = 0] | ||
75 | mm.references.forEach[it.lowerBound = 0] | ||
76 | mm.references.removeAll(vq.derivedFeatures.values) | ||
77 | mm.attributes.removeAll(vq.derivedFeatures.values) | ||
78 | for(run : 1..scenario.runs) { | ||
79 | runCase(run==1,"noConstraints"+run,scenario,mm,new ViatraQuerySetDescriptor(vq.patterns,emptySet,emptyMap),ps) | ||
80 | } | ||
81 | } else { | ||
82 | |||
83 | } | ||
84 | |||
85 | |||
86 | } | ||
87 | |||
88 | // private def printHeader(Scenario scenario) { | ||
89 | // print("id;Solution type (ms);Transformation time (ms);Solver time (ms);") | ||
90 | // (1..scenario.number).forEach[print("sol"+it+" (nano);")] | ||
91 | // print("TransformationExecutionTime (ms);TypeAnalysisTime (ms);StateCoderTime (ms);SolutionCopyTime (ms);") | ||
92 | // print("SolutionDiversityCheckTime (ms);SolutionDiversitySuccessRate (%);") | ||
93 | // println("save") | ||
94 | // } | ||
95 | |||
96 | private def runCase(boolean first, String id, Scenario scenario, EcoreMetamodelDescriptor mm, ViatraQuerySetDescriptor vq, List<EObject> partialModel) { | ||
97 | // Transform | ||
98 | val metamodelProblem = ecore2Logic.transformMetamodel(mm,new Ecore2LogicConfiguration()) | ||
99 | instanceModel2Logic.transform(metamodelProblem,partialModel) | ||
100 | if(vq!=null) { | ||
101 | viatra2Logic.transformQueries(vq,metamodelProblem,new Viatra2LogicConfiguration) | ||
102 | } | ||
103 | val problem = metamodelProblem.output | ||
104 | |||
105 | var FileSystemWorkspace workspace = new FileSystemWorkspace('''output_«id»/''',"") | ||
106 | workspace.initAndClear | ||
107 | val config = getSolverConfiguration(scenario,vq) | ||
108 | |||
109 | // Execute | ||
110 | val solution = viatraSolver.solve(problem,config,workspace) | ||
111 | printStatistics(solution,scenario,workspace,id,first) | ||
112 | |||
113 | } | ||
114 | |||
115 | private def init() { | ||
116 | LogiclanguagePackage.eINSTANCE.class | ||
117 | LogicproblemPackage.eINSTANCE.class | ||
118 | PartialinterpretationPackage.eINSTANCE.class | ||
119 | Ecore2logicannotationsPackage.eINSTANCE.class | ||
120 | Viatra2LogicAnnotationsPackage.eINSTANCE.class | ||
121 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("ecore",new XMIResourceFactoryImpl) | ||
122 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi",new XMIResourceFactoryImpl) | ||
123 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem",new XMIResourceFactoryImpl) | ||
124 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialinterpretation",new XMIResourceFactoryImpl) | ||
125 | } | ||
126 | |||
127 | private def initLoader(Metamodel metamodel) { | ||
128 | loader = if(metamodel == Metamodel::FAM) { | ||
129 | new FAMLoader(inputs) | ||
130 | } else if(metamodel == Metamodel::Yakindu || metamodel == Metamodel::YakinduWOSynch) { | ||
131 | new YakinduLoader(inputs) | ||
132 | } else throw new IllegalArgumentException('''Unknown domain: «metamodel»''') | ||
133 | } | ||
134 | |||
135 | def private getSolverConfiguration(Scenario scenario, ViatraQuerySetDescriptor vq) { | ||
136 | val viatraConfig = new ViatraReasonerConfiguration => [ | ||
137 | it.runtimeLimit = 300 | ||
138 | it.typeScopes.maxNewElements = scenario.size | ||
139 | it.typeScopes.minNewElements = scenario.size | ||
140 | it.solutionScope.numberOfRequiredSolution = scenario.number | ||
141 | it.existingQueries = vq.patterns.map[it.internalQueryRepresentation] | ||
142 | it.nameNewElements = false | ||
143 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis | ||
144 | it.additionalGlobalConstraints += loader.additionalConstraints | ||
145 | it.stateCoderStrategy = StateCoderStrategy::Neighbourhood | ||
146 | if(scenario.statecoder != StateCoder::ID) { | ||
147 | val range = if(scenario.statecoder != StateCoder::R1) { | ||
148 | 1 | ||
149 | } else if(scenario.statecoder != StateCoder::R2) { | ||
150 | 2 | ||
151 | } else if(scenario.statecoder != StateCoder::R3) { | ||
152 | 3 | ||
153 | } | ||
154 | |||
155 | it.diversityRequirement = new DiversityDescriptor => [ | ||
156 | it.relevantTypes = null | ||
157 | it.relevantRelations = null | ||
158 | it.maxNumber = 1 | ||
159 | it.range = range | ||
160 | it.parallels = 1 | ||
161 | ] | ||
162 | } | ||
163 | ] | ||
164 | return viatraConfig | ||
165 | } | ||
166 | |||
167 | def printStatistics(LogicResult solution, Scenario scenario, FileSystemWorkspace workspace, String id, boolean printHeader) { | ||
168 | if(printHeader) { | ||
169 | print("id;Solution type (ms);Transformation time (ms);Solver time (ms);") | ||
170 | solution.statistics.entries.map[name].forEach[print(it+";")] | ||
171 | println("save") | ||
172 | } | ||
173 | |||
174 | |||
175 | print(id+";") | ||
176 | print(solution.class.simpleName+";"); | ||
177 | print(solution.statistics.transformationTime+";") | ||
178 | print(solution.statistics.solverTime+";") | ||
179 | |||
180 | print((new StatisticSections2Print).transformStatisticDatas2CSV(solution.statistics.entries)) | ||
181 | |||
182 | if(solution instanceof ModelResult) { | ||
183 | val representations = solution.representation | ||
184 | for(representationIndex : 0..<representations.size) { | ||
185 | val representation = representations.get(representationIndex) | ||
186 | val representationNumber = representationIndex + 1 | ||
187 | if(representation instanceof PartialInterpretation) { | ||
188 | workspace.writeModel(representation, '''solution«representationNumber».partialinterpretation''') | ||
189 | } else { | ||
190 | workspace.writeText('''solution«representationNumber».txt''',representation.toString) | ||
191 | } | ||
192 | } | ||
193 | println('''saved''') | ||
194 | } else { | ||
195 | println('''notsaved''') | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | |||
200 | class DiverseMeasurementRunner { | ||
201 | def static void main(String[] args) { | ||
202 | val scenario = new Scenario(50,50,Metamodel::Yakindu,Constraints.None,StateCoder.ID,12) | ||
203 | val scenarioRunner = new ScenarioRunner | ||
204 | scenarioRunner.runScenario(scenario) | ||
205 | } | ||
206 | } \ No newline at end of file | ||
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/RunMeasurements.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/RunMeasurements.xtend index 7ba38ede..b4ae9293 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/RunMeasurements.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/RunMeasurements.xtend | |||
@@ -189,10 +189,10 @@ class RunMeasurements { | |||
189 | static val clean = false | 189 | static val clean = false |
190 | static val domain = Domain::Yakindu | 190 | static val domain = Domain::Yakindu |
191 | static val solver = UseSolver::Viatra | 191 | static val solver = UseSolver::Viatra |
192 | static val diverse = false | 192 | static val diverse = true |
193 | static val wf = true | 193 | static val wf = false |
194 | public static var sizes = #[50] | 194 | public static var sizes = #[50] |
195 | static var int number = 10 | 195 | static var int number = 3 |
196 | 196 | ||
197 | def static void waitForEnter() { | 197 | def static void waitForEnter() { |
198 | if(monitoring) { | 198 | if(monitoring) { |