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