diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend | 227 |
1 files changed, 139 insertions, 88 deletions
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 6639e5f3..edcca676 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 | |||
@@ -1,5 +1,7 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.Lists | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException | 7 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException |
@@ -17,12 +19,17 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par | |||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.IdentifierBasedStateCoderFactory | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.IdentifierBasedStateCoderFactory |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedStateCoderFactory | 20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedStateCoderFactory |
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BestFirstStrategyForModelGeneration | 21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BestFirstStrategyForModelGeneration |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityChecker | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.LoggerSolutionFoundHandler | ||
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ModelGenerationCompositeObjective | 24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ModelGenerationCompositeObjective |
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ScopeObjective | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ScopeObjective |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.SurelyViolatedObjectiveGlobalConstraint | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.UnfinishedMultiplicityObjective | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.UnfinishedMultiplicityObjective |
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.UnfinishedWFObjective | 29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ViatraReasonerSolutionSaver |
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.WF2ObjectiveConverter | 30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.WF2ObjectiveConverter |
31 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ThreeValuedCostElement | ||
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ThreeValuedCostObjective | ||
26 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | 33 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace |
27 | import java.util.List | 34 | import java.util.List |
28 | import java.util.Map | 35 | import java.util.Map |
@@ -31,44 +38,41 @@ import org.eclipse.viatra.dse.api.DesignSpaceExplorer | |||
31 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel | 38 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel |
32 | import org.eclipse.viatra.dse.solutionstore.SolutionStore | 39 | import org.eclipse.viatra.dse.solutionstore.SolutionStore |
33 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory | 40 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory |
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.SolutionStoreWithDiversityDescriptor | ||
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityGranularity | ||
36 | 41 | ||
37 | class ViatraReasoner extends LogicReasoner{ | 42 | class ViatraReasoner extends LogicReasoner { |
38 | val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser() | 43 | val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser() |
39 | val ModelGenerationMethodProvider modelGenerationMethodProvider = new ModelGenerationMethodProvider | 44 | val ModelGenerationMethodProvider modelGenerationMethodProvider = new ModelGenerationMethodProvider |
40 | val extension LogicresultFactory factory = LogicresultFactory.eINSTANCE | 45 | val extension LogicresultFactory factory = LogicresultFactory.eINSTANCE |
41 | val WF2ObjectiveConverter wf2ObjectiveConverter = new WF2ObjectiveConverter | 46 | val WF2ObjectiveConverter wf2ObjectiveConverter = new WF2ObjectiveConverter |
42 | 47 | ||
43 | 48 | override solve(LogicProblem problem, LogicSolverConfiguration configuration, | |
44 | override solve(LogicProblem problem, LogicSolverConfiguration configuration, ReasonerWorkspace workspace) throws LogicReasonerException { | 49 | ReasonerWorkspace workspace) throws LogicReasonerException { |
45 | val viatraConfig = configuration.asConfig | 50 | val viatraConfig = configuration.asConfig |
46 | 51 | ||
47 | if(viatraConfig.debugCongiguration.logging) { | 52 | if (viatraConfig.debugConfiguration.logging) { |
48 | DesignSpaceExplorer.turnOnLogging(DseLoggingLevel.VERBOSE_FULL) | 53 | DesignSpaceExplorer.turnOnLogging(DseLoggingLevel.VERBOSE_FULL) |
49 | } else { | 54 | } else { |
50 | DesignSpaceExplorer.turnOnLogging(DseLoggingLevel.WARN) | 55 | DesignSpaceExplorer.turnOnLogging(DseLoggingLevel.WARN) |
51 | } | 56 | } |
52 | 57 | ||
53 | val DesignSpaceExplorer dse = new DesignSpaceExplorer(); | 58 | val DesignSpaceExplorer dse = new DesignSpaceExplorer(); |
54 | 59 | ||
55 | dse.addMetaModelPackage(LogiclanguagePackage.eINSTANCE) | 60 | dse.addMetaModelPackage(LogiclanguagePackage.eINSTANCE) |
56 | dse.addMetaModelPackage(LogicproblemPackage.eINSTANCE) | 61 | dse.addMetaModelPackage(LogicproblemPackage.eINSTANCE) |
57 | dse.addMetaModelPackage(PartialinterpretationPackage.eINSTANCE) | 62 | dse.addMetaModelPackage(PartialinterpretationPackage.eINSTANCE) |
58 | 63 | ||
59 | val transformationStartTime = System.nanoTime | 64 | val transformationStartTime = System.nanoTime |
60 | 65 | ||
61 | 66 | val emptySolution = initialiser.initialisePartialInterpretation(problem, viatraConfig.typeScopes).output | |
62 | 67 | if ((viatraConfig.documentationLevel == DocumentationLevel::FULL || | |
63 | val emptySolution = initialiser.initialisePartialInterpretation(problem,viatraConfig.typeScopes).output | 68 | viatraConfig.documentationLevel == DocumentationLevel::NORMAL) && workspace !== null) { |
64 | if((viatraConfig.documentationLevel == DocumentationLevel::FULL || viatraConfig.documentationLevel == DocumentationLevel::NORMAL) && workspace !== null) { | 69 | workspace.writeModel(emptySolution, "init.partialmodel") |
65 | workspace.writeModel(emptySolution,"init.partialmodel") | 70 | } |
66 | } | ||
67 | emptySolution.problemConainer = problem | 71 | emptySolution.problemConainer = problem |
68 | 72 | ||
69 | val ScopePropagator scopePropagator = new ScopePropagator(emptySolution) | 73 | val ScopePropagator scopePropagator = new ScopePropagator(emptySolution) |
70 | scopePropagator.propagateAllScopeConstraints | 74 | scopePropagator.propagateAllScopeConstraints |
71 | 75 | ||
72 | val method = modelGenerationMethodProvider.createModelGenerationMethod( | 76 | val method = modelGenerationMethodProvider.createModelGenerationMethod( |
73 | problem, | 77 | problem, |
74 | emptySolution, | 78 | emptySolution, |
@@ -78,138 +82,185 @@ class ViatraReasoner extends LogicReasoner{ | |||
78 | scopePropagator, | 82 | scopePropagator, |
79 | viatraConfig.documentationLevel | 83 | viatraConfig.documentationLevel |
80 | ) | 84 | ) |
81 | 85 | ||
82 | dse.addObjective(new ModelGenerationCompositeObjective( | 86 | dse.addObjective(new ModelGenerationCompositeObjective( |
83 | new ScopeObjective, | 87 | new ScopeObjective, |
84 | method.unfinishedMultiplicities.map[new UnfinishedMultiplicityObjective(it)], | 88 | method.unfinishedMultiplicities.map[new UnfinishedMultiplicityObjective(it)], |
85 | new UnfinishedWFObjective(method.unfinishedWF) | 89 | wf2ObjectiveConverter.createCompletenessObjective(method.unfinishedWF) |
86 | )) | 90 | )) |
87 | 91 | ||
88 | dse.addGlobalConstraint(wf2ObjectiveConverter.createInvalidationObjective(method.invalidWF)) | 92 | val extremalObjectives = Lists.newArrayListWithExpectedSize(viatraConfig.costObjectives.size) |
89 | for(additionalConstraint : viatraConfig.searchSpaceConstraints.additionalGlobalConstraints) { | 93 | for (entry : viatraConfig.costObjectives.indexed) { |
90 | dse.addGlobalConstraint(additionalConstraint.apply(method)) | 94 | val objectiveName = '''costObjective«entry.key»''' |
95 | val objectiveConfig = entry.value | ||
96 | val elementsBuilder = ImmutableList.builder | ||
97 | for (elementConfig : objectiveConfig.elements) { | ||
98 | val relationName = elementConfig.patternQualifiedName | ||
99 | val modalQueries = method.modalRelationQueries.get(relationName) | ||
100 | if (modalQueries === null) { | ||
101 | throw new IllegalArgumentException("Unknown relation: " + relationName) | ||
102 | } | ||
103 | elementsBuilder.add(new ThreeValuedCostElement( | ||
104 | modalQueries.currentQuery, | ||
105 | modalQueries.mayQuery, | ||
106 | modalQueries.mustQuery, | ||
107 | elementConfig.weight | ||
108 | )) | ||
109 | } | ||
110 | val costElements = elementsBuilder.build | ||
111 | val costObjective = new ThreeValuedCostObjective(objectiveName, costElements, objectiveConfig.kind, | ||
112 | objectiveConfig.threshold, 3) | ||
113 | dse.addObjective(costObjective) | ||
114 | if (objectiveConfig.findExtremum) { | ||
115 | extremalObjectives += costObjective | ||
116 | } | ||
91 | } | 117 | } |
92 | 118 | ||
93 | dse.setInitialModel(emptySolution,false) | 119 | val numberOfRequiredSolutions = configuration.solutionScope.numberOfRequiredSolutions |
94 | 120 | val solutionStore = if (extremalObjectives.empty) { | |
95 | val IStateCoderFactory statecoder = if(viatraConfig.stateCoderStrategy == StateCoderStrategy.Neighbourhood) { | 121 | new SolutionStore(numberOfRequiredSolutions) |
96 | new NeighbourhoodBasedStateCoderFactory | 122 | } else { |
97 | } else { | 123 | new SolutionStore() |
98 | new IdentifierBasedStateCoderFactory | 124 | } |
125 | solutionStore.registerSolutionFoundHandler(new LoggerSolutionFoundHandler(viatraConfig)) | ||
126 | val diversityChecker = DiversityChecker.of(viatraConfig.diversityRequirement) | ||
127 | val solutionSaver = new ViatraReasonerSolutionSaver(newArrayList(extremalObjectives), numberOfRequiredSolutions, | ||
128 | diversityChecker) | ||
129 | val solutionCopier = solutionSaver.solutionCopier | ||
130 | solutionStore.withSolutionSaver(solutionSaver) | ||
131 | dse.solutionStore = solutionStore | ||
132 | |||
133 | dse.addGlobalConstraint(wf2ObjectiveConverter.createInvalidationGlobalConstraint(method.invalidWF)) | ||
134 | dse.addGlobalConstraint(new SurelyViolatedObjectiveGlobalConstraint(solutionSaver)) | ||
135 | for (additionalConstraint : viatraConfig.searchSpaceConstraints.additionalGlobalConstraints) { | ||
136 | dse.addGlobalConstraint(additionalConstraint.apply(method)) | ||
99 | } | 137 | } |
138 | |||
139 | dse.setInitialModel(emptySolution, false) | ||
140 | |||
141 | val IStateCoderFactory statecoder = if (viatraConfig.stateCoderStrategy == StateCoderStrategy.Neighbourhood) { | ||
142 | new NeighbourhoodBasedStateCoderFactory | ||
143 | } else { | ||
144 | new IdentifierBasedStateCoderFactory | ||
145 | } | ||
100 | dse.stateCoderFactory = statecoder | 146 | dse.stateCoderFactory = statecoder |
101 | 147 | ||
102 | dse.maxNumberOfThreads = 1 | 148 | dse.maxNumberOfThreads = 1 |
103 | 149 | ||
104 | val solutionStore = new SolutionStore(configuration.solutionScope.numberOfRequiredSolution) | 150 | for (rule : method.relationRefinementRules) { |
105 | dse.solutionStore = solutionStore | ||
106 | |||
107 | for(rule : method.relationRefinementRules) { | ||
108 | dse.addTransformationRule(rule) | 151 | dse.addTransformationRule(rule) |
109 | } | 152 | } |
110 | for(rule : method.objectRefinementRules) { | 153 | for (rule : method.objectRefinementRules) { |
111 | dse.addTransformationRule(rule) | 154 | dse.addTransformationRule(rule) |
112 | } | 155 | } |
113 | 156 | ||
114 | val strategy = new BestFirstStrategyForModelGeneration(workspace,viatraConfig,method) | 157 | val strategy = new BestFirstStrategyForModelGeneration(workspace, viatraConfig, method) |
115 | viatraConfig.progressMonitor.workedForwardTransformation | 158 | viatraConfig.progressMonitor.workedForwardTransformation |
116 | 159 | ||
117 | val transformationTime = System.nanoTime - transformationStartTime | 160 | val transformationTime = System.nanoTime - transformationStartTime |
118 | val solverStartTime = System.nanoTime | 161 | val solverStartTime = System.nanoTime |
119 | 162 | ||
120 | var boolean stoppedByTimeout | 163 | var boolean stoppedByTimeout |
121 | var boolean stoppedByException | 164 | try { |
122 | try{ | 165 | stoppedByTimeout = dse.startExplorationWithTimeout(strategy, configuration.runtimeLimit * 1000); |
123 | stoppedByTimeout = dse.startExplorationWithTimeout(strategy,configuration.runtimeLimit*1000); | ||
124 | stoppedByException = false | ||
125 | } catch (NullPointerException npe) { | 166 | } catch (NullPointerException npe) { |
126 | stoppedByTimeout = false | 167 | stoppedByTimeout = false |
127 | stoppedByException = true | ||
128 | } | 168 | } |
129 | val solverTime = System.nanoTime - solverStartTime | 169 | val solverTime = System.nanoTime - solverStartTime |
130 | viatraConfig.progressMonitor.workedSearchFinished | 170 | viatraConfig.progressMonitor.workedSearchFinished |
131 | 171 | ||
132 | //additionalMatches = strategy.solutionStoreWithCopy.additionalMatches | 172 | // additionalMatches = strategy.solutionStoreWithCopy.additionalMatches |
133 | val statistics = createStatistics => [ | 173 | val statistics = createStatistics => [ |
134 | //it.solverTime = viatraConfig.runtimeLimit | 174 | // it.solverTime = viatraConfig.runtimeLimit |
135 | it.solverTime = (solverTime/1000000) as int | 175 | it.solverTime = (solverTime / 1000000) as int |
136 | it.transformationTime = (transformationTime/1000000) as int | 176 | it.transformationTime = (transformationTime / 1000000) as int |
137 | for(x : 0..<strategy.solutionStoreWithCopy.allRuntimes.size) { | 177 | for (pair : solutionCopier.getAllCopierRuntimes(true).indexed) { |
138 | it.entries += createIntStatisticEntry => [ | 178 | it.entries += createIntStatisticEntry => [ |
139 | it.name = '''_Solution«x»FoundAt''' | 179 | it.name = '''_Solution«pair.key»FoundAt''' |
140 | it.value = (strategy.solutionStoreWithCopy.allRuntimes.get(x)/1000000) as int | 180 | it.value = (pair.value / 1000000) as int |
141 | ] | 181 | ] |
142 | } | 182 | } |
143 | it.entries += createIntStatisticEntry => [ | 183 | it.entries += createIntStatisticEntry => [ |
144 | it.name = "TransformationExecutionTime" it.value = (method.statistics.transformationExecutionTime/1000000) as int | 184 | it.name = "TransformationExecutionTime" |
185 | it.value = (method.statistics.transformationExecutionTime / 1000000) as int | ||
145 | ] | 186 | ] |
146 | it.entries += createIntStatisticEntry => [ | 187 | it.entries += createIntStatisticEntry => [ |
147 | it.name = "TypeAnalysisTime" it.value = (method.statistics.PreliminaryTypeAnalisisTime/1000000) as int | 188 | it.name = "TypeAnalysisTime" |
189 | it.value = (method.statistics.PreliminaryTypeAnalisisTime / 1000000) as int | ||
148 | ] | 190 | ] |
149 | it.entries += createIntStatisticEntry => [ | 191 | it.entries += createIntStatisticEntry => [ |
150 | it.name = "StateCoderTime" it.value = (statecoder.runtime/1000000) as int | 192 | it.name = "StateCoderTime" |
193 | it.value = (statecoder.runtime / 1000000) as int | ||
151 | ] | 194 | ] |
152 | it.entries += createIntStatisticEntry => [ | 195 | it.entries += createIntStatisticEntry => [ |
153 | it.name = "StateCoderFailCount" it.value = strategy.numberOfStatecoderFail | 196 | it.name = "StateCoderFailCount" |
197 | it.value = strategy.numberOfStatecoderFail | ||
154 | ] | 198 | ] |
155 | it.entries += createIntStatisticEntry => [ | 199 | it.entries += createIntStatisticEntry => [ |
156 | it.name = "SolutionCopyTime" it.value = (strategy.solutionStoreWithCopy.sumRuntime/1000000) as int | 200 | it.name = "SolutionCopyTime" |
201 | it.value = (solutionCopier.getTotalCopierRuntime / 1000000) as int | ||
157 | ] | 202 | ] |
158 | if(strategy.solutionStoreWithDiversityDescriptor.isActive) { | 203 | if (diversityChecker.isActive) { |
159 | it.entries += createIntStatisticEntry => [ | 204 | it.entries += createIntStatisticEntry => [ |
160 | it.name = "SolutionDiversityCheckTime" it.value = (strategy.solutionStoreWithDiversityDescriptor.sumRuntime/1000000) as int | 205 | it.name = "SolutionDiversityCheckTime" |
206 | it.value = (diversityChecker.totalRuntime / 1000000) as int | ||
161 | ] | 207 | ] |
162 | it.entries += createRealStatisticEntry => [ | 208 | it.entries += createRealStatisticEntry => [ |
163 | it.name = "SolutionDiversitySuccessRate" it.value = strategy.solutionStoreWithDiversityDescriptor.successRate | 209 | it.name = "SolutionDiversitySuccessRate" |
210 | it.value = diversityChecker.successRate | ||
164 | ] | 211 | ] |
165 | } | 212 | } |
166 | ] | 213 | ] |
167 | 214 | ||
168 | viatraConfig.progressMonitor.workedBackwardTransformationFinished | 215 | viatraConfig.progressMonitor.workedBackwardTransformationFinished |
169 | 216 | ||
170 | if(stoppedByTimeout) { | 217 | if (stoppedByTimeout) { |
171 | return createInsuficientResourcesResult=>[ | 218 | return createInsuficientResourcesResult => [ |
172 | it.problem = problem | 219 | it.problem = problem |
173 | it.resourceName="time" | 220 | it.resourceName = "time" |
174 | it.representation += strategy.solutionStoreWithCopy.solutions | 221 | it.representation += solutionCopier.getPartialInterpretations(true) |
175 | it.statistics = statistics | 222 | it.statistics = statistics |
176 | ] | 223 | ] |
177 | } else { | 224 | } else { |
178 | if(solutionStore.solutions.empty) { | 225 | if (solutionStore.solutions.empty) { |
179 | return createInconsistencyResult => [ | 226 | return createInconsistencyResult => [ |
180 | it.problem = problem | 227 | it.problem = problem |
181 | it.representation += strategy.solutionStoreWithCopy.solutions | 228 | it.representation += solutionCopier.getPartialInterpretations(true) |
182 | it.statistics = statistics | 229 | it.statistics = statistics |
183 | ] | 230 | ] |
184 | } else { | 231 | } else { |
185 | return createModelResult => [ | 232 | return createModelResult => [ |
186 | it.problem = problem | 233 | it.problem = problem |
187 | it.trace = strategy.solutionStoreWithCopy.copyTraces | 234 | it.trace = solutionCopier.getTraces(true) |
188 | it.representation += strategy.solutionStoreWithCopy.solutions | 235 | it.representation += solutionCopier.getPartialInterpretations(true) |
189 | it.statistics = statistics | 236 | it.statistics = statistics |
190 | ] | 237 | ] |
191 | } | 238 | } |
192 | } | 239 | } |
193 | } | 240 | } |
194 | 241 | ||
195 | private def dispatch long runtime(NeighbourhoodBasedStateCoderFactory sc) { | 242 | private def dispatch long runtime(NeighbourhoodBasedStateCoderFactory sc) { |
196 | sc.sumStatecoderRuntime | 243 | sc.sumStatecoderRuntime |
197 | } | 244 | } |
198 | 245 | ||
199 | private def dispatch long runtime(IdentifierBasedStateCoderFactory sc) { | 246 | private def dispatch long runtime(IdentifierBasedStateCoderFactory sc) { |
200 | sc.sumStatecoderRuntime | 247 | sc.sumStatecoderRuntime |
201 | } | 248 | } |
202 | 249 | ||
203 | override getInterpretations(ModelResult modelResult) { | 250 | override getInterpretations(ModelResult modelResult) { |
204 | val indexes = 0..<modelResult.representation.size | 251 | val indexes = 0 ..< modelResult.representation.size |
205 | val traces = modelResult.trace as List<Map<EObject, EObject>>; | 252 | val traces = modelResult.trace as List<Map<EObject, EObject>>; |
206 | val res = indexes.map[i | new PartialModelAsLogicInterpretation(modelResult.representation.get(i) as PartialInterpretation,traces.get(i))].toList | 253 | val res = indexes.map [ i | |
254 | new PartialModelAsLogicInterpretation(modelResult.representation.get(i) as PartialInterpretation, | ||
255 | traces.get(i)) | ||
256 | ].toList | ||
207 | return res | 257 | return res |
208 | } | 258 | } |
209 | 259 | ||
210 | private def ViatraReasonerConfiguration asConfig(LogicSolverConfiguration configuration) { | 260 | private def ViatraReasonerConfiguration asConfig(LogicSolverConfiguration configuration) { |
211 | if(configuration instanceof ViatraReasonerConfiguration) { | 261 | if (configuration instanceof ViatraReasonerConfiguration) { |
212 | return configuration | 262 | return configuration |
213 | } else throw new IllegalArgumentException('''Wrong configuration. Expected: «ViatraReasonerConfiguration.name», but got: «configuration.class.name»"''') | 263 | } else |
264 | throw new IllegalArgumentException('''Wrong configuration. Expected: «ViatraReasonerConfiguration.name», but got: «configuration.class.name»"''') | ||
214 | } | 265 | } |
215 | } | 266 | } |