diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2020-06-27 17:56:46 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2020-06-27 17:56:46 +0200 |
commit | 957082776dbb7efed53a783c5e5be6b443a9bb86 (patch) | |
tree | 6b88701d4b1b3928b7d3e7de49d177ca8c93ffad /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu | |
parent | Merge branch 'kris' (diff) | |
download | VIATRA-Generator-957082776dbb7efed53a783c5e5be6b443a9bb86.tar.gz VIATRA-Generator-957082776dbb7efed53a783c5e5be6b443a9bb86.tar.zst VIATRA-Generator-957082776dbb7efed53a783c5e5be6b443a9bb86.zip |
Fix scope + numerical propagation WIP
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu')
4 files changed, 10 insertions, 21 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend index ddd25aac..e33a2590 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend | |||
@@ -58,13 +58,14 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration { | |||
58 | public var runIntermediateNumericalConsistencyChecks = true | 58 | public var runIntermediateNumericalConsistencyChecks = true |
59 | 59 | ||
60 | public var punishSize = true | 60 | public var punishSize = true |
61 | public var scopeWeight = 1 | 61 | public var scopeWeight = 2 |
62 | public var conaintmentWeight = 2 | 62 | public var conaintmentWeight = 1 |
63 | public var nonContainmentWeight = 1 | 63 | public var nonContainmentWeight = 1 |
64 | public var unfinishedWFWeight = 1 | 64 | public var unfinishedWFWeight = 1 |
65 | 65 | ||
66 | public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( | 66 | public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( |
67 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) | 67 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) |
68 | // public var ScopePropagatorStrategy scopePropagatorStrategy = ScopePropagatorStrategy.BasicTypeHierarchy | ||
68 | 69 | ||
69 | public var List<LinearTypeConstraintHint> hints = newArrayList | 70 | public var List<LinearTypeConstraintHint> hints = newArrayList |
70 | 71 | ||
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 e529892c..09575384 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 | |||
@@ -18,6 +18,7 @@ import java.util.List; | |||
18 | import java.util.PriorityQueue; | 18 | import java.util.PriorityQueue; |
19 | import java.util.Random; | 19 | import java.util.Random; |
20 | 20 | ||
21 | import org.apache.log4j.Level; | ||
21 | import org.apache.log4j.Logger; | 22 | import org.apache.log4j.Logger; |
22 | import org.eclipse.emf.ecore.EObject; | 23 | import org.eclipse.emf.ecore.EObject; |
23 | import org.eclipse.emf.ecore.util.EcoreUtil; | 24 | import org.eclipse.emf.ecore.util.EcoreUtil; |
@@ -76,7 +77,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
76 | private volatile boolean isInterrupted = false; | 77 | private volatile boolean isInterrupted = false; |
77 | private ModelResult modelResultByInternalSolver = null; | 78 | private ModelResult modelResultByInternalSolver = null; |
78 | private Random random = new Random(); | 79 | private Random random = new Random(); |
79 | //private Collection<ViatraQueryMatcher<? extends IPatternMatch>> matchers; | 80 | // private Collection<ViatraQueryMatcher<? extends IPatternMatch>> matchers; |
80 | public ActivationSelector activationSelector = new EvenActivationSelector(random); | 81 | public ActivationSelector activationSelector = new EvenActivationSelector(random); |
81 | public ViatraReasonerSolutionSaver solutionSaver; | 82 | public ViatraReasonerSolutionSaver solutionSaver; |
82 | public NumericSolver numericSolver; | 83 | public NumericSolver numericSolver; |
@@ -100,7 +101,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
100 | this.method = method; | 101 | this.method = method; |
101 | this.solutionSaver = solutionSaver; | 102 | this.solutionSaver = solutionSaver; |
102 | this.numericSolver = numericSolver; | 103 | this.numericSolver = numericSolver; |
103 | //logger.setLevel(Level.DEBUG); | 104 | // logger.setLevel(Level.DEBUG); |
104 | } | 105 | } |
105 | 106 | ||
106 | public int getNumberOfStatecoderFail() { | 107 | public int getNumberOfStatecoderFail() { |
@@ -136,7 +137,6 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
136 | // ViatraQueryEngine engine = context.getQueryEngine(); | 137 | // ViatraQueryEngine engine = context.getQueryEngine(); |
137 | // matchers = new LinkedList<ViatraQueryMatcher<? extends IPatternMatch>>(); | 138 | // matchers = new LinkedList<ViatraQueryMatcher<? extends IPatternMatch>>(); |
138 | // for(IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> p : this.method.getAllPatterns()) { | 139 | // for(IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> p : this.method.getAllPatterns()) { |
139 | // //System.out.println(p.getSimpleName()); | ||
140 | // ViatraQueryMatcher<? extends IPatternMatch> matcher = p.getMatcher(engine); | 140 | // ViatraQueryMatcher<? extends IPatternMatch> matcher = p.getMatcher(engine); |
141 | // matchers.add(matcher); | 141 | // matchers.add(matcher); |
142 | // } | 142 | // } |
@@ -154,13 +154,6 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
154 | 154 | ||
155 | @Override | 155 | @Override |
156 | public void explore() { | 156 | public void explore() { |
157 | // System.out.println("press enter"); | ||
158 | // try { | ||
159 | // new BufferedReader(new InputStreamReader(System.in)).readLine(); | ||
160 | // } catch (IOException e) { | ||
161 | // // TODO Auto-generated catch block | ||
162 | // e.printStackTrace(); | ||
163 | // } | ||
164 | this.explorationStarted=System.nanoTime(); | 157 | this.explorationStarted=System.nanoTime(); |
165 | if (!checkGlobalConstraints()) { | 158 | if (!checkGlobalConstraints()) { |
166 | logger.info("Global contraint is not satisifed in the first state. Terminate."); | 159 | logger.info("Global contraint is not satisifed in the first state. Terminate."); |
@@ -219,10 +212,6 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
219 | 212 | ||
220 | while (!isInterrupted && !configuration.progressMonitor.isCancelled() && iterator.hasNext()) { | 213 | while (!isInterrupted && !configuration.progressMonitor.isCancelled() && iterator.hasNext()) { |
221 | final Object nextActivation = iterator.next(); | 214 | final Object nextActivation = iterator.next(); |
222 | // if (!iterator.hasNext()) { | ||
223 | // logger.debug("Last untraversed activation of the state."); | ||
224 | // trajectoiresToExplore.remove(currentTrajectoryWithfitness); | ||
225 | // } | ||
226 | logger.debug("Executing new activation: " + nextActivation); | 215 | logger.debug("Executing new activation: " + nextActivation); |
227 | context.executeAcitvationId(nextActivation); | 216 | context.executeAcitvationId(nextActivation); |
228 | method.getStatistics().incrementDecisionCount(); | 217 | method.getStatistics().incrementDecisionCount(); |
@@ -230,10 +219,9 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
230 | visualiseCurrentState(); | 219 | visualiseCurrentState(); |
231 | // for(ViatraQueryMatcher<? extends IPatternMatch> matcher : matchers) { | 220 | // for(ViatraQueryMatcher<? extends IPatternMatch> matcher : matchers) { |
232 | // int c = matcher.countMatches(); | 221 | // int c = matcher.countMatches(); |
233 | // if(c>=100) { | 222 | // if(c>=1) { |
234 | // System.out.println(c+ " " +matcher.getPatternName()); | 223 | // System.out.println(c+ " " +matcher.getPatternName()); |
235 | // } | 224 | // } |
236 | // | ||
237 | // } | 225 | // } |
238 | 226 | ||
239 | boolean consistencyCheckResult = checkConsistency(currentTrajectoryWithFitness); | 227 | boolean consistencyCheckResult = checkConsistency(currentTrajectoryWithFitness); |
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 d2faaa65..481f4ce1 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 | |||
@@ -112,7 +112,7 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
112 | 112 | ||
113 | override isHardObjective() { true } | 113 | override isHardObjective() { true } |
114 | 114 | ||
115 | override satisifiesHardObjective(Double fitness) { fitness <= 0.001 } | 115 | override satisifiesHardObjective(Double fitness) { fitness <= 0.9 } |
116 | 116 | ||
117 | override setComparator(Comparator<Double> comparator) { | 117 | override setComparator(Comparator<Double> comparator) { |
118 | throw new UnsupportedOperationException("Model generation objective comparator cannot be set.") | 118 | throw new UnsupportedOperationException("Model generation objective comparator cannot be set.") |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend index 69a734f8..7abc5cb8 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend | |||
@@ -25,7 +25,7 @@ class ScopeObjective implements IObjective{ | |||
25 | val interpretation = context.model as PartialInterpretation | 25 | val interpretation = context.model as PartialInterpretation |
26 | var res = interpretation.minNewElementsHeuristic.doubleValue | 26 | var res = interpretation.minNewElementsHeuristic.doubleValue |
27 | for(scope : interpretation.scopes) { | 27 | for(scope : interpretation.scopes) { |
28 | res += scope.minNewElementsHeuristic*2 | 28 | res += scope.minNewElementsHeuristic |
29 | } | 29 | } |
30 | return res | 30 | return res |
31 | } | 31 | } |