diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner')
3 files changed, 45 insertions, 13 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 1fe65afe..5df28edd 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 | |||
@@ -137,10 +137,16 @@ class ViatraReasoner extends LogicReasoner{ | |||
137 | it.transformationTime = (transformationTime/1000000) as int | 137 | it.transformationTime = (transformationTime/1000000) as int |
138 | for(x : 0..<strategy.solutionStoreWithCopy.allRuntimes.size) { | 138 | for(x : 0..<strategy.solutionStoreWithCopy.allRuntimes.size) { |
139 | it.entries += createIntStatisticEntry => [ | 139 | it.entries += createIntStatisticEntry => [ |
140 | it.name = '''_Solution«x»FoundAt''' | 140 | it.name = '''Solution«x+1»FoundAt''' |
141 | it.value = (strategy.solutionStoreWithCopy.allRuntimes.get(x)/1000000) as int | 141 | it.value = (strategy.solutionStoreWithCopy.allRuntimes.get(x)/1000000) as int |
142 | ] | 142 | ] |
143 | } | 143 | } |
144 | for(x: 0..<strategy.times.size) { | ||
145 | it.entries += createStringStatisticEntry => [ | ||
146 | it.name = '''Solution«x+1»DetailedStatistics''' | ||
147 | it.value = strategy.times.get(x) | ||
148 | ] | ||
149 | } | ||
144 | it.entries += createIntStatisticEntry => [ | 150 | it.entries += createIntStatisticEntry => [ |
145 | it.name = "ExplorationInitializationTime" it.value = ((strategy.explorationStarted-transformationFinished)/1000000) as int | 151 | it.name = "ExplorationInitializationTime" it.value = ((strategy.explorationStarted-transformationFinished)/1000000) as int |
146 | ] | 152 | ] |
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 75ce7f10..710996a9 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 | |||
@@ -44,6 +44,7 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.NumericProblemSolver; | |||
44 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod; | 44 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod; |
45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.PartialInterpretation2Logic; | 45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.PartialInterpretation2Logic; |
46 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 46 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
47 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedPartialInterpretationStateCoder; | ||
47 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 48 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
48 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser; | 49 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser; |
49 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 50 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
@@ -112,7 +113,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
112 | public int getNumberOfStatecoderFail() { | 113 | public int getNumberOfStatecoderFail() { |
113 | return numberOfStatecoderFail; | 114 | return numberOfStatecoderFail; |
114 | } | 115 | } |
115 | 116 | //LinkedList<ViatraQueryMatcher<? extends IPatternMatch>> matchers; | |
116 | @Override | 117 | @Override |
117 | public void initStrategy(ThreadContext context) { | 118 | public void initStrategy(ThreadContext context) { |
118 | this.context = context; | 119 | this.context = context; |
@@ -120,7 +121,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
120 | 121 | ||
121 | // ViatraQueryEngine engine = context.getQueryEngine(); | 122 | // ViatraQueryEngine engine = context.getQueryEngine(); |
122 | // // TODO: visualisation | 123 | // // TODO: visualisation |
123 | // LinkedList<ViatraQueryMatcher<? extends IPatternMatch>> matchers = new LinkedList<ViatraQueryMatcher<? extends IPatternMatch>>(); | 124 | // matchers = new LinkedList<ViatraQueryMatcher<? extends IPatternMatch>>(); |
124 | // for(IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> p : this.method.getAllPatterns()) { | 125 | // for(IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> p : this.method.getAllPatterns()) { |
125 | // //System.out.println(p.getSimpleName()); | 126 | // //System.out.println(p.getSimpleName()); |
126 | // ViatraQueryMatcher<? extends IPatternMatch> matcher = p.getMatcher(engine); | 127 | // ViatraQueryMatcher<? extends IPatternMatch> matcher = p.getMatcher(engine); |
@@ -213,12 +214,11 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
213 | 214 | ||
214 | visualiseCurrentState(); | 215 | visualiseCurrentState(); |
215 | // for(ViatraQueryMatcher<? extends IPatternMatch> matcher : matchers) { | 216 | // for(ViatraQueryMatcher<? extends IPatternMatch> matcher : matchers) { |
216 | // System.out.println(matcher.getPatternName()); | 217 | // int c = matcher.countMatches(); |
217 | // System.out.println("---------"); | 218 | // if(c>=100) { |
218 | // for(IPatternMatch m : matcher.getAllMatches()) { | 219 | // System.out.println(c+ " " +matcher.getPatternName()); |
219 | // System.out.println(m); | ||
220 | // } | 220 | // } |
221 | // System.out.println("---------"); | 221 | // |
222 | // } | 222 | // } |
223 | 223 | ||
224 | boolean consistencyCheckResult = checkConsistency(currentTrajectoryWithFittness); | 224 | boolean consistencyCheckResult = checkConsistency(currentTrajectoryWithFittness); |
@@ -292,12 +292,31 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
292 | solutionStoreWithDiversityDescriptor.newSolution(context); | 292 | solutionStoreWithDiversityDescriptor.newSolution(context); |
293 | solutionStore.newSolution(context); | 293 | solutionStore.newSolution(context); |
294 | configuration.progressMonitor.workedModelFound(configuration.solutionScope.numberOfRequiredSolution); | 294 | configuration.progressMonitor.workedModelFound(configuration.solutionScope.numberOfRequiredSolution); |
295 | 295 | saveTimes(); | |
296 | logger.debug("Found a solution."); | 296 | logger.debug("Found a solution."); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | public List<String> times = new LinkedList<String>(); | ||
302 | private void saveTimes() { | ||
303 | long statecoderTime = ((NeighbourhoodBasedPartialInterpretationStateCoder)this.context.getStateCoder()).getStatecoderRuntime()/1000000; | ||
304 | long solutionCopy = solutionStoreWithCopy.getSumRuntime()/1000000; | ||
305 | long activationSelection = this.activationSelector.getRuntime()/1000000; | ||
306 | long numericalSolverSumTime = this.numericSolver.getRuntime()/1000000; | ||
307 | long numericalSolverProblemForming = this.numericSolver.getSolverSolvingProblem()/1000000; | ||
308 | long numericalSolverSolving = this.numericSolver.getSolverSolvingProblem()/1000000; | ||
309 | long numericalSolverInterpreting = this.numericSolver.getSolverSolution()/1000000; | ||
310 | this.times.add( | ||
311 | "(StateCoderTime:"+statecoderTime+ | ||
312 | "|SolutionCopyTime:"+solutionCopy+ | ||
313 | "|ActivationSelectionTime:"+activationSelection+ | ||
314 | "|NumericalSolverSumTime:"+numericalSolverSumTime+ | ||
315 | "|NumericalSolverProblemFormingTime:"+numericalSolverProblemForming+ | ||
316 | "|NumericalSolverSolvingTime:"+numericalSolverSolving+ | ||
317 | "|NumericalSolverInterpretingSolution:"+numericalSolverInterpreting+")"); | ||
318 | |||
319 | } | ||
301 | 320 | ||
302 | @Override | 321 | @Override |
303 | public void interruptStrategy() { | 322 | public void interruptStrategy() { |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend index e75cae41..2a4294ad 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend | |||
@@ -6,6 +6,7 @@ import org.eclipse.viatra.dse.base.ThreadContext | |||
6 | import org.eclipse.viatra.dse.objectives.Comparators | 6 | import org.eclipse.viatra.dse.objectives.Comparators |
7 | import org.eclipse.viatra.dse.objectives.IObjective | 7 | import org.eclipse.viatra.dse.objectives.IObjective |
8 | import org.eclipse.viatra.dse.objectives.impl.BaseObjective | 8 | import org.eclipse.viatra.dse.objectives.impl.BaseObjective |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
9 | 10 | ||
10 | //class ViatraReasonerNumbers { | 11 | //class ViatraReasonerNumbers { |
11 | // public static val scopePriority = 2 | 12 | // public static val scopePriority = 2 |
@@ -26,6 +27,7 @@ class ModelGenerationCompositeObjective implements IObjective{ | |||
26 | val ScopeObjective scopeObjective | 27 | val ScopeObjective scopeObjective |
27 | val List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives | 28 | val List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives |
28 | val UnfinishedWFObjective unfinishedWFObjective | 29 | val UnfinishedWFObjective unfinishedWFObjective |
30 | var PartialInterpretation model=null; | ||
29 | 31 | ||
30 | public new( | 32 | public new( |
31 | ScopeObjective scopeObjective, | 33 | ScopeObjective scopeObjective, |
@@ -38,6 +40,7 @@ class ModelGenerationCompositeObjective implements IObjective{ | |||
38 | } | 40 | } |
39 | 41 | ||
40 | override init(ThreadContext context) { | 42 | override init(ThreadContext context) { |
43 | model = context.model as PartialInterpretation | ||
41 | this.scopeObjective.init(context) | 44 | this.scopeObjective.init(context) |
42 | this.unfinishedMultiplicityObjectives.forEach[it.init(context)] | 45 | this.unfinishedMultiplicityObjectives.forEach[it.init(context)] |
43 | this.unfinishedWFObjective.init(context) | 46 | this.unfinishedWFObjective.init(context) |
@@ -64,11 +67,15 @@ class ModelGenerationCompositeObjective implements IObjective{ | |||
64 | nonContainmentMultiplicity+=multiplicityObjective.getFitness(context) | 67 | nonContainmentMultiplicity+=multiplicityObjective.getFitness(context) |
65 | } | 68 | } |
66 | } | 69 | } |
70 | val size = 0.9/model.newElements.size | ||
67 | var sum = 0.0 | 71 | var sum = 0.0 |
68 | sum += scopeFitnes | 72 | sum += scopeFitnes |
69 | sum += containmentMultiplicity | 73 | sum += containmentMultiplicity*2 |
70 | sum += Math.sqrt(nonContainmentMultiplicity) | 74 | sum += nonContainmentMultiplicity |
71 | sum += unfinishedWFsFitness//*0.5 | 75 | sum += unfinishedWFsFitness |
76 | sum+=size | ||
77 | |||
78 | |||
72 | 79 | ||
73 | //println('''Sum=«sum»|Scope=«scopeFitnes»|ContainmentMultiplicity=«containmentMultiplicity»|NonContainmentMultiplicity=«nonContainmentMultiplicity»|WFs=«unfinishedWFsFitness»''') | 80 | //println('''Sum=«sum»|Scope=«scopeFitnes»|ContainmentMultiplicity=«containmentMultiplicity»|NonContainmentMultiplicity=«nonContainmentMultiplicity»|WFs=«unfinishedWFsFitness»''') |
74 | 81 | ||
@@ -79,7 +86,7 @@ class ModelGenerationCompositeObjective implements IObjective{ | |||
79 | override getName() { "CompositeUnfinishednessObjective"} | 86 | override getName() { "CompositeUnfinishednessObjective"} |
80 | 87 | ||
81 | override isHardObjective() { true } | 88 | override isHardObjective() { true } |
82 | override satisifiesHardObjective(Double fitness) { fitness <= 0.001 } | 89 | override satisifiesHardObjective(Double fitness) { fitness < 0.95 } |
83 | 90 | ||
84 | 91 | ||
85 | override setComparator(Comparator<Double> comparator) { | 92 | override setComparator(Comparator<Double> comparator) { |