From 278ad1aa5f8cff85604f98c2a2e7269753cdbd47 Mon Sep 17 00:00:00 2001 From: Aren Babikian Date: Thu, 21 Jan 2021 06:47:08 +0100 Subject: Major MM update + Refactor VQL + post-meeting approach change --- .../viatra2logic/NumericDrealProblemSolver.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src') diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericDrealProblemSolver.java b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericDrealProblemSolver.java index 575a9224..b8ab8e95 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericDrealProblemSolver.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericDrealProblemSolver.java @@ -193,15 +193,24 @@ public class NumericDrealProblemSolver extends NumericProblemSolver{ PrimitiveElement matchedObj = aMatch.get(((XFeatureCall) e).getFeature()); boolean isInt = matchedObj instanceof IntegerElement; if (!matchedObj.isValueSet()) { + //e is UNDEFINED term if (varMap.get(matchedObj) == null) { + //define and store the name of the matchedObj expr = ((XFeatureCall) e).getFeature().getQualifiedName() + matchedObj.hashCode(); //TODO ISSUE varMap.put(matchedObj, expr); } else { + //get name if already seen expr = varMap.get(matchedObj); } + //Add variable declarations, only for UNDEFINED + if(! curVar2Decl.keySet().contains(expr)) { + String varDecl = "(declare-fun " + expr + " () "; + if (isInt) {varDecl += "Int)";} + else {varDecl += "Real)";} + curVar2Decl.put(expr, varDecl); + } } else { - //TODO unsure what it means if something gets in here - System.err.println("Reached weird place"); + //e is DEFINED term (has a value) if (isInt) { expr = Integer.toString(((IntegerElement) matchedObj).getValue()); } else { @@ -210,13 +219,6 @@ public class NumericDrealProblemSolver extends NumericProblemSolver{ } varMap.put(matchedObj, expr); } - //Add variable declarations - if(! curVar2Decl.keySet().contains(expr)) { - String varDecl = "(declare-fun " + expr + " () "; - if (isInt) {varDecl += "Int)";} - else {varDecl += "Real)";} - curVar2Decl.put(expr, varDecl); - } } // Constants else if (e instanceof XNumberLiteral) { @@ -375,8 +377,9 @@ public class NumericDrealProblemSolver extends NumericProblemSolver{ //DEBUG - Print things if (outputProcess == null) { System.err.println("TIMEOUT"); -// printOutput(numProbContent); + printOutput(numProbContent); } + // printOutput(numProbContent); // if (outputs != null) printOutput(outputs.get(0)); // System.out.println(result); @@ -434,8 +437,8 @@ public class NumericDrealProblemSolver extends NumericProblemSolver{ //DEBUG - Print things System.out.println("Getting Solution!"); -// printOutput(numProbContent); -// printOutput(outputs.get(0)); + printOutput(numProbContent); + printOutput(outputs.get(0)); // System.out.println(result); //END DEBUG -- cgit v1.2.3-54-g00ecf