diff options
Diffstat (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend')
-rw-r--r-- | Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend index d9536989..20683fff 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend | |||
@@ -30,6 +30,9 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | |||
30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | 30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml |
31 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolverConfiguration | 31 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolverConfiguration |
32 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolver | 32 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolver |
33 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | ||
34 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | ||
35 | import java.util.LinkedList | ||
33 | 36 | ||
34 | class SimpleRun { | 37 | class SimpleRun { |
35 | 38 | ||
@@ -47,6 +50,7 @@ class SimpleRun { | |||
47 | println("DSL loaded") | 50 | println("DSL loaded") |
48 | 51 | ||
49 | val Ecore2Logic ecore2Logic = new Ecore2Logic | 52 | val Ecore2Logic ecore2Logic = new Ecore2Logic |
53 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | ||
50 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | 54 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) |
51 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | 55 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic |
52 | 56 | ||
@@ -58,9 +62,9 @@ class SimpleRun { | |||
58 | 62 | ||
59 | println("Problem created") | 63 | println("Problem created") |
60 | var LogicResult solution | 64 | var LogicResult solution |
61 | 65 | var LogicReasoner reasoner | |
62 | //* | 66 | /* |
63 | val ViatraReasoner viatraSolver = new ViatraReasoner | 67 | reasoner = new ViatraReasoner |
64 | val viatraConfig = new ViatraReasonerConfiguration => [ | 68 | val viatraConfig = new ViatraReasonerConfiguration => [ |
65 | it.typeScopes.maxNewElements = 10 | 69 | it.typeScopes.maxNewElements = 10 |
66 | it.typeScopes.minNewElements = 10 | 70 | it.typeScopes.minNewElements = 10 |
@@ -70,9 +74,9 @@ class SimpleRun { | |||
70 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis | 74 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis |
71 | it.stateCoderStrategy = StateCoderStrategy::Neighbourhood | 75 | it.stateCoderStrategy = StateCoderStrategy::Neighbourhood |
72 | ] | 76 | ] |
73 | solution = viatraSolver.solve(logicProblem,viatraConfig,workspace) | 77 | solution = reasoner.solve(logicProblem,viatraConfig,workspace) |
74 | /*/ | 78 | /*/ |
75 | val AlloySolver alloyReasoner = new AlloySolver | 79 | reasoner = new AlloySolver |
76 | val alloyConfig = new AlloySolverConfiguration => [ | 80 | val alloyConfig = new AlloySolverConfiguration => [ |
77 | it.typeScopes.maxNewElements = 5 | 81 | it.typeScopes.maxNewElements = 5 |
78 | it.typeScopes.minNewElements = 5 | 82 | it.typeScopes.minNewElements = 5 |
@@ -80,12 +84,19 @@ class SimpleRun { | |||
80 | it.typeScopes.maxIntScope = 0 | 84 | it.typeScopes.maxIntScope = 0 |
81 | it.writeToFile = true | 85 | it.writeToFile = true |
82 | ] | 86 | ] |
83 | solution = alloyReasoner.solve(logicProblem,alloyConfig,workspace) | 87 | solution = reasoner.solve(logicProblem,alloyConfig,workspace) |
84 | //*/ | 88 | //*/ |
85 | 89 | ||
86 | println("Problem solved") | 90 | println("Problem solved") |
87 | 91 | ||
88 | solution.writeSolution(workspace) | 92 | val interpretations = reasoner.getInterpretations(solution as ModelResult) |
93 | val models = new LinkedList | ||
94 | for(interpretation : interpretations) { | ||
95 | val instanceModel = logic2Ecore.transformInterpretation(interpretation,modelGenerationProblem.trace) | ||
96 | models+=instanceModel | ||
97 | } | ||
98 | |||
99 | solution.writeSolution(workspace, #[]) | ||
89 | } | 100 | } |
90 | 101 | ||
91 | def private static loadMetamodel() { | 102 | def private static loadMetamodel() { |
@@ -118,7 +129,7 @@ class SimpleRun { | |||
118 | inputs.readModel(EObject,"FAM.xmi").eResource.allContents.toList | 129 | inputs.readModel(EObject,"FAM.xmi").eResource.allContents.toList |
119 | } | 130 | } |
120 | 131 | ||
121 | def static writeSolution(LogicResult solution, ReasonerWorkspace workspace) { | 132 | def static writeSolution(LogicResult solution, ReasonerWorkspace workspace, List<EObject> models) { |
122 | if(solution instanceof ModelResult) { | 133 | if(solution instanceof ModelResult) { |
123 | val representations = solution.representation | 134 | val representations = solution.representation |
124 | for(representationIndex : 0..<representations.size) { | 135 | for(representationIndex : 0..<representations.size) { |
@@ -135,6 +146,9 @@ class SimpleRun { | |||
135 | workspace.writeText('''solutionĀ«representationNumberĀ».txt''',representation.toString) | 146 | workspace.writeText('''solutionĀ«representationNumberĀ».txt''',representation.toString) |
136 | } | 147 | } |
137 | } | 148 | } |
149 | for(model : models) { | ||
150 | workspace.writeModel(model,"model.xmi") | ||
151 | } | ||
138 | println("Solution saved and visualised") | 152 | println("Solution saved and visualised") |
139 | } | 153 | } |
140 | } | 154 | } |