diff options
author | 2021-01-14 13:12:17 -0500 | |
---|---|---|
committer | 2021-01-14 13:12:17 -0500 | |
commit | 8402974389274d7427b67d6bbac0d5f3eae64deb (patch) | |
tree | 489c4e43efb6d1f8a76077a7efe25a43c2d46802 /Domains/crossingScenario/src | |
parent | complete change of real representation BigDecimal->Double (diff) | |
download | VIATRA-Generator-8402974389274d7427b67d6bbac0d5f3eae64deb.tar.gz VIATRA-Generator-8402974389274d7427b67d6bbac0d5f3eae64deb.tar.zst VIATRA-Generator-8402974389274d7427b67d6bbac0d5f3eae64deb.zip |
some cleanup
Diffstat (limited to 'Domains/crossingScenario/src')
-rw-r--r-- | Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java | 168 |
1 files changed, 103 insertions, 65 deletions
diff --git a/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java b/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java index 7cbf626d..7f19d2a8 100644 --- a/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java +++ b/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java | |||
@@ -1,73 +1,111 @@ | |||
1 | package crossingScenario.run; | 1 | package crossingScenario.run; |
2 | 2 | ||
3 | import java.util.ArrayList; | ||
4 | import java.util.HashMap; | ||
5 | import java.util.List; | ||
6 | import java.util.Map; | ||
7 | import java.util.regex.Matcher; | ||
8 | import java.util.regex.Pattern; | ||
9 | |||
3 | public class QueryDebug { | 10 | public class QueryDebug { |
4 | // public static void main(String[] args) { | 11 | /* |
5 | // Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); | 12 | public static void main(String[] args) { |
13 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); | ||
14 | EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); | ||
15 | ResourceSet rs = new ResourceSetImpl(); | ||
16 | rs.getResource(URI.createFileURI("inputs/sample.xmi"), true); | ||
17 | |||
18 | ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); | ||
19 | // Access pattern matcher | ||
20 | |||
21 | |||
22 | |||
23 | SimpleScenarioQueries.instance().prepare(engine); | ||
24 | RefSpec.Matcher matcher = RefSpec.Matcher.on(engine); | ||
25 | // Get and iterate over all matches | ||
26 | for (RefSpec.Match match : matcher.getAllMatches()) { | ||
27 | // Print all the matches to the standard output | ||
28 | System.out.println(match.getL()); | ||
29 | } | ||
30 | } | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | public static void main(String[] args) { | ||
35 | //Add xmi resource | ||
36 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); | ||
37 | //Add required EPackages | ||
6 | // EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); | 38 | // EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); |
7 | // ResourceSet rs = new ResourceSetImpl(); | 39 | EPackage.Registry.INSTANCE.put(LogiclanguagePackage.eNS_URI, LogiclanguagePackage.eINSTANCE); |
8 | // rs.getResource(URI.createFileURI("inputs/sample.xmi"), true); | 40 | EPackage.Registry.INSTANCE.put(LogicproblemPackage.eNS_URI, LogicproblemPackage.eINSTANCE); |
9 | // | 41 | EPackage.Registry.INSTANCE.put(PartialinterpretationPackage.eNS_URI, PartialinterpretationPackage.eINSTANCE); |
10 | // ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); | 42 | EPackage.Registry.INSTANCE.put(Ecore2logicannotationsPackage.eNS_URI, Ecore2logicannotationsPackage.eINSTANCE); |
11 | // // Access pattern matcher | 43 | EPackage.Registry.INSTANCE.put(Partial2logicannotationsPackage.eNS_URI, Partial2logicannotationsPackage.eINSTANCE); |
12 | // | 44 | EPackage.Registry.INSTANCE.put(Viatra2LogicAnnotationsPackage.eNS_URI, Viatra2LogicAnnotationsPackage.eINSTANCE); |
13 | // | 45 | EPackage.Registry.INSTANCE.put(LogicresultPackage.eNS_URI, LogicresultPackage.eINSTANCE); |
14 | // | 46 | |
15 | // SimpleScenarioQueries.instance().prepare(engine); | 47 | //Get res |
16 | // RefSpec.Matcher matcher = RefSpec.Matcher.on(engine); | 48 | ResourceSet rs = new ResourceSetImpl(); |
17 | // // Get and iterate over all matches | 49 | rs.getResource(URI.createFileURI("inputs/partial-int.xmi"), true); |
18 | // for (RefSpec.Match match : matcher.getAllMatches()) { | 50 | |
19 | // // Print all the matches to the standard output | 51 | ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); |
20 | // System.out.println(match.getL()); | 52 | // Access pattern matcher |
21 | // } | 53 | |
22 | // } | 54 | |
55 | |||
56 | LogProb.instance().prepare(engine); | ||
57 | // Get and iterate over all matches | ||
58 | System.out.println("UPMUST:"); | ||
59 | for (UPMUSTPropagateConstraint0_pattern_queries_refSpec.Match match : | ||
60 | UPMUSTPropagateConstraint0_pattern_queries_refSpec.Matcher.on(engine).getAllMatches()) { | ||
61 | // Print all the matches to the standard output | ||
62 | System.out.println(match.getVar_l()); | ||
63 | } | ||
64 | |||
65 | System.out.println("mustIn:"); | ||
66 | for (MustInRelationreferenceCoord_attribute_Lane.Match match : | ||
67 | MustInRelationreferenceCoord_attribute_Lane.Matcher.on(engine).getAllMatches()) { | ||
68 | // Print all the matches to the standard output | ||
69 | DefinedElement de = match.getTarget(); | ||
70 | System.out.println(de); | ||
71 | System.out.println("--set?: " + ((PrimitiveElement) de).isValueSet()); | ||
72 | System.out.println("--val?: " + ((IntegerElement) de).getValue()); | ||
73 | |||
74 | } | ||
75 | |||
76 | System.out.println("interp:"); | ||
77 | for (Interpretation.Match match : | ||
78 | Interpretation.Matcher.on(engine).getAllMatches()) { | ||
79 | // Print all the matches to the standard output | ||
80 | System.out.println(match.getProblem()); | ||
81 | } | ||
82 | } | ||
83 | */ | ||
23 | 84 | ||
24 | public static void main(String[] args) { | 85 | public static void main(String[] args) { |
25 | // //Add xmi resource | 86 | ArrayList<String> out = new ArrayList<String>(); |
26 | // Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); | 87 | out.add("delta-sat with delta = 0.001"); |
27 | // //Add required EPackages | 88 | out.add("w1602659765 : [1.797693134862315708e+308, 1.797693134862315708e+308]"); |
28 | //// EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); | 89 | String s = "1.797693134862315708e+308"; |
29 | // EPackage.Registry.INSTANCE.put(LogiclanguagePackage.eNS_URI, LogiclanguagePackage.eINSTANCE); | 90 | |
30 | // EPackage.Registry.INSTANCE.put(LogicproblemPackage.eNS_URI, LogicproblemPackage.eINSTANCE); | 91 | System.out.println(parseDrealOutput(out)); |
31 | // EPackage.Registry.INSTANCE.put(PartialinterpretationPackage.eNS_URI, PartialinterpretationPackage.eINSTANCE); | 92 | |
32 | // EPackage.Registry.INSTANCE.put(Ecore2logicannotationsPackage.eNS_URI, Ecore2logicannotationsPackage.eINSTANCE); | 93 | } |
33 | // EPackage.Registry.INSTANCE.put(Partial2logicannotationsPackage.eNS_URI, Partial2logicannotationsPackage.eINSTANCE); | 94 | |
34 | // EPackage.Registry.INSTANCE.put(Viatra2LogicAnnotationsPackage.eNS_URI, Viatra2LogicAnnotationsPackage.eINSTANCE); | 95 | private static Map<String, String> parseDrealOutput(List<String> output) { |
35 | // EPackage.Registry.INSTANCE.put(LogicresultPackage.eNS_URI, LogicresultPackage.eINSTANCE); | 96 | Map<String, String> res = new HashMap<String, String>(); |
36 | // | 97 | String re = "(\\w+) : \\[([0-9\\+-.e]+), ([0-9\\+-.e]+)\\]"; |
37 | // //Get res | 98 | // String re = "(\\w+) : \\[(.*), (.*)\\]"; |
38 | // ResourceSet rs = new ResourceSetImpl(); | 99 | Pattern p = Pattern.compile(re); |
39 | // rs.getResource(URI.createFileURI("inputs/partial-int.xmi"), true); | 100 | for (String varVal : output) { |
40 | // | 101 | Matcher m = p.matcher(varVal); |
41 | // ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); | 102 | if (m.matches()) { |
42 | // // Access pattern matcher | 103 | String name = m.group(1); |
43 | // | 104 | String lowerB = m.group(2); |
44 | // | 105 | String upperB = m.group(2); |
45 | // | 106 | res.put(name, lowerB); |
46 | // LogProb.instance().prepare(engine); | 107 | } |
47 | // // Get and iterate over all matches | 108 | } |
48 | // System.out.println("UPMUST:"); | 109 | return res; |
49 | // for (UPMUSTPropagateConstraint0_pattern_queries_refSpec.Match match : | ||
50 | // UPMUSTPropagateConstraint0_pattern_queries_refSpec.Matcher.on(engine).getAllMatches()) { | ||
51 | // // Print all the matches to the standard output | ||
52 | // System.out.println(match.getVar_l()); | ||
53 | // } | ||
54 | // | ||
55 | // System.out.println("mustIn:"); | ||
56 | // for (MustInRelationreferenceCoord_attribute_Lane.Match match : | ||
57 | // MustInRelationreferenceCoord_attribute_Lane.Matcher.on(engine).getAllMatches()) { | ||
58 | // // Print all the matches to the standard output | ||
59 | // DefinedElement de = match.getTarget(); | ||
60 | // System.out.println(de); | ||
61 | // System.out.println("--set?: " + ((PrimitiveElement) de).isValueSet()); | ||
62 | // System.out.println("--val?: " + ((IntegerElement) de).getValue()); | ||
63 | // | ||
64 | // } | ||
65 | // | ||
66 | // System.out.println("interp:"); | ||
67 | // for (Interpretation.Match match : | ||
68 | // Interpretation.Matcher.on(engine).getAllMatches()) { | ||
69 | // // Print all the matches to the standard output | ||
70 | // System.out.println(match.getProblem()); | ||
71 | // } | ||
72 | } | 110 | } |
73 | } | 111 | } |