diff options
author | 2020-04-22 13:14:23 -0400 | |
---|---|---|
committer | 2020-04-22 13:14:23 -0400 | |
commit | 2cf27da1e2d10d358f7438e702e075ef1360fcbe (patch) | |
tree | 290cecd3d178581b0e7e0153b918d7398312f1c2 /Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu | |
parent | Added measurements (diff) | |
download | VIATRA-Generator-2cf27da1e2d10d358f7438e702e075ef1360fcbe.tar.gz VIATRA-Generator-2cf27da1e2d10d358f7438e702e075ef1360fcbe.tar.zst VIATRA-Generator-2cf27da1e2d10d358f7438e702e075ef1360fcbe.zip |
Added new test
Diffstat (limited to 'Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu')
2 files changed, 49 insertions, 2 deletions
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend index 569414f0..a27e8904 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend | |||
@@ -25,7 +25,8 @@ class ExpressionEvaluation2Logic { | |||
25 | def Term transformEval(PVariable target, XExpression expression, Map<PVariable, Variable> variable2Variable) { | 25 | def Term transformEval(PVariable target, XExpression expression, Map<PVariable, Variable> variable2Variable) { |
26 | // numericSolver.testIsNotSat(expression, expression.transform(variable2Variable)); | 26 | // numericSolver.testIsNotSat(expression, expression.transform(variable2Variable)); |
27 | // numericSolver.testGetOneSol(expression, expression.transform(variable2Variable)); | 27 | // numericSolver.testGetOneSol(expression, expression.transform(variable2Variable)); |
28 | numericSolver.testGetOneSol2(expression, expression.transform(variable2Variable)); | 28 | // numericSolver.testGetOneSol2(expression, expression.transform(variable2Variable)); |
29 | numericSolver.testGetOneSol3(expression, expression.transform(variable2Variable)); | ||
29 | // numericSolver.testIsSat(expression, expression.transform(variable2Variable)); | 30 | // numericSolver.testIsSat(expression, expression.transform(variable2Variable)); |
30 | 31 | ||
31 | return expression.transform(variable2Variable) | 32 | return expression.transform(variable2Variable) |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java index 7845c528..ff3a85eb 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java | |||
@@ -5,6 +5,7 @@ import java.util.HashMap; | |||
5 | import java.util.HashSet; | 5 | import java.util.HashSet; |
6 | import java.util.List; | 6 | import java.util.List; |
7 | import java.util.Map; | 7 | import java.util.Map; |
8 | import java.util.Random; | ||
8 | import java.util.Set; | 9 | import java.util.Set; |
9 | 10 | ||
10 | import org.eclipse.xtext.common.types.JvmIdentifiableElement; | 11 | import org.eclipse.xtext.common.types.JvmIdentifiableElement; |
@@ -165,7 +166,7 @@ public class NumericProblemSolver { | |||
165 | } | 166 | } |
166 | 167 | ||
167 | public void testGetOneSol2(XExpression expression, Term t) throws Exception { | 168 | public void testGetOneSol2(XExpression expression, Term t) throws Exception { |
168 | int count = 100; | 169 | int count = 250; |
169 | Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches = new HashMap<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>>(); | 170 | Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches = new HashMap<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>>(); |
170 | Set<Map<JvmIdentifiableElement,PrimitiveElement>> matchSet = new HashSet<Map<JvmIdentifiableElement,PrimitiveElement>>(); | 171 | Set<Map<JvmIdentifiableElement,PrimitiveElement>> matchSet = new HashSet<Map<JvmIdentifiableElement,PrimitiveElement>>(); |
171 | ArrayList<JvmIdentifiableElement> allElem = getJvmIdentifiableElements(expression); | 172 | ArrayList<JvmIdentifiableElement> allElem = getJvmIdentifiableElements(expression); |
@@ -208,6 +209,49 @@ public class NumericProblemSolver { | |||
208 | System.out.println("Number of matches: " + matchSet.size()); | 209 | System.out.println("Number of matches: " + matchSet.size()); |
209 | for (int i = 0; i < 10; i++) { | 210 | for (int i = 0; i < 10; i++) { |
210 | Map<Object,Integer> sol = getOneSolution(obj, matches); | 211 | Map<Object,Integer> sol = getOneSolution(obj, matches); |
212 | System.out.println("**********************"); | ||
213 | Thread.sleep(3000); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | public void testGetOneSol3(XExpression expression, Term t) throws Exception { | ||
218 | int count = 15000; | ||
219 | Random rand = new Random(); | ||
220 | Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches = new HashMap<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>>(); | ||
221 | Set<Map<JvmIdentifiableElement,PrimitiveElement>> matchSet = new HashSet<Map<JvmIdentifiableElement,PrimitiveElement>>(); | ||
222 | ArrayList<JvmIdentifiableElement> allElem = getJvmIdentifiableElements(expression); | ||
223 | List<Object> obj = new ArrayList<Object>(); | ||
224 | for (int i = 0; i < count; i++) { | ||
225 | Map<JvmIdentifiableElement,PrimitiveElement> match = new HashMap<JvmIdentifiableElement,PrimitiveElement>(); | ||
226 | if (obj.size() > 1) { | ||
227 | for (JvmIdentifiableElement e: allElem) { | ||
228 | FakeIntegerElement intE = null; | ||
229 | int useOld = rand.nextInt(10); | ||
230 | if (useOld == 1) { | ||
231 | System.out.println("here "); | ||
232 | int index = rand.nextInt(obj.size()); | ||
233 | intE = (FakeIntegerElement) obj.get(index); | ||
234 | } else { | ||
235 | intE = new FakeIntegerElement(); | ||
236 | } | ||
237 | obj.add(intE); | ||
238 | match.put(e, intE); | ||
239 | } | ||
240 | } else { | ||
241 | for (JvmIdentifiableElement e: allElem) { | ||
242 | FakeIntegerElement intE = new FakeIntegerElement(); | ||
243 | obj.add(intE); | ||
244 | match.put(e, intE); | ||
245 | } | ||
246 | } | ||
247 | matchSet.add(match); | ||
248 | } | ||
249 | matches.put(expression, matchSet); | ||
250 | |||
251 | System.out.println("Number of matches: " + matchSet.size()); | ||
252 | for (int i = 0; i < 10; i++) { | ||
253 | Map<Object,Integer> sol = getOneSolution(obj, matches); | ||
254 | System.out.println("**********************"); | ||
211 | Thread.sleep(3000); | 255 | Thread.sleep(3000); |
212 | } | 256 | } |
213 | } | 257 | } |
@@ -257,6 +301,8 @@ public class NumericProblemSolver { | |||
257 | } | 301 | } |
258 | long endFormingSolution = System.currentTimeMillis(); | 302 | long endFormingSolution = System.currentTimeMillis(); |
259 | System.out.println("Forming solution: " + (endFormingSolution - startFormingSolution)); | 303 | System.out.println("Forming solution: " + (endFormingSolution - startFormingSolution)); |
304 | } else { | ||
305 | System.out.println("Unsatisfiable"); | ||
260 | } | 306 | } |
261 | 307 | ||
262 | return sol; | 308 | return sol; |