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