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