diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf')
2 files changed, 24 insertions, 5 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..7ef7073a 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,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner |
2 | 2 | ||
3 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.PartialInterpretationMetric | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException |
@@ -27,12 +28,11 @@ import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | |||
27 | import java.util.List | 28 | import java.util.List |
28 | import java.util.Map | 29 | import java.util.Map |
29 | import org.eclipse.emf.ecore.EObject | 30 | import org.eclipse.emf.ecore.EObject |
31 | import org.eclipse.emf.ecore.util.EcoreUtil | ||
30 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer | 32 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer |
31 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel | 33 | import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel |
32 | import org.eclipse.viatra.dse.solutionstore.SolutionStore | 34 | import org.eclipse.viatra.dse.solutionstore.SolutionStore |
33 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory | 35 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory |
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.SolutionStoreWithDiversityDescriptor | ||
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityGranularity | ||
36 | 36 | ||
37 | class ViatraReasoner extends LogicReasoner{ | 37 | class ViatraReasoner extends LogicReasoner{ |
38 | val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser() | 38 | val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser() |
@@ -61,11 +61,12 @@ class ViatraReasoner extends LogicReasoner{ | |||
61 | 61 | ||
62 | 62 | ||
63 | val emptySolution = initialiser.initialisePartialInterpretation(problem,viatraConfig.typeScopes).output | 63 | val emptySolution = initialiser.initialisePartialInterpretation(problem,viatraConfig.typeScopes).output |
64 | |||
64 | if((viatraConfig.documentationLevel == DocumentationLevel::FULL || viatraConfig.documentationLevel == DocumentationLevel::NORMAL) && workspace !== null) { | 65 | if((viatraConfig.documentationLevel == DocumentationLevel::FULL || viatraConfig.documentationLevel == DocumentationLevel::NORMAL) && workspace !== null) { |
65 | workspace.writeModel(emptySolution,"init.partialmodel") | 66 | workspace.writeModel(emptySolution,"init.partialmodel") |
66 | } | 67 | } |
67 | emptySolution.problemConainer = problem | 68 | emptySolution.problemConainer = problem |
68 | 69 | val emptySolutionCopy = EcoreUtil.copy(emptySolution) | |
69 | val ScopePropagator scopePropagator = new ScopePropagator(emptySolution) | 70 | val ScopePropagator scopePropagator = new ScopePropagator(emptySolution) |
70 | scopePropagator.propagateAllScopeConstraints | 71 | scopePropagator.propagateAllScopeConstraints |
71 | 72 | ||
@@ -129,6 +130,11 @@ class ViatraReasoner extends LogicReasoner{ | |||
129 | val solverTime = System.nanoTime - solverStartTime | 130 | val solverTime = System.nanoTime - solverStartTime |
130 | viatraConfig.progressMonitor.workedSearchFinished | 131 | viatraConfig.progressMonitor.workedSearchFinished |
131 | 132 | ||
133 | //find trajectory to each solution | ||
134 | if(viatraConfig.documentationLevel == DocumentationLevel.METRICS){ | ||
135 | PartialInterpretationMetric.outputTrajectories(emptySolutionCopy, dse.solutions.toList()); | ||
136 | } | ||
137 | |||
132 | //additionalMatches = strategy.solutionStoreWithCopy.additionalMatches | 138 | //additionalMatches = strategy.solutionStoreWithCopy.additionalMatches |
133 | val statistics = createStatistics => [ | 139 | val statistics = createStatistics => [ |
134 | //it.solverTime = viatraConfig.runtimeLimit | 140 | //it.solverTime = viatraConfig.runtimeLimit |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java index 60f46033..21efd7ba 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java | |||
@@ -32,6 +32,7 @@ import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | |||
32 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 32 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; |
33 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | 33 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; |
34 | 34 | ||
35 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.PartialInterpretationMetric; | ||
35 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | 36 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; |
36 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner; | 37 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner; |
37 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | 38 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; |
@@ -190,6 +191,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
190 | List<Object> activationIds = selectActivation(); | 191 | List<Object> activationIds = selectActivation(); |
191 | Iterator<Object> iterator = activationIds.iterator(); | 192 | Iterator<Object> iterator = activationIds.iterator(); |
192 | 193 | ||
194 | |||
193 | while (!isInterrupted && !configuration.progressMonitor.isCancelled() && iterator.hasNext()) { | 195 | while (!isInterrupted && !configuration.progressMonitor.isCancelled() && iterator.hasNext()) { |
194 | final Object nextActivation = iterator.next(); | 196 | final Object nextActivation = iterator.next(); |
195 | // if (!iterator.hasNext()) { | 197 | // if (!iterator.hasNext()) { |
@@ -198,7 +200,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
198 | // } | 200 | // } |
199 | logger.debug("Executing new activation: " + nextActivation); | 201 | logger.debug("Executing new activation: " + nextActivation); |
200 | context.executeAcitvationId(nextActivation); | 202 | context.executeAcitvationId(nextActivation); |
201 | 203 | ||
202 | visualiseCurrentState(); | 204 | visualiseCurrentState(); |
203 | // for(ViatraQueryMatcher<? extends IPatternMatch> matcher : matchers) { | 205 | // for(ViatraQueryMatcher<? extends IPatternMatch> matcher : matchers) { |
204 | // System.out.println(matcher.getPatternName()); | 206 | // System.out.println(matcher.getPatternName()); |
@@ -209,6 +211,9 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
209 | // System.out.println("---------"); | 211 | // System.out.println("---------"); |
210 | // } | 212 | // } |
211 | 213 | ||
214 | //calculate the metrics for each state | ||
215 | logCurrentStateMetric(); | ||
216 | |||
212 | boolean consistencyCheckResult = checkConsistency(currentTrajectoryWithFittness); | 217 | boolean consistencyCheckResult = checkConsistency(currentTrajectoryWithFittness); |
213 | if(consistencyCheckResult == true) { continue mainLoop; } | 218 | if(consistencyCheckResult == true) { continue mainLoop; } |
214 | 219 | ||
@@ -248,7 +253,6 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
248 | } | 253 | } |
249 | } | 254 | } |
250 | } | 255 | } |
251 | |||
252 | logger.debug("State is fully traversed."); | 256 | logger.debug("State is fully traversed."); |
253 | trajectoiresToExplore.remove(currentTrajectoryWithFittness); | 257 | trajectoiresToExplore.remove(currentTrajectoryWithFittness); |
254 | currentTrajectoryWithFittness = null; | 258 | currentTrajectoryWithFittness = null; |
@@ -309,6 +313,15 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
309 | return trajectoiresToExplore.element(); | 313 | return trajectoiresToExplore.element(); |
310 | } | 314 | } |
311 | } | 315 | } |
316 | |||
317 | private void logCurrentStateMetric() { | ||
318 | if(this.configuration.documentationLevel != DocumentationLevel.METRICS || workspace == null) { | ||
319 | return; | ||
320 | } | ||
321 | |||
322 | PartialInterpretation interpretation = (PartialInterpretation)context.getModel(); //pattern.get("interpretation"); | ||
323 | PartialInterpretationMetric.calculateMetric(interpretation, "debug/metric/" + context.getModel().hashCode(), context.getCurrentStateId().toString()); | ||
324 | } | ||
312 | 325 | ||
313 | public void visualiseCurrentState() { | 326 | public void visualiseCurrentState() { |
314 | PartialInterpretationVisualiser partialInterpretatioVisualiser = configuration.debugCongiguration.partialInterpretatioVisualiser; | 327 | PartialInterpretationVisualiser partialInterpretatioVisualiser = configuration.debugCongiguration.partialInterpretatioVisualiser; |