diff options
author | 2020-05-17 01:35:57 +0200 | |
---|---|---|
committer | 2020-05-17 01:35:57 +0200 | |
commit | d03c841f2e4114a442deb08946c391c823745953 (patch) | |
tree | 334294a46f4b7bfe3aad8dbda368fb7ea5e5b6c0 | |
parent | Setting delimier in every printing mode to ',' (diff) | |
download | VIATRA-Generator-d03c841f2e4114a442deb08946c391c823745953.tar.gz VIATRA-Generator-d03c841f2e4114a442deb08946c391c823745953.tar.zst VIATRA-Generator-d03c841f2e4114a442deb08946c391c823745953.zip |
detailed runtimes + counting defined objects only
4 files changed, 81 insertions, 44 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend index abfa4554..8012776f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend | |||
@@ -8,6 +8,7 @@ import java.util.Map | |||
8 | import java.util.Set | 8 | import java.util.Set |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation |
10 | import java.util.HashSet | 10 | import java.util.HashSet |
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
11 | 12 | ||
12 | class ScopePropagator { | 13 | class ScopePropagator { |
13 | PartialInterpretation partialInterpretation | 14 | PartialInterpretation partialInterpretation |
@@ -61,38 +62,42 @@ class ScopePropagator { | |||
61 | } | 62 | } |
62 | 63 | ||
63 | def public propagateAdditionToType(PartialTypeInterpratation t) { | 64 | def public propagateAdditionToType(PartialTypeInterpratation t) { |
64 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | 65 | val isPrimitive = t instanceof PartialPrimitiveInterpretation || t === null |
65 | val targetScope = type2Scope.get(t) | 66 | if(!isPrimitive) { |
66 | if(targetScope!==null) { | 67 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') |
67 | targetScope.removeOne | 68 | val targetScope = type2Scope.get(t) |
68 | val sups = superScopes.get(targetScope) | 69 | if(targetScope!==null) { |
69 | sups.forEach[removeOne] | 70 | targetScope.removeOne |
70 | } | 71 | val sups = superScopes.get(targetScope) |
71 | 72 | sups.forEach[removeOne] | |
72 | if(this.partialInterpretation.minNewElements > 0) { | 73 | } |
73 | this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements-1 | 74 | |
74 | } | 75 | |
75 | if(this.partialInterpretation.maxNewElements > 0) { | 76 | if(this.partialInterpretation.minNewElements > 0 ) { |
76 | this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements-1 | 77 | this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements-1 |
77 | } else if(this.partialInterpretation.maxNewElements === 0) { | 78 | } |
78 | this.partialInterpretation.maxNewElements = 0 | 79 | if(this.partialInterpretation.maxNewElements > 0) { |
79 | //throw new IllegalArgumentException('''Inconsistent object creation: lower node limit is 0!''') | 80 | this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements-1 |
81 | } else if(this.partialInterpretation.maxNewElements === 0) { | ||
82 | this.partialInterpretation.maxNewElements = 0 | ||
83 | //throw new IllegalArgumentException('''Inconsistent object creation: lower node limit is 0!''') | ||
84 | } | ||
85 | |||
86 | // subScopes.get(targetScope).forEach[propagateUpperLimitDown(it,targetScope)] | ||
87 | // for(sup: sups) { | ||
88 | // subScopes.get(sup).forEach[propagateUpperLimitDown(it,sup)] | ||
89 | // } | ||
90 | // for(scope : type2Scope.values) { | ||
91 | // propagateUpperLimitDown(scope,partialInterpretation) | ||
92 | // } | ||
93 | |||
94 | propagateAllScopeConstraints | ||
95 | |||
96 | // println('''Target Scope: «targetScope.minNewElements» - «targetScope.maxNewElements»''') | ||
97 | // println(''' «this.partialInterpretation.minNewElements» - «this.partialInterpretation.maxNewElements»''') | ||
98 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] | ||
99 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | ||
80 | } | 100 | } |
81 | |||
82 | // subScopes.get(targetScope).forEach[propagateUpperLimitDown(it,targetScope)] | ||
83 | // for(sup: sups) { | ||
84 | // subScopes.get(sup).forEach[propagateUpperLimitDown(it,sup)] | ||
85 | // } | ||
86 | // for(scope : type2Scope.values) { | ||
87 | // propagateUpperLimitDown(scope,partialInterpretation) | ||
88 | // } | ||
89 | |||
90 | propagateAllScopeConstraints | ||
91 | |||
92 | // println('''Target Scope: «targetScope.minNewElements» - «targetScope.maxNewElements»''') | ||
93 | // println(''' «this.partialInterpretation.minNewElements» - «this.partialInterpretation.maxNewElements»''') | ||
94 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] | ||
95 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | ||
96 | } | 101 | } |
97 | 102 | ||
98 | private def propagateLowerLimitUp(Scope subScope, Scope superScope) { | 103 | private def propagateLowerLimitUp(Scope subScope, Scope superScope) { |
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) { |