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