diff options
Diffstat (limited to 'Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf')
-rw-r--r-- | Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java | 22 |
1 files changed, 15 insertions, 7 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 28fa2c64..7845c528 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 | |||
@@ -164,9 +164,8 @@ public class NumericProblemSolver { | |||
164 | System.out.println("Running time:" + (end - start)); | 164 | System.out.println("Running time:" + (end - start)); |
165 | } | 165 | } |
166 | 166 | ||
167 | |||
168 | public void testGetOneSol2(XExpression expression, Term t) throws Exception { | 167 | public void testGetOneSol2(XExpression expression, Term t) throws Exception { |
169 | int count = 50; | 168 | int count = 100; |
170 | Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches = new HashMap<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>>(); | 169 | Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches = new HashMap<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>>(); |
171 | Set<Map<JvmIdentifiableElement,PrimitiveElement>> matchSet = new HashSet<Map<JvmIdentifiableElement,PrimitiveElement>>(); | 170 | Set<Map<JvmIdentifiableElement,PrimitiveElement>> matchSet = new HashSet<Map<JvmIdentifiableElement,PrimitiveElement>>(); |
172 | ArrayList<JvmIdentifiableElement> allElem = getJvmIdentifiableElements(expression); | 171 | ArrayList<JvmIdentifiableElement> allElem = getJvmIdentifiableElements(expression); |
@@ -206,12 +205,11 @@ public class NumericProblemSolver { | |||
206 | } | 205 | } |
207 | matches.put(expression, matchSet); | 206 | matches.put(expression, matchSet); |
208 | 207 | ||
209 | long start = System.currentTimeMillis(); | ||
210 | Map<Object,Integer> sol = getOneSolution(obj, matches); | ||
211 | long end = System.currentTimeMillis(); | ||
212 | |||
213 | System.out.println("Number of matches: " + matchSet.size()); | 208 | System.out.println("Number of matches: " + matchSet.size()); |
214 | System.out.println("Running time:" + (end - start)); | 209 | for (int i = 0; i < 10; i++) { |
210 | Map<Object,Integer> sol = getOneSolution(obj, matches); | ||
211 | Thread.sleep(3000); | ||
212 | } | ||
215 | } | 213 | } |
216 | 214 | ||
217 | private ArrayList<JvmIdentifiableElement> getJvmIdentifiableElements(XExpression expression) { | 215 | private ArrayList<JvmIdentifiableElement> getJvmIdentifiableElements(XExpression expression) { |
@@ -241,16 +239,26 @@ public class NumericProblemSolver { | |||
241 | 239 | ||
242 | public Map<Object,Integer> getOneSolution(List<Object> objs, Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches) throws Exception { | 240 | public Map<Object,Integer> getOneSolution(List<Object> objs, Map<XExpression, Set<Map<JvmIdentifiableElement,PrimitiveElement>>> matches) throws Exception { |
243 | Map<Object,Integer> sol = new HashMap<Object, Integer>(); | 241 | Map<Object,Integer> sol = new HashMap<Object, Integer>(); |
242 | long startformingProblem = System.currentTimeMillis(); | ||
244 | BoolExpr problemInstance = formNumericProblemInstance(matches); | 243 | BoolExpr problemInstance = formNumericProblemInstance(matches); |
244 | long endformingProblem = System.currentTimeMillis(); | ||
245 | System.out.println("Forming problem: " + (endformingProblem - startformingProblem)); | ||
245 | s.add(problemInstance); | 246 | s.add(problemInstance); |
247 | long startSolvingProblem = System.currentTimeMillis(); | ||
246 | if (s.check() == Status.SATISFIABLE) { | 248 | if (s.check() == Status.SATISFIABLE) { |
247 | Model m = s.getModel(); | 249 | Model m = s.getModel(); |
250 | long endSolvingProblem = System.currentTimeMillis(); | ||
251 | System.out.println("Solving problem: " + (endSolvingProblem - startSolvingProblem)); | ||
252 | long startFormingSolution = System.currentTimeMillis(); | ||
248 | for (Object o: objs) { | 253 | for (Object o: objs) { |
249 | IntExpr val =(IntExpr) m.evaluate(varMap.get(o), false); | 254 | IntExpr val =(IntExpr) m.evaluate(varMap.get(o), false); |
250 | Integer oSol = Integer.parseInt(val.toString()); | 255 | Integer oSol = Integer.parseInt(val.toString()); |
251 | sol.put(o, oSol); | 256 | sol.put(o, oSol); |
252 | } | 257 | } |
258 | long endFormingSolution = System.currentTimeMillis(); | ||
259 | System.out.println("Forming solution: " + (endFormingSolution - startFormingSolution)); | ||
253 | } | 260 | } |
261 | |||
254 | return sol; | 262 | return sol; |
255 | } | 263 | } |
256 | 264 | ||