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