Merge lp:~tapaal-contributor/tapaal/add-discrete-to-untimed into lp:tapaal
- add-discrete-to-untimed
- Merge into trunk
Proposed by
Lena Ernstsen
Status: | Merged |
---|---|
Approved by: | Jiri Srba |
Approved revision: | 1107 |
Merged at revision: | 1110 |
Proposed branch: | lp:~tapaal-contributor/tapaal/add-discrete-to-untimed |
Merge into: | lp:tapaal |
Diff against target: |
222 lines (+39/-23) 3 files modified
src/dk/aau/cs/gui/TabContent.java (+4/-0) src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNDiscreteVerification.java (+15/-5) src/pipe/gui/widgets/QueryDialog.java (+20/-18) |
To merge this branch: | bzr merge lp:~tapaal-contributor/tapaal/add-discrete-to-untimed |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Approve | ||
Kenneth Yrke Jørgensen | Approve | ||
Lena Ernstsen (community) | Needs Resubmitting | ||
Review via email: mp+390666@code.launchpad.net |
Commit message
Added the discrete engine to untimed, gamed nets
Description of the change
To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote : | # |
I create a simple net for untimed and game lens, ask a simple AF query and the verification ends with error in query parsing. When I save the file and open again, the GUI hals and becomes unresponsive.
review:
Needs Fixing
Revision history for this message
Lena Ernstsen (lsaid) wrote : | # |
Fixed some logic that created bugs in the querydialog
review:
Needs Resubmitting
Revision history for this message
Jiri Srba (srba) wrote : | # |
In order to make this work, before the untimed game net is sent to verifydtapn engine
there should be added new isolated place, with one token in it and age invariant <=0.
Then the timed engine will be able to mimick the untimed game semantics.
review:
Needs Fixing
Revision history for this message
Lena Ernstsen (lsaid) : | # |
review:
Needs Resubmitting
- 1107. By lsaid <email address hidden>
-
Added token to the ghost place
Revision history for this message
Kenneth Yrke Jørgensen (yrke) : | # |
review:
Approve
Revision history for this message
Jiri Srba (srba) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/dk/aau/cs/gui/TabContent.java' | |||
2 | --- src/dk/aau/cs/gui/TabContent.java 2020-09-16 19:30:40 +0000 | |||
3 | +++ src/dk/aau/cs/gui/TabContent.java 2020-09-27 13:29:30 +0000 | |||
4 | @@ -680,6 +680,10 @@ | |||
5 | 680 | q.setReductionOption(ReductionOption.VerifyTAPNdiscreteVerification); | 680 | q.setReductionOption(ReductionOption.VerifyTAPNdiscreteVerification); |
6 | 681 | q.setUseOverApproximationEnabled(false); | 681 | q.setUseOverApproximationEnabled(false); |
7 | 682 | q.setUseUnderApproximationEnabled(false); | 682 | q.setUseUnderApproximationEnabled(false); |
8 | 683 | } else if (!tab.lens.isTimed()) { | ||
9 | 684 | q.setReductionOption(ReductionOption.VerifyPN); | ||
10 | 685 | q.setUseOverApproximationEnabled(false); | ||
11 | 686 | q.setUseUnderApproximationEnabled(false); | ||
12 | 683 | } | 687 | } |
13 | 684 | } | 688 | } |
14 | 685 | String message = ""; | 689 | String message = ""; |
15 | 686 | 690 | ||
16 | === modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNDiscreteVerification.java' | |||
17 | --- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNDiscreteVerification.java 2020-08-06 13:48:04 +0000 | |||
18 | +++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNDiscreteVerification.java 2020-09-27 13:29:30 +0000 | |||
19 | @@ -5,10 +5,8 @@ | |||
20 | 5 | import dk.aau.cs.TCTL.TCTLAGNode; | 5 | import dk.aau.cs.TCTL.TCTLAGNode; |
21 | 6 | import dk.aau.cs.TCTL.TCTLEFNode; | 6 | import dk.aau.cs.TCTL.TCTLEFNode; |
22 | 7 | import dk.aau.cs.TCTL.TCTLEGNode; | 7 | import dk.aau.cs.TCTL.TCTLEGNode; |
27 | 8 | import dk.aau.cs.model.tapn.LocalTimedPlace; | 8 | import dk.aau.cs.gui.TabContent; |
28 | 9 | import dk.aau.cs.model.tapn.TAPNQuery; | 9 | import dk.aau.cs.model.tapn.*; |
25 | 10 | import dk.aau.cs.model.tapn.TimedArcPetriNet; | ||
26 | 11 | import dk.aau.cs.model.tapn.TimedPlace; | ||
29 | 12 | import dk.aau.cs.model.tapn.simulation.TimedArcPetriNetTrace; | 10 | import dk.aau.cs.model.tapn.simulation.TimedArcPetriNetTrace; |
30 | 13 | import dk.aau.cs.util.ExecutabilityChecker; | 11 | import dk.aau.cs.util.ExecutabilityChecker; |
31 | 14 | import dk.aau.cs.util.Tuple; | 12 | import dk.aau.cs.util.Tuple; |
32 | @@ -27,6 +25,7 @@ | |||
33 | 27 | import java.io.InputStream; | 25 | import java.io.InputStream; |
34 | 28 | import java.io.InputStreamReader; | 26 | import java.io.InputStreamReader; |
35 | 29 | import java.io.StringReader; | 27 | import java.io.StringReader; |
36 | 28 | import java.math.BigDecimal; | ||
37 | 30 | import java.util.ArrayList; | 29 | import java.util.ArrayList; |
38 | 31 | import java.util.List; | 30 | import java.util.List; |
39 | 32 | import java.util.regex.Matcher; | 31 | import java.util.regex.Matcher; |
40 | @@ -274,6 +273,9 @@ | |||
41 | 274 | //throw new UnsupportedQueryException("Discrete inclusion check only supports upward closed queries."); | 273 | //throw new UnsupportedQueryException("Discrete inclusion check only supports upward closed queries."); |
42 | 275 | 274 | ||
43 | 276 | if (((VerifyTAPNOptions) options).discreteInclusion()) mapDiscreteInclusionPlacesToNewNames(options, model); | 275 | if (((VerifyTAPNOptions) options).discreteInclusion()) mapDiscreteInclusionPlacesToNewNames(options, model); |
44 | 276 | if (CreateGui.getCurrentTab().getLens().isGame() && !CreateGui.getCurrentTab().getLens().isTimed()) { | ||
45 | 277 | addGhostPlace(model.value1()); | ||
46 | 278 | } | ||
47 | 277 | 279 | ||
48 | 278 | VerifyTAPNExporter exporter = new VerifyTAPNExporter(); | 280 | VerifyTAPNExporter exporter = new VerifyTAPNExporter(); |
49 | 279 | ExportedVerifyTAPNModel exportedModel = exporter.export(model.value1(), query, CreateGui.getCurrentTab().getLens()); | 281 | ExportedVerifyTAPNModel exportedModel = exporter.export(model.value1(), query, CreateGui.getCurrentTab().getLens()); |
50 | @@ -285,6 +287,13 @@ | |||
51 | 285 | return verify(options, model, exportedModel, query); | 287 | return verify(options, model, exportedModel, query); |
52 | 286 | } | 288 | } |
53 | 287 | 289 | ||
54 | 290 | //An extra place is added before verifying the query so the timed engine is able to mimic the untimed game semantics. | ||
55 | 291 | private void addGhostPlace(TimedArcPetriNet net) { | ||
56 | 292 | TimedPlace place = new LocalTimedPlace("ghost", new TimeInvariant(true, new IntBound(0))); | ||
57 | 293 | net.add(place); | ||
58 | 294 | place.addToken(new TimedToken(place, new BigDecimal(0))); | ||
59 | 295 | } | ||
60 | 296 | |||
61 | 288 | private void mapDiscreteInclusionPlacesToNewNames(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model) { | 297 | private void mapDiscreteInclusionPlacesToNewNames(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model) { |
62 | 289 | VerifyTAPNOptions verificationOptions = (VerifyTAPNOptions) options; | 298 | VerifyTAPNOptions verificationOptions = (VerifyTAPNOptions) options; |
63 | 290 | 299 | ||
64 | @@ -308,7 +317,8 @@ | |||
65 | 308 | 317 | ||
66 | 309 | private VerificationResult<TimedArcPetriNetTrace> verify(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model, ExportedVerifyTAPNModel exportedModel, TAPNQuery query) { | 318 | private VerificationResult<TimedArcPetriNetTrace> verify(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model, ExportedVerifyTAPNModel exportedModel, TAPNQuery query) { |
67 | 310 | ((VerifyTAPNOptions) options).setTokensInModel(model.value1().marking().size()); // TODO: get rid of me | 319 | ((VerifyTAPNOptions) options).setTokensInModel(model.value1().marking().size()); // TODO: get rid of me |
69 | 311 | runner = new ProcessRunner(verifydtapnpath, createArgumentString(exportedModel.modelFile(), exportedModel.queryFile(), options)); | 320 | |
70 | 321 | runner = new ProcessRunner(verifydtapnpath, createArgumentString(exportedModel.modelFile(), exportedModel.queryFile(), options)); | ||
71 | 312 | runner.run(); | 322 | runner.run(); |
72 | 313 | 323 | ||
73 | 314 | if (runner.error()) { | 324 | if (runner.error()) { |
74 | 315 | 325 | ||
75 | === modified file 'src/pipe/gui/widgets/QueryDialog.java' | |||
76 | --- src/pipe/gui/widgets/QueryDialog.java 2020-09-23 11:37:19 +0000 | |||
77 | +++ src/pipe/gui/widgets/QueryDialog.java 2020-09-27 13:29:30 +0000 | |||
78 | @@ -371,10 +371,10 @@ | |||
79 | 371 | TAPNQuery.SearchOption searchOption = getSearchOption(); | 371 | TAPNQuery.SearchOption searchOption = getSearchOption(); |
80 | 372 | ReductionOption reductionOptionToSet = getReductionOption(); | 372 | ReductionOption reductionOptionToSet = getReductionOption(); |
81 | 373 | 373 | ||
83 | 374 | if (lens.isTimed()) { | 374 | if (!lens.isGame() && !lens.isTimed()) { |
84 | 375 | return getUntimedQuery(name, capacity, traceOption, searchOption, reductionOptionToSet); | ||
85 | 376 | } else { | ||
86 | 375 | return getTimedQuery(name, capacity, traceOption, searchOption, reductionOptionToSet); | 377 | return getTimedQuery(name, capacity, traceOption, searchOption, reductionOptionToSet); |
87 | 376 | } else { | ||
88 | 377 | return getUntimedQuery(name, capacity, traceOption, searchOption, reductionOptionToSet); | ||
89 | 378 | } | 378 | } |
90 | 379 | } | 379 | } |
91 | 380 | 380 | ||
92 | @@ -690,10 +690,10 @@ | |||
93 | 690 | templateBox.setSelectedItem(tapnNetwork.getTAPNByName(placeNode.getTemplate())); | 690 | templateBox.setSelectedItem(tapnNetwork.getTAPNByName(placeNode.getTemplate())); |
94 | 691 | } | 691 | } |
95 | 692 | } | 692 | } |
97 | 693 | if (lens.isTimed()) { | 693 | if (!lens.isGame() && !lens.isTimed()) { |
98 | 694 | updateUntimedQueryButtons(node); | ||
99 | 695 | } else { | ||
100 | 694 | updateTimedQueryButtons(node); | 696 | updateTimedQueryButtons(node); |
101 | 695 | } else { | ||
102 | 696 | updateUntimedQueryButtons(node); | ||
103 | 697 | } | 697 | } |
104 | 698 | } else if (current instanceof TCTLTransitionNode) { | 698 | } else if (current instanceof TCTLTransitionNode) { |
105 | 699 | TCTLTransitionNode transitionNode = (TCTLTransitionNode) current; | 699 | TCTLTransitionNode transitionNode = (TCTLTransitionNode) current; |
106 | @@ -891,6 +891,8 @@ | |||
107 | 891 | } | 891 | } |
108 | 892 | } else if (!lens.isGame()) { | 892 | } else if (!lens.isGame()) { |
109 | 893 | options.add(name_UNTIMED); | 893 | options.add(name_UNTIMED); |
110 | 894 | } else { | ||
111 | 895 | options.add(name_DISCRETE); | ||
112 | 894 | } | 896 | } |
113 | 895 | 897 | ||
114 | 896 | reductionOption.removeAllItems(); | 898 | reductionOption.removeAllItems(); |
115 | @@ -1199,7 +1201,7 @@ | |||
116 | 1199 | queryName.setText(queryToCreateFrom.getName()); | 1201 | queryName.setText(queryToCreateFrom.getName()); |
117 | 1200 | numberOfExtraTokensInNet.setValue(queryToCreateFrom.getCapacity()); | 1202 | numberOfExtraTokensInNet.setValue(queryToCreateFrom.getCapacity()); |
118 | 1201 | 1203 | ||
120 | 1202 | if (lens.isTimed()) { | 1204 | if (lens.isTimed() || lens.isGame()) { |
121 | 1203 | setupQuantificationFromQuery(queryToCreateFrom); | 1205 | setupQuantificationFromQuery(queryToCreateFrom); |
122 | 1204 | setupApproximationOptionsFromQuery(queryToCreateFrom); | 1206 | setupApproximationOptionsFromQuery(queryToCreateFrom); |
123 | 1205 | } | 1207 | } |
124 | @@ -1252,7 +1254,7 @@ | |||
125 | 1252 | reductionOption.addItem(reduction); | 1254 | reductionOption.addItem(reduction); |
126 | 1253 | reductionOption.setSelectedItem(reduction); | 1255 | reductionOption.setSelectedItem(reduction); |
127 | 1254 | 1256 | ||
129 | 1255 | if (lens.isTimed()) { | 1257 | if (lens.isTimed() || lens.isGame()) { |
130 | 1256 | setupTimedReductionOptions(queryToCreateFrom); | 1258 | setupTimedReductionOptions(queryToCreateFrom); |
131 | 1257 | } else { | 1259 | } else { |
132 | 1258 | setupUntimedReductionOptions(queryToCreateFrom); | 1260 | setupUntimedReductionOptions(queryToCreateFrom); |
133 | @@ -1449,7 +1451,7 @@ | |||
134 | 1449 | 1451 | ||
135 | 1450 | searchOptionsPanel.setVisible(advancedView); | 1452 | searchOptionsPanel.setVisible(advancedView); |
136 | 1451 | reductionOptionsPanel.setVisible(advancedView); | 1453 | reductionOptionsPanel.setVisible(advancedView); |
138 | 1452 | if (lens.isTimed()) { | 1454 | if (lens.isTimed() || lens.isGame()) { |
139 | 1453 | saveUppaalXMLButton.setVisible(advancedView); | 1455 | saveUppaalXMLButton.setVisible(advancedView); |
140 | 1454 | overApproximationOptionsPanel.setVisible(advancedView); | 1456 | overApproximationOptionsPanel.setVisible(advancedView); |
141 | 1455 | } | 1457 | } |
142 | @@ -1682,7 +1684,7 @@ | |||
143 | 1682 | gbc.fill = GridBagConstraints.VERTICAL; | 1684 | gbc.fill = GridBagConstraints.VERTICAL; |
144 | 1683 | queryPanel.add(quantificationPanel, gbc); | 1685 | queryPanel.add(quantificationPanel, gbc); |
145 | 1684 | 1686 | ||
147 | 1685 | if (lens.isTimed()) { | 1687 | if (lens.isTimed()|| lens.isGame()) { |
148 | 1686 | addTimedQuantificationListeners(); | 1688 | addTimedQuantificationListeners(); |
149 | 1687 | } else { | 1689 | } else { |
150 | 1688 | addUntimedQuantificationListeners(); | 1690 | addUntimedQuantificationListeners(); |
151 | @@ -1924,7 +1926,7 @@ | |||
152 | 1924 | }); | 1926 | }); |
153 | 1925 | 1927 | ||
154 | 1926 | negationButton.addActionListener(e -> { | 1928 | negationButton.addActionListener(e -> { |
156 | 1927 | if (lens.isTimed()) { | 1929 | if (lens.isTimed() || lens.isGame()) { |
157 | 1928 | TCTLNotNode property = new TCTLNotNode(getStateProperty(currentSelection.getObject())); | 1930 | TCTLNotNode property = new TCTLNotNode(getStateProperty(currentSelection.getObject())); |
158 | 1929 | addPropertyToQuery(property); | 1931 | addPropertyToQuery(property); |
159 | 1930 | } else { | 1932 | } else { |
160 | @@ -2045,7 +2047,7 @@ | |||
161 | 2045 | for (SharedPlace place : tapnNetwork.sharedPlaces()) { | 2047 | for (SharedPlace place : tapnNetwork.sharedPlaces()) { |
162 | 2046 | placeNames.add(place.name()); | 2048 | placeNames.add(place.name()); |
163 | 2047 | } | 2049 | } |
165 | 2048 | if (lens.isTimed()) { | 2050 | if (lens.isTimed() || lens.isGame()) { |
166 | 2049 | for (SharedTransition transition : tapnNetwork.sharedTransitions()) { | 2051 | for (SharedTransition transition : tapnNetwork.sharedTransitions()) { |
167 | 2050 | placeNames.add(transition.name()); | 2052 | placeNames.add(transition.name()); |
168 | 2051 | } | 2053 | } |
169 | @@ -2158,7 +2160,7 @@ | |||
170 | 2158 | String template = templateBox.getSelectedItem().toString(); | 2160 | String template = templateBox.getSelectedItem().toString(); |
171 | 2159 | if(template.equals(SHARED)) template = ""; | 2161 | if(template.equals(SHARED)) template = ""; |
172 | 2160 | 2162 | ||
174 | 2161 | if (lens.isTimed() && transitionIsSelected()) { | 2163 | if ((lens.isTimed() || lens.isGame()) && transitionIsSelected()) { |
175 | 2162 | addPropertyToQuery(new TCTLTransitionNode(template, (String) placesBox.getSelectedItem())); | 2164 | addPropertyToQuery(new TCTLTransitionNode(template, (String) placesBox.getSelectedItem())); |
176 | 2163 | } else { | 2165 | } else { |
177 | 2164 | TCTLAtomicPropositionNode property = new TCTLAtomicPropositionNode( | 2166 | TCTLAtomicPropositionNode property = new TCTLAtomicPropositionNode( |
178 | @@ -2293,7 +2295,7 @@ | |||
179 | 2293 | ArrayList<Tuple<String,String>> templatePlaceNames = new ArrayList<Tuple<String,String>>(); | 2295 | ArrayList<Tuple<String,String>> templatePlaceNames = new ArrayList<Tuple<String,String>>(); |
180 | 2294 | for(TimedArcPetriNet tapn : tapnNetwork.activeTemplates()) { | 2296 | for(TimedArcPetriNet tapn : tapnNetwork.activeTemplates()) { |
181 | 2295 | for(TimedPlace p : tapn.places()) { | 2297 | for(TimedPlace p : tapn.places()) { |
183 | 2296 | if (lens.isTimed() || !p.isShared()) { | 2298 | if (lens.isTimed() || !p.isShared() || lens.isGame()) { |
184 | 2297 | templatePlaceNames.add(new Tuple<String, String>(tapn.name(), p.name())); | 2299 | templatePlaceNames.add(new Tuple<String, String>(tapn.name(), p.name())); |
185 | 2298 | } | 2300 | } |
186 | 2299 | } | 2301 | } |
187 | @@ -2309,7 +2311,7 @@ | |||
188 | 2309 | 2311 | ||
189 | 2310 | boolean isResultFalse; | 2312 | boolean isResultFalse; |
190 | 2311 | 2313 | ||
192 | 2312 | if (lens.isTimed()) { | 2314 | if (lens.isTimed() || lens.isGame()) { |
193 | 2313 | isResultFalse = !c.getResult(); | 2315 | isResultFalse = !c.getResult(); |
194 | 2314 | } else { | 2316 | } else { |
195 | 2315 | isResultFalse = checkUntimedResult(newQuery) && !c.getResult(); | 2317 | isResultFalse = checkUntimedResult(newQuery) && !c.getResult(); |
196 | @@ -2535,7 +2537,7 @@ | |||
197 | 2535 | gridBagConstraints.anchor = GridBagConstraints.WEST; | 2537 | gridBagConstraints.anchor = GridBagConstraints.WEST; |
198 | 2536 | traceOptionsPanel.add(fastestTraceRadioButton, gridBagConstraints); | 2538 | traceOptionsPanel.add(fastestTraceRadioButton, gridBagConstraints); |
199 | 2537 | 2539 | ||
201 | 2538 | if (lens.isTimed()) { | 2540 | if (lens.isTimed() || lens.isGame()) { |
202 | 2539 | gridBagConstraints.gridy = 2; | 2541 | gridBagConstraints.gridy = 2; |
203 | 2540 | gridBagConstraints.weightx = 1; | 2542 | gridBagConstraints.weightx = 1; |
204 | 2541 | gridBagConstraints.anchor = GridBagConstraints.WEST; | 2543 | gridBagConstraints.anchor = GridBagConstraints.WEST; |
205 | @@ -2671,7 +2673,7 @@ | |||
206 | 2671 | usePTrie.setToolTipText(TOOL_TIP_PTRIE); | 2673 | usePTrie.setToolTipText(TOOL_TIP_PTRIE); |
207 | 2672 | useOverApproximation.setToolTipText(TOOL_TIP_OVERAPPROX); | 2674 | useOverApproximation.setToolTipText(TOOL_TIP_OVERAPPROX); |
208 | 2673 | 2675 | ||
210 | 2674 | if (lens.isTimed()) { | 2676 | if (lens.isTimed() || lens.isGame()) { |
211 | 2675 | initTimedReductionOptions(); | 2677 | initTimedReductionOptions(); |
212 | 2676 | } else { | 2678 | } else { |
213 | 2677 | initUntimedReductionOptions(); | 2679 | initUntimedReductionOptions(); |
214 | @@ -2753,7 +2755,7 @@ | |||
215 | 2753 | protected void setEnabledOptionsAccordingToCurrentReduction() { | 2755 | protected void setEnabledOptionsAccordingToCurrentReduction() { |
216 | 2754 | refreshQueryEditingButtons(); | 2756 | refreshQueryEditingButtons(); |
217 | 2755 | refreshTraceOptions(); | 2757 | refreshTraceOptions(); |
219 | 2756 | if (lens.isTimed()) { | 2758 | if (lens.isTimed() || lens.isGame()) { |
220 | 2757 | refreshSymmetryReduction(); | 2759 | refreshSymmetryReduction(); |
221 | 2758 | refreshStubbornReduction(); | 2760 | refreshStubbornReduction(); |
222 | 2759 | refreshDiscreteOptions(); | 2761 | refreshDiscreteOptions(); |
Please check comments for one possible minior issue, just double check that the logic is as intended