aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java
diff options
context:
space:
mode:
authorLibravatar anqili426 <mollisterkl@outlook.com>2020-04-22 13:14:23 -0400
committerLibravatar anqili426 <mollisterkl@outlook.com>2020-04-22 13:14:23 -0400
commit2cf27da1e2d10d358f7438e702e075ef1360fcbe (patch)
tree290cecd3d178581b0e7e0153b918d7398312f1c2 /Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java
parentAdded measurements (diff)
downloadVIATRA-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/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java')
-rw-r--r--Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java48
1 files changed, 47 insertions, 1 deletions
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;
5import java.util.HashSet; 5import java.util.HashSet;
6import java.util.List; 6import java.util.List;
7import java.util.Map; 7import java.util.Map;
8import java.util.Random;
8import java.util.Set; 9import java.util.Set;
9 10
10import org.eclipse.xtext.common.types.JvmIdentifiableElement; 11import 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;