Merge lp:~verifydtapn-contributers/verifydtapn/timeDartPtrie into lp:verifydtapn

Proposed by Peter Gjøl Jensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 437
Merged at revision: 276
Proposed branch: lp:~verifydtapn-contributers/verifydtapn/timeDartPtrie
Merge into: lp:verifydtapn
Diff against target: 9641 lines (+5659/-2401)
62 files modified
src/Core/ArgsParser.cpp (+366/-317)
src/Core/ArgsParser.hpp (+1/-1)
src/Core/QueryParser/Generated/lexer.cpp (+72/-57)
src/Core/QueryParser/Generated/location.hh (+42/-29)
src/Core/QueryParser/Generated/parser.cpp (+200/-249)
src/Core/QueryParser/Generated/parser.hpp (+35/-53)
src/Core/QueryParser/Generated/position.hh (+40/-32)
src/Core/QueryParser/Generated/stack.hh (+26/-30)
src/Core/TAPN/TimedArcPetriNet.cpp (+9/-0)
src/Core/TAPN/TimedTransition.hpp (+6/-3)
src/Core/VerificationOptions.cpp (+22/-13)
src/Core/VerificationOptions.hpp (+14/-5)
src/DiscreteVerification/DataStructures/EncodingStructure.cpp (+14/-0)
src/DiscreteVerification/DataStructures/EncodingStructure.h (+241/-0)
src/DiscreteVerification/DataStructures/NonStrictMarking.cpp (+0/-240)
src/DiscreteVerification/DataStructures/NonStrictMarking.hpp (+36/-158)
src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp (+339/-0)
src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp (+196/-0)
src/DiscreteVerification/DataStructures/PData.cpp (+16/-0)
src/DiscreteVerification/DataStructures/PData.h (+427/-0)
src/DiscreteVerification/DataStructures/PWList.cpp (+77/-8)
src/DiscreteVerification/DataStructures/PWList.hpp (+74/-9)
src/DiscreteVerification/DataStructures/TimeDart.hpp (+128/-0)
src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp (+164/-0)
src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp (+118/-0)
src/DiscreteVerification/DataStructures/TimeDartPWList.cpp (+126/-0)
src/DiscreteVerification/DataStructures/TimeDartPWList.hpp (+112/-0)
src/DiscreteVerification/DataStructures/WaitingList.cpp (+0/-202)
src/DiscreteVerification/DataStructures/WaitingList.hpp (+341/-39)
src/DiscreteVerification/DiscreteVerification.cpp (+129/-350)
src/DiscreteVerification/DiscreteVerification.hpp (+7/-7)
src/DiscreteVerification/QueryVisitor.cpp (+0/-75)
src/DiscreteVerification/QueryVisitor.hpp (+91/-25)
src/DiscreteVerification/SearchStrategies/LivenessWeightQueryVisitor.hpp (+2/-2)
src/DiscreteVerification/SearchStrategies/NonStrictBFS.hpp (+4/-4)
src/DiscreteVerification/SearchStrategies/NonStrictDFS.hpp (+4/-3)
src/DiscreteVerification/SearchStrategies/NonStrictDFSHeuristic.hpp (+3/-2)
src/DiscreteVerification/SearchStrategies/NonStrictDFSRandom.hpp (+4/-3)
src/DiscreteVerification/SearchStrategies/NonStrictHeuristic.hpp (+3/-2)
src/DiscreteVerification/SearchStrategies/NonStrictRandom.hpp (+4/-3)
src/DiscreteVerification/SearchStrategies/SearchFactory.h (+74/-0)
src/DiscreteVerification/SearchStrategies/SearchStrategies.hpp (+13/-0)
src/DiscreteVerification/SearchStrategies/SearchStrategy.hpp (+4/-1)
src/DiscreteVerification/SearchStrategies/WeightQueryVisitor.hpp (+2/-2)
src/DiscreteVerification/SuccessorGenerator.cpp (+0/-263)
src/DiscreteVerification/SuccessorGenerator.hpp (+413/-136)
src/DiscreteVerification/TimeDartSuccessorGenerator.cpp (+236/-0)
src/DiscreteVerification/TimeDartSuccessorGenerator.hpp (+65/-0)
src/DiscreteVerification/Util/IntervalOps.cpp (+79/-0)
src/DiscreteVerification/Util/IntervalOps.hpp (+30/-0)
src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp (+44/-33)
src/DiscreteVerification/VerificationTypes/LivenessSearch.hpp (+22/-5)
src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp (+43/-13)
src/DiscreteVerification/VerificationTypes/ReachabilitySearch.hpp (+28/-6)
src/DiscreteVerification/VerificationTypes/TimeDartLiveness.cpp (+196/-0)
src/DiscreteVerification/VerificationTypes/TimeDartLiveness.hpp (+86/-0)
src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.cpp (+126/-0)
src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.hpp (+78/-0)
src/DiscreteVerification/VerificationTypes/TimeDartVerification.cpp (+246/-0)
src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp (+67/-0)
src/DiscreteVerification/VerificationTypes/Verification.hpp (+309/-16)
src/compile-linux-32-64.sh (+5/-5)
To merge this branch: bzr merge lp:~verifydtapn-contributers/verifydtapn/timeDartPtrie
Reviewer Review Type Date Requested Status
Jakob Taankvist Approve
Mathias Grund Sørensen Approve
Jiri Srba Approve
Review via email: mp+154525@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

Merge into trunk.

Revision history for this message
Jiri Srba (srba) wrote :

There are many conflicts. Please, resolve them.

review: Needs Fixing
428. By Peter Gjøl Jensen

fixed to short deadlock trace

429. By Peter Gjøl Jensen

should fix compile error

430. By Peter Gjøl Jensen

re-fixed short deadlock trace issue

Revision history for this message
Jiri Srba (srba) wrote :

the fix to deadlock trace seems to work;
the conflicts have to be resolved now before we can merge to trunk

431. By Peter Gjøl Jensen

merged with trunk

Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

> There are many conflicts. Please, resolve them.

The conflicts should be resolved in last commit.

Revision history for this message
Jiri Srba (srba) wrote :

I found a net with wrongly reported deadlock. A separate bug report is made.

review: Needs Fixing
432. By Peter Gjøl Jensen

fix trace-loop detection delay for timedarts

433. By Peter Gjøl Jensen

trace-error seems fixed for naive engine

434. By Peter Gjøl Jensen

Seems to fix the trace issue for 2.xml as well as the delay in trace loop detection for timedarts

Revision history for this message
Jiri Srba (srba) wrote :

Now it passed almost all my tests, except for one that is reported as a separate bug.

review: Needs Fixing
435. By Peter Gjøl Jensen

Delay forever reported when loop is detected-bug fix

Revision history for this message
Jiri Srba (srba) wrote :

The problem seems fixed. The only small issue is that when I try this fix on 10.xml that I attached
to the bug report, sometimes I get

*delay 1
goto *

instead of

delay forever

Could this be fixed to delay for ever (as this is the same thing)?

Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

I think so, yes - there is a bit of ambiguity between delay forever and loop-detection.
As you noted, the previous fix introduced this bug, as the fix was to remove a check.

I will attempt to find a nicer solution.

436. By Peter Gjøl Jensen

seems to have fixed the loop/delay for ever issue

437. By Peter Gjøl Jensen

fixed reintroduced bug

Revision history for this message
Jiri Srba (srba) wrote :

Now it passed all my tests. I suggest to (finally) merge it to trunk!
Any other issues should be then corrected in a separate branch.

Mathias and Jakob, please, take a look at the code to see if you find
any issues by inspecting the code and then approve.

review: Approve
Revision history for this message
Mathias Grund Sørensen (mathias.grund) wrote :

I think it looks pretty okay. I have a two (non-critical) comments (line numbers refer to changelog):

Line 2320-2328: Are transport arcs accounted for in GetPostset()? If not, it appears that it will be untimed even if it has transport arcs with timed postset (this might be an issue later I guess?).

Line 3489-3502: This loop should really be an else statement to the condition in line 3480-3486. Currently, we iterate over all tokens to test if any are older than c_max even though we just removed all tokens older than c_max --> twice the iterations for dead places (I know this is small, but because it is in cut it will be run a lot).

review: Approve
Revision history for this message
Jakob Taankvist (jakob-taankvist) wrote :

1) The file src/DiscreteVerification/DataStructures/EncodingStructure.cpp is practically empty?

2) The lines

2569 + void Release() const {
2570 + delete[] shadow;
2571 + }

seems a little dodgy? Shouldn't this be in the destructor?

3) The file src/DiscreteVerification/DataStructures/NonStrictMarking.cpp had it's contents deleted - but the file wasn't?

4) The file src/DiscreteVerification/DataStructures/PData.cpp is practically empty?

5) The comment "//possible mem-leek?" in line 3807 seems like it should be investigated?

I don't think the above have any functional implications, but it should be fixed at some point.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Core/ArgsParser.cpp'
2--- src/Core/ArgsParser.cpp 2012-07-12 15:47:35 +0000
3+++ src/Core/ArgsParser.cpp 2013-03-31 13:25:26 +0000
4@@ -8,321 +8,370 @@
5 #include "boost/tokenizer.hpp"
6
7 namespace VerifyTAPN {
8- static const std::string KBOUND_OPTION = "k-bound";
9- static const std::string SEARCH_OPTION = "search-type";
10- static const std::string TRACE_OPTION = "trace";
11- static const std::string MAX_CONSTANT_OPTION = "global-max-constants";
12- static const std::string XML_TRACE_OPTION = "xml-trace";
13- static const std::string LEGACY = "legacy";
14- static const std::string KEEP_DEAD = "keep-dead-tokens";
15-
16- std::ostream& operator<<(std::ostream& out, const Switch& flag)
17- {
18- flag.Print(out);
19- return out;
20- }
21-
22- std::ostream& operator <<(std::ostream& out, const Version& version)
23- {
24- out << version.maj << "." << version.min << "." << version.build;
25- return out;
26- }
27-
28- void PrintIndentedDescription(std::ostream& out, const std::string& description)
29- {
30- typedef boost::tokenizer<boost::char_separator<char> > tokens;
31- tokens lines(description.begin(), description.end(), boost::char_separator<char>("\n", "", boost::keep_empty_tokens));
32- bool first = true;
33- for(tokens::const_iterator it = lines.begin(); it != lines.end(); it++)
34- {
35- if(!first){
36- out << std::setw(WIDTH) << " ";
37- }
38- out << *it << std::endl;
39- first = false;
40- }
41- }
42-
43- void Switch::Print(std::ostream& out) const
44- {
45- std::stringstream s;
46- s << "-" << ShortName();
47- s << " [ --" << LongName() << " ]";
48- out << std::setw(WIDTH) << std::left << s.str();
49- PrintIndentedDescription(out, Description());
50- };
51-
52- void SwitchWithArg::Print(std::ostream& out) const
53- {
54- std::stringstream s;
55- s << "-" << ShortName();
56- s << " [ --" << LongName() << " ] ";
57- s << " arg (=" << default_value << ")";
58- out << std::setw(WIDTH) << std::left << s.str();
59- PrintIndentedDescription(out, Description());
60- };
61-
62- void SwitchWithStringArg::Print(std::ostream& out) const
63- {
64- std::stringstream s;
65- s << "-" << ShortName();
66- s << " [ --" << LongName() << " ] ";
67- s << " a1,a2,.. (=" << default_value << ")";
68- out << std::setw(WIDTH) << std::left << s.str();
69- PrintIndentedDescription(out, Description());
70- };
71-
72- bool Switch::Handles(const std::string& flag) const
73- {
74- std::stringstream stream;
75- stream << "-" << name << " ";
76- if(flag.find(stream.str()) != std::string::npos) return true;
77- if(flag.find(long_name) != std::string::npos) return true;
78- return false;
79- };
80-
81- option Switch::Parse(const std::string& flag)
82- {
83- assert(Handles(flag));
84- handled_option = true;
85- return option(LongName(), "1");
86- };
87-
88-
89- option SwitchWithArg::Parse(const std::string& flag)
90- {
91- assert(Handles(flag));
92- handled_option = true;
93- std::string copy(flag);
94- std::stringstream stream;
95- stream << "-" << ShortName() << " ";
96- if(flag.find(stream.str()) != std::string::npos)
97- {
98- boost::erase_all(copy, stream.str());
99- }
100- else
101- {
102- std::stringstream long_name_stream;
103- long_name_stream << "--" << LongName() << " ";
104- boost::erase_all(copy, long_name_stream.str());
105- }
106- boost::trim(copy);
107- return option(LongName(), copy);
108- };
109-
110- option SwitchWithStringArg::Parse(const std::string& flag)
111- {
112- assert(Handles(flag));
113- handled_option = true;
114- std::string copy(flag);
115- std::stringstream stream;
116- stream << "-" << ShortName() << " ";
117- if(flag.find(stream.str()) != std::string::npos)
118- {
119- boost::erase_all(copy, stream.str());
120- }
121- else
122- {
123- std::stringstream long_name_stream;
124- long_name_stream << "--" << LongName() << " ";
125- boost::erase_all(copy, long_name_stream.str());
126- }
127- boost::trim(copy);
128- return option(LongName(), copy);
129- };
130-
131- void ArgsParser::Initialize()
132- {
133- // NOTE: The Help() function only splits and indents descriptions based on newlines.
134- // Each line in the description is assumed to fit within the remaining width
135- // of the console, so keep descriptions short, or implement manual word-wrapping :).
136- parsers.push_back(boost::make_shared<SwitchWithArg>("k", KBOUND_OPTION, "Max tokens to use during exploration.",0));
137- parsers.push_back(boost::make_shared<SwitchWithArg>("o", SEARCH_OPTION, "Specify the desired search strategy.\n - 0: Breadth-First Search\n - 1: Depth-First Search\n - 2: Random Search\n - 3: Heuristic Search",3));
138- parsers.push_back(boost::make_shared<SwitchWithArg>("t", TRACE_OPTION, "Specify the desired trace option.\n - 0: none\n - 1: some",0));
139- parsers.push_back(boost::make_shared<Switch>("d",KEEP_DEAD, "Do not discard dead tokens\n(used for boundedness checking)"));
140- parsers.push_back(boost::make_shared<Switch>("g",MAX_CONSTANT_OPTION, "Use global maximum constant for \nextrapolation (as opposed to local \nconstants)."));
141- parsers.push_back(boost::make_shared<Switch>("s",LEGACY, "Legacy option (no effect)."));
142-
143- parsers.push_back(boost::make_shared<Switch>("x",XML_TRACE_OPTION, "Output trace in xml format for TAPAAL."));
144- };
145-
146- void ArgsParser::Help() const
147- {
148- std::cout << "Usage: verifydtapn -k <number> [optional arguments] model-file query-file" << std::endl;
149- std::cout << "Allowed Options:" << std::endl;
150- std::cout << std::setw(WIDTH) << std::left << "-h [ --help ]" << "Displays this help message." << std::endl;
151- std::cout << std::setw(WIDTH) << std::left << "-v [ --version ]" << "Displays version information." << std::endl;
152- for(parser_vec::const_iterator arg = parsers.begin(); arg != parsers.end(); arg++)
153- {
154- std::cout << **arg;
155- }
156- };
157-
158- void ArgsParser::Version() const
159- {
160- std::cout << "VerifyDTAPN " << version << std::endl;
161- std::cout << "Licensed under BSD." << std::endl;
162- }
163-
164- VerificationOptions ArgsParser::Parse(int argc, char* argv[]) const
165- {
166- if(argc == 1 || std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help")
167- {
168- Help();
169- exit(0);
170- }
171-
172- if(std::string(argv[1]) == "-v" || std::string(argv[1]) == "--version")
173- {
174- Version();
175- exit(0);
176- }
177-
178- if(argc < 3)
179- {
180- std::cout << "too few parameters." << std::endl;
181- std::cout << "Use '-h' for help on correct usage." << std::endl;
182- exit(1);
183- }
184-
185- std::string model_file(argv[argc-2]);
186- std::string query_file(argv[argc-1]);
187-
188- if(boost::iends_with(query_file,".xml"))
189- {
190- std::cout << "Missing query file." << std::endl;
191- exit(1);
192- }
193-
194- if(!boost::iends_with(model_file,".xml"))
195- {
196- std::cout << "Invalid model file specified." << std::endl;
197- exit(1);
198- }
199-
200- if(!boost::iends_with(query_file, ".q"))
201- {
202- std::cout << "Invalid query file specified." << std::endl;
203- exit(1);
204- }
205-
206- std::vector<std::string> flags;
207- unsigned int i = 1;
208- unsigned int size = static_cast<unsigned int>(argc);
209- while(i < size-2)
210- {
211- std::string arg(argv[i]);
212- if(boost::istarts_with(arg, "-"))
213- {
214- std::string arg2(argv[i+1]);
215- if(!boost::istarts_with(arg2,"-") && i+1 < size-2)
216- {
217- flags.push_back(arg + " " + arg2);
218- i++;
219- }else{
220- flags.push_back(arg + " ");
221- }
222- }
223- i++;
224- }
225-
226- option_map options;
227- for(std::vector<std::string>::const_iterator flag = flags.begin(); flag != flags.end(); flag++)
228- {
229- bool handled = false;
230- for(parser_vec::const_iterator it = parsers.begin(); it != parsers.end(); it++)
231- {
232- if((*it)->Handles(*flag))
233- {
234- options.insert((*it)->Parse(*flag));
235- handled = true;
236- }
237- }
238- if(!handled)
239- {
240- std::cout << "Unknown option flag '" << *flag << "'" << std::endl;
241- std::cout << "Use '-h' to see a list of valid options." << std::endl;
242- exit(1);
243- }
244- }
245-
246- // Put in default values for non-specified options
247- for(parser_vec::const_iterator it = parsers.begin(); it != parsers.end(); it++)
248- {
249- if(!(*it)->HandledOption())
250- {
251- options.insert((*it)->DefaultOption());
252- }
253- }
254-
255- return CreateVerificationOptions(options, model_file, query_file);
256- }
257-
258- SearchType intToSearchTypeEnum(int i) {
259- switch(i){
260- case 0: return BREADTHFIRST;
261- case 1: return DEPTHFIRST;
262- case 2: return RANDOM;
263- case 3: return COVERMOST;
264- default:
265- std::cout << "Unknown search strategy specified." << std::endl;
266- exit(1);
267- }
268- }
269-
270- Trace intToEnum(int i){
271- switch(i)
272- {
273- case 0: return NONE;
274- case 1: return SOME;
275- default:
276- std::cout << "Unknown trace option specified." << std::endl;
277- exit(1);
278- }
279- }
280-
281- unsigned int ArgsParser::TryParseInt(const option& option) const
282- {
283- unsigned int result = 0;
284- try
285- {
286- result = boost::lexical_cast<unsigned int>(option.second);
287- }
288- catch(boost::bad_lexical_cast & e)
289- {
290- std::cout << "Invalid value '" << option.second << "' for option '--" << option.first << "'" << std::endl;
291- exit(1);
292- }
293- return result;
294- }
295-
296- std::vector<std::string> ArgsParser::ParseIncPlaces(const std::string& string) const
297- {
298- std::vector<std::string> vec;
299- boost::split( vec, string, boost::is_any_of(",") );
300- return vec;
301- }
302-
303- VerificationOptions ArgsParser::CreateVerificationOptions(const option_map& map, const std::string& modelFile, const std::string& queryFile) const
304- {
305- assert(map.find(KBOUND_OPTION) != map.end());
306- unsigned int kbound = TryParseInt(*map.find(KBOUND_OPTION));
307-
308- assert(map.find(SEARCH_OPTION) != map.end());
309- SearchType search = intToSearchTypeEnum(TryParseInt(*map.find(SEARCH_OPTION)));
310-
311- assert(map.find(TRACE_OPTION) != map.end());
312- Trace trace = intToEnum(TryParseInt(*map.find(TRACE_OPTION)));
313-
314- assert(map.find(MAX_CONSTANT_OPTION) != map.end());
315- bool max_constant = boost::lexical_cast<bool>(map.find(MAX_CONSTANT_OPTION)->second);
316-
317- assert(map.find(KEEP_DEAD) != map.end());
318- bool keep_dead = boost::lexical_cast<bool>(map.find(KEEP_DEAD)->second);
319-
320- assert(map.find(XML_TRACE_OPTION) != map.end());
321- bool xml_trace = boost::lexical_cast<bool>(map.find(XML_TRACE_OPTION)->second);
322-
323- return VerificationOptions(modelFile, queryFile, search, kbound, trace, xml_trace, max_constant, keep_dead);
324- }
325+static const std::string KBOUND_OPTION = "k-bound";
326+static const std::string SEARCH_OPTION = "search-type";
327+static const std::string VERIFICATION_OPTION = "verification-method";
328+static const std::string MEMORY_OPTIMIZATION_OPTION = "memory-optimization";
329+static const std::string TRACE_OPTION = "trace";
330+static const std::string MAX_CONSTANT_OPTION = "global-max-constants";
331+static const std::string XML_TRACE_OPTION = "xml-trace";
332+static const std::string LEGACY = "legacy";
333+static const std::string KEEP_DEAD = "keep-dead-tokens";
334+
335+std::ostream& operator<<(std::ostream& out, const Switch& flag) {
336+ flag.Print(out);
337+ return out;
338+}
339+
340+std::ostream& operator <<(std::ostream& out, const Version& version) {
341+ out << version.maj << "." << version.min << "." << version.build;
342+ return out;
343+}
344+
345+void PrintIndentedDescription(std::ostream& out,
346+ const std::string& description) {
347+ typedef boost::tokenizer<boost::char_separator<char> > tokens;
348+ tokens lines(description.begin(), description.end(),
349+ boost::char_separator<char>("\n", "", boost::keep_empty_tokens));
350+ bool first = true;
351+ for (tokens::const_iterator it = lines.begin(); it != lines.end(); it++) {
352+ if (!first) {
353+ out << std::setw(WIDTH) << " ";
354+ }
355+ out << *it << std::endl;
356+ first = false;
357+ }
358+}
359+
360+void Switch::Print(std::ostream& out) const {
361+ std::stringstream s;
362+ s << "-" << ShortName();
363+ s << " [ --" << LongName() << " ]";
364+ out << std::setw(WIDTH) << std::left << s.str();
365+ PrintIndentedDescription(out, Description());
366+}
367+;
368+
369+void SwitchWithArg::Print(std::ostream& out) const {
370+ std::stringstream s;
371+ s << "-" << ShortName();
372+ s << " [ --" << LongName() << " ] ";
373+ s << " arg (=" << default_value << ")";
374+ out << std::setw(WIDTH) << std::left << s.str();
375+ PrintIndentedDescription(out, Description());
376+}
377+;
378+
379+void SwitchWithStringArg::Print(std::ostream& out) const {
380+ std::stringstream s;
381+ s << "-" << ShortName();
382+ s << " [ --" << LongName() << " ] ";
383+ s << " a1,a2,.. (=" << default_value << ")";
384+ out << std::setw(WIDTH) << std::left << s.str();
385+ PrintIndentedDescription(out, Description());
386+}
387+;
388+
389+bool Switch::Handles(const std::string& flag) const {
390+ std::stringstream stream;
391+ stream << "-" << name << " ";
392+ if (flag.find(stream.str()) != std::string::npos)
393+ return true;
394+ if (flag.find(long_name) != std::string::npos)
395+ return true;
396+ return false;
397+}
398+;
399+
400+option Switch::Parse(const std::string& flag) {
401+ assert(Handles(flag));
402+ handled_option = true;
403+ return option(LongName(), "1");
404+}
405+;
406+
407+option SwitchWithArg::Parse(const std::string& flag) {
408+ assert(Handles(flag));
409+ handled_option = true;
410+ std::string copy(flag);
411+ std::stringstream stream;
412+ stream << "-" << ShortName() << " ";
413+ if (flag.find(stream.str()) != std::string::npos) {
414+ boost::erase_all(copy, stream.str());
415+ } else {
416+ std::stringstream long_name_stream;
417+ long_name_stream << "--" << LongName() << " ";
418+ boost::erase_all(copy, long_name_stream.str());
419+ }
420+ boost::trim(copy);
421+ return option(LongName(), copy);
422+}
423+;
424+
425+option SwitchWithStringArg::Parse(const std::string& flag) {
426+ assert(Handles(flag));
427+ handled_option = true;
428+ std::string copy(flag);
429+ std::stringstream stream;
430+ stream << "-" << ShortName() << " ";
431+ if (flag.find(stream.str()) != std::string::npos) {
432+ boost::erase_all(copy, stream.str());
433+ } else {
434+ std::stringstream long_name_stream;
435+ long_name_stream << "--" << LongName() << " ";
436+ boost::erase_all(copy, long_name_stream.str());
437+ }
438+ boost::trim(copy);
439+ return option(LongName(), copy);
440+}
441+;
442+
443+void ArgsParser::Initialize() {
444+ // NOTE: The Help() function only splits and indents descriptions based on newlines.
445+ // Each line in the description is assumed to fit within the remaining width
446+ // of the console, so keep descriptions short, or implement manual word-wrapping :).
447+ parsers.push_back(
448+ boost::make_shared<SwitchWithArg > ("k", KBOUND_OPTION,
449+ "Max tokens to use during exploration.", 0));
450+ parsers.push_back(
451+ boost::make_shared<SwitchWithArg > ("o", SEARCH_OPTION,
452+ "Specify the desired search strategy.\n - 0: Breadth-First Search\n - 1: Depth-First Search\n - 2: Random Search\n - 3: Heuristic Search",
453+ 3));
454+ parsers.push_back(
455+ boost::make_shared<SwitchWithArg > ("m", VERIFICATION_OPTION,
456+ "Specify the desired verification method.\n - 0: Default (discrete)\n - 1: Time Darts",
457+ 0)); // TODO change to 0!
458+ parsers.push_back(
459+ boost::make_shared<SwitchWithArg > ("p", MEMORY_OPTIMIZATION_OPTION,
460+ "Specify the desired memory optimization.\n - 0: None \n - 1: PTrie",
461+ 1)); // TODO change to 0!
462+ parsers.push_back(
463+ boost::make_shared<SwitchWithArg > ("t", TRACE_OPTION,
464+ "Specify the desired trace option.\n - 0: none\n - 1: some",
465+ 0));
466+ parsers.push_back(
467+ boost::make_shared<Switch > ("d", KEEP_DEAD,
468+ "Do not discard dead tokens\n(used for boundedness checking)"));
469+ parsers.push_back(
470+ boost::make_shared<Switch > ("g", MAX_CONSTANT_OPTION,
471+ "Use global maximum constant for \nextrapolation (as opposed to local \nconstants)."));
472+ parsers.push_back(
473+ boost::make_shared<Switch > ("s", LEGACY,
474+ "Legacy option (no effect)."));
475+
476+ parsers.push_back(
477+ boost::make_shared<Switch > ("x", XML_TRACE_OPTION,
478+ "Output trace in xml format for TAPAAL."));
479+};
480+
481+void ArgsParser::Help() const {
482+ std::cout
483+ << "Usage: verifydtapn -k <number> [optional arguments] model-file query-file"
484+ << std::endl;
485+ std::cout << "Allowed Options:" << std::endl;
486+ std::cout << std::setw(WIDTH) << std::left << "-h [ --help ]"
487+ << "Displays this help message." << std::endl;
488+ std::cout << std::setw(WIDTH) << std::left << "-v [ --version ]"
489+ << "Displays version information." << std::endl;
490+ for (parser_vec::const_iterator arg = parsers.begin(); arg != parsers.end();
491+ arg++) {
492+ std::cout << **arg;
493+ }
494+}
495+;
496+
497+void ArgsParser::Version() const {
498+ std::cout << "VerifyDTAPN " << version << std::endl;
499+ std::cout << "Licensed under BSD." << std::endl;
500+}
501+
502+VerificationOptions ArgsParser::Parse(int argc, char* argv[]) const {
503+ if (argc == 1 || std::string(argv[1]) == "-h"
504+ || std::string(argv[1]) == "--help") {
505+ Help();
506+ exit(0);
507+ }
508+
509+ if (std::string(argv[1]) == "-v" || std::string(argv[1]) == "--version") {
510+ Version();
511+ exit(0);
512+ }
513+
514+ if (argc < 3) {
515+ std::cout << "too few parameters." << std::endl;
516+ std::cout << "Use '-h' for help on correct usage." << std::endl;
517+ exit(1);
518+ }
519+
520+ std::string model_file(argv[argc - 2]);
521+ std::string query_file(argv[argc - 1]);
522+
523+ if (boost::iends_with(query_file, ".xml")) {
524+ std::cout << "Missing query file." << std::endl;
525+ exit(1);
526+ }
527+
528+ if (!boost::iends_with(model_file, ".xml")) {
529+ std::cout << "Invalid model file specified." << std::endl;
530+ exit(1);
531+ }
532+
533+ if (!boost::iends_with(query_file, ".q")) {
534+ std::cout << "Invalid query file specified." << std::endl;
535+ exit(1);
536+ }
537+
538+ std::vector<std::string> flags;
539+ unsigned int i = 1;
540+ unsigned int size = static_cast<unsigned int>(argc);
541+ while (i < size - 2) {
542+ std::string arg(argv[i]);
543+ if (boost::istarts_with(arg, "-")) {
544+ std::string arg2(argv[i + 1]);
545+ if (!boost::istarts_with(arg2, "-") && i + 1 < size - 2) {
546+ flags.push_back(arg + " " + arg2);
547+ i++;
548+ } else {
549+ flags.push_back(arg + " ");
550+ }
551+ }
552+ i++;
553+ }
554+
555+ option_map options;
556+ for (std::vector<std::string>::const_iterator flag = flags.begin();
557+ flag != flags.end(); flag++) {
558+ bool handled = false;
559+ for (parser_vec::const_iterator it = parsers.begin();
560+ it != parsers.end(); it++) {
561+ if ((*it)->Handles(*flag)) {
562+ options.insert((*it)->Parse(*flag));
563+ handled = true;
564+ }
565+ }
566+ if (!handled) {
567+ std::cout << "Unknown option flag '" << *flag << "'" << std::endl;
568+ std::cout << "Use '-h' to see a list of valid options."
569+ << std::endl;
570+ exit(1);
571+ }
572+ }
573+
574+ // Put in default values for non-specified options
575+ for (parser_vec::const_iterator it = parsers.begin(); it != parsers.end();
576+ it++) {
577+ if (!(*it)->HandledOption()) {
578+ options.insert((*it)->DefaultOption());
579+ }
580+ }
581+
582+ return CreateVerificationOptions(options, model_file, query_file);
583+}
584+
585+SearchType intToSearchTypeEnum(int i) {
586+ switch (i) {
587+ case 0:
588+ return BREADTHFIRST;
589+ case 1:
590+ return DEPTHFIRST;
591+ case 2:
592+ return RANDOM;
593+ case 3:
594+ return COVERMOST;
595+ default:
596+ std::cout << "Unknown search strategy specified." << std::endl;
597+ exit(1);
598+ }
599+}
600+
601+VerificationType intToVerificationTypeEnum(int i) {
602+ switch (i) {
603+ case 0:
604+ return DISCRETE;
605+ case 1:
606+ return TIMEDART;
607+ default:
608+ std::cout << "Unknown verification method specified." << std::endl;
609+ exit(1);
610+ }
611+}
612+
613+MemoryOptimization intToMemoryOptimizationEnum(int i) {
614+ switch (i) {
615+ case 0:
616+ return NO_MEMORY_OPTIMIZATION;
617+ case 1:
618+ return PTRIE;
619+ default:
620+ std::cout << "Unknown memory optimization specified." << std::endl;
621+ exit(1);
622+ }
623+}
624+
625+
626+Trace intToEnum(int i) {
627+ switch (i) {
628+ case 0:
629+ return NONE;
630+ case 1:
631+ return SOME;
632+ default:
633+ std::cout << "Unknown trace option specified." << std::endl;
634+ exit(1);
635+ }
636+}
637+
638+unsigned int ArgsParser::TryParseInt(const option& option) const {
639+ unsigned int result = 0;
640+ try {
641+ result = boost::lexical_cast<unsigned int>(option.second);
642+ } catch (boost::bad_lexical_cast & e) {
643+ std::cout << "Invalid value '" << option.second << "' for option '--"
644+ << option.first << "'" << std::endl;
645+ exit(1);
646+ }
647+ return result;
648+}
649+
650+std::vector<std::string> ArgsParser::ParseIncPlaces(
651+ const std::string& string) const {
652+ std::vector<std::string> vec;
653+ boost::split(vec, string, boost::is_any_of(","));
654+ return vec;
655+}
656+
657+VerificationOptions ArgsParser::CreateVerificationOptions(const option_map& map,
658+ const std::string& modelFile, const std::string& queryFile) const {
659+ assert(map.find(KBOUND_OPTION) != map.end());
660+ unsigned int kbound = TryParseInt(*map.find(KBOUND_OPTION));
661+
662+ assert(map.find(SEARCH_OPTION) != map.end());
663+ SearchType search = intToSearchTypeEnum(
664+ TryParseInt(*map.find(SEARCH_OPTION)));
665+
666+ assert(map.find(VERIFICATION_OPTION) != map.end());
667+ VerificationType verification = intToVerificationTypeEnum(
668+ TryParseInt(*map.find(VERIFICATION_OPTION)));
669+
670+ assert(map.find(MEMORY_OPTIMIZATION_OPTION) != map.end());
671+ MemoryOptimization memoptimization = intToMemoryOptimizationEnum(
672+ TryParseInt(*map.find(MEMORY_OPTIMIZATION_OPTION)));
673+
674+ assert(map.find(TRACE_OPTION) != map.end());
675+ Trace trace = intToEnum(TryParseInt(*map.find(TRACE_OPTION)));
676+
677+ assert(map.find(MAX_CONSTANT_OPTION) != map.end());
678+ bool max_constant = boost::lexical_cast<bool>(
679+ map.find(MAX_CONSTANT_OPTION)->second);
680+
681+ assert(map.find(KEEP_DEAD) != map.end());
682+ bool keep_dead = boost::lexical_cast<bool>(map.find(KEEP_DEAD)->second);
683+
684+ assert(map.find(XML_TRACE_OPTION) != map.end());
685+ bool xml_trace = boost::lexical_cast<bool>(
686+ map.find(XML_TRACE_OPTION)->second);
687+
688+ return VerificationOptions(modelFile, queryFile, search, verification, memoptimization, kbound, trace,
689+ xml_trace, max_constant, keep_dead);
690+}
691 }
692
693=== modified file 'src/Core/ArgsParser.hpp' (properties changed: +x to -x)
694--- src/Core/ArgsParser.hpp 2012-11-29 00:53:29 +0000
695+++ src/Core/ArgsParser.hpp 2013-03-31 13:25:26 +0000
696@@ -80,7 +80,7 @@
697 class ArgsParser {
698 typedef std::vector< boost::shared_ptr<Switch> > parser_vec;
699 public:
700- ArgsParser() : parsers(), version(1,0,1) { Initialize(); };
701+ ArgsParser() : parsers(), version(2,0,0) { Initialize(); };
702 virtual ~ArgsParser() {};
703
704 VerificationOptions Parse(int argc, char* argv[]) const;
705
706=== modified file 'src/Core/QueryParser/Generated/lexer.cpp'
707--- src/Core/QueryParser/Generated/lexer.cpp 2012-04-19 12:40:05 +0000
708+++ src/Core/QueryParser/Generated/lexer.cpp 2013-03-31 13:25:26 +0000
709@@ -1,6 +1,6 @@
710-#line 2 "Generated/lexer.cpp"
711+#line 2 "Core/QueryParser/Generated/lexer.cpp"
712
713-#line 4 "Generated/lexer.cpp"
714+#line 4 "Core/QueryParser/Generated/lexer.cpp"
715
716 #define YY_INT_ALIGNED short int
717
718@@ -54,7 +54,6 @@
719 typedef unsigned char flex_uint8_t;
720 typedef unsigned short int flex_uint16_t;
721 typedef unsigned int flex_uint32_t;
722-#endif /* ! C99 */
723
724 /* Limits of integral types. */
725 #ifndef INT8_MIN
726@@ -85,6 +84,8 @@
727 #define UINT32_MAX (4294967295U)
728 #endif
729
730+#endif /* ! C99 */
731+
732 #endif /* ! FLEXINT_H */
733
734 #ifdef __cplusplus
735@@ -141,7 +142,15 @@
736
737 /* Size of default input buffer. */
738 #ifndef YY_BUF_SIZE
739+#ifdef __ia64__
740+/* On IA-64, the buffer size is 16k, not 8k.
741+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
742+ * Ditto for the __ia64__ case accordingly.
743+ */
744+#define YY_BUF_SIZE 32768
745+#else
746 #define YY_BUF_SIZE 16384
747+#endif /* __ia64__ */
748 #endif
749
750 /* The state buf must be large enough to hold one state per character in the main buffer.
751@@ -153,12 +162,7 @@
752 typedef struct yy_buffer_state *YY_BUFFER_STATE;
753 #endif
754
755-#ifndef YY_TYPEDEF_YY_SIZE_T
756-#define YY_TYPEDEF_YY_SIZE_T
757-typedef size_t yy_size_t;
758-#endif
759-
760-extern yy_size_t yyleng;
761+extern int yyleng;
762
763 extern FILE *yyin, *yyout;
764
765@@ -184,6 +188,11 @@
766
767 #define unput(c) yyunput( c, (yytext_ptr) )
768
769+#ifndef YY_TYPEDEF_YY_SIZE_T
770+#define YY_TYPEDEF_YY_SIZE_T
771+typedef size_t yy_size_t;
772+#endif
773+
774 #ifndef YY_STRUCT_YY_BUFFER_STATE
775 #define YY_STRUCT_YY_BUFFER_STATE
776 struct yy_buffer_state
777@@ -201,7 +210,7 @@
778 /* Number of characters read into yy_ch_buf, not including EOB
779 * characters.
780 */
781- yy_size_t yy_n_chars;
782+ int yy_n_chars;
783
784 /* Whether we "own" the buffer - i.e., we know we created it,
785 * and can realloc() it to grow it, and should free() it to
786@@ -271,8 +280,8 @@
787
788 /* yy_hold_char holds the character lost when yytext is formed. */
789 static char yy_hold_char;
790-static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
791-yy_size_t yyleng;
792+static int yy_n_chars; /* number of characters read into yy_ch_buf */
793+int yyleng;
794
795 /* Points to current character in buffer. */
796 static char *yy_c_buf_p = (char *) 0;
797@@ -300,7 +309,7 @@
798
799 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
800 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
801-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
802+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
803
804 void *yyalloc (yy_size_t );
805 void *yyrealloc (void *,yy_size_t );
806@@ -478,8 +487,8 @@
807 #define YY_MORE_ADJ 0
808 #define YY_RESTORE_YY_MORE_OFFSET
809 char *yytext;
810-#line 1 "flex.ll"
811-#line 2 "flex.ll"
812+#line 1 "Core/QueryParser/flex.ll"
813+#line 2 "Core/QueryParser/flex.ll"
814 # include <string>
815 # include "../TAPNQueryParser.hpp"
816 # include "parser.hpp"
817@@ -495,9 +504,9 @@
818 Unfortunately yyterminate by default returns 0, which is
819 not of token_type. */
820 #define yyterminate() return token::END
821-#line 26 "flex.ll"
822+#line 26 "Core/QueryParser/flex.ll"
823 # define YY_USER_ACTION yylloc->columns (yyleng);
824-#line 501 "Generated/lexer.cpp"
825+#line 510 "Core/QueryParser/Generated/lexer.cpp"
826
827 #define INITIAL 0
828
829@@ -536,7 +545,7 @@
830
831 void yyset_out (FILE * out_str );
832
833-yy_size_t yyget_leng (void );
834+int yyget_leng (void );
835
836 char *yyget_text (void );
837
838@@ -576,7 +585,12 @@
839
840 /* Amount of stuff to slurp up with each read. */
841 #ifndef YY_READ_BUF_SIZE
842+#ifdef __ia64__
843+/* On IA-64, the buffer size is 16k, not 8k */
844+#define YY_READ_BUF_SIZE 16384
845+#else
846 #define YY_READ_BUF_SIZE 8192
847+#endif /* __ia64__ */
848 #endif
849
850 /* Copy whatever the last rule matched to the standard output. */
851@@ -584,7 +598,7 @@
852 /* This used to be an fputs(), but since the string might contain NUL's,
853 * we now use fwrite().
854 */
855-#define ECHO fwrite( yytext, yyleng, 1, yyout )
856+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
857 #endif
858
859 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
860@@ -595,7 +609,7 @@
861 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
862 { \
863 int c = '*'; \
864- yy_size_t n; \
865+ size_t n; \
866 for ( n = 0; n < max_size && \
867 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
868 buf[n] = (char) c; \
869@@ -680,12 +694,12 @@
870 register char *yy_cp, *yy_bp;
871 register int yy_act;
872
873-#line 28 "flex.ll"
874+#line 28 "Core/QueryParser/flex.ll"
875
876
877 yylloc->step ();
878
879-#line 689 "Generated/lexer.cpp"
880+#line 703 "Core/QueryParser/Generated/lexer.cpp"
881
882 if ( !(yy_init) )
883 {
884@@ -767,13 +781,13 @@
885
886 case 1:
887 YY_RULE_SETUP
888-#line 32 "flex.ll"
889+#line 32 "Core/QueryParser/flex.ll"
890 { yylloc->step (); }
891 YY_BREAK
892 case 2:
893 /* rule 2 can match eol */
894 YY_RULE_SETUP
895-#line 33 "flex.ll"
896+#line 33 "Core/QueryParser/flex.ll"
897 { yylloc->lines (yyleng); yylloc->step (); }
898 YY_BREAK
899
900@@ -781,105 +795,105 @@
901
902 case 3:
903 YY_RULE_SETUP
904-#line 39 "flex.ll"
905+#line 39 "Core/QueryParser/flex.ll"
906 { yylval->number = atoi(yytext); return token::NUMBER; }
907 YY_BREAK
908 case 4:
909 YY_RULE_SETUP
910-#line 40 "flex.ll"
911+#line 40 "Core/QueryParser/flex.ll"
912 { return token::EF; }
913 YY_BREAK
914 case 5:
915 YY_RULE_SETUP
916-#line 41 "flex.ll"
917+#line 41 "Core/QueryParser/flex.ll"
918 { return token::AG; }
919 YY_BREAK
920 case 6:
921 YY_RULE_SETUP
922-#line 42 "flex.ll"
923+#line 42 "Core/QueryParser/flex.ll"
924 { return token::AF; }
925 YY_BREAK
926 case 7:
927 YY_RULE_SETUP
928-#line 43 "flex.ll"
929+#line 43 "Core/QueryParser/flex.ll"
930 { return token::EG; }
931 YY_BREAK
932 case 8:
933 YY_RULE_SETUP
934-#line 44 "flex.ll"
935+#line 44 "Core/QueryParser/flex.ll"
936 { return token::OR; }
937 YY_BREAK
938 case 9:
939 YY_RULE_SETUP
940-#line 45 "flex.ll"
941+#line 45 "Core/QueryParser/flex.ll"
942 { return token::AND; }
943 YY_BREAK
944 case 10:
945 YY_RULE_SETUP
946-#line 46 "flex.ll"
947+#line 46 "Core/QueryParser/flex.ll"
948 { return token::BOOL_TRUE; }
949 YY_BREAK
950 case 11:
951 YY_RULE_SETUP
952-#line 47 "flex.ll"
953+#line 47 "Core/QueryParser/flex.ll"
954 { return token::BOOL_FALSE; }
955 YY_BREAK
956 case 12:
957 YY_RULE_SETUP
958-#line 48 "flex.ll"
959+#line 48 "Core/QueryParser/flex.ll"
960 { return token::NOT; }
961 YY_BREAK
962 case 13:
963 YY_RULE_SETUP
964-#line 49 "flex.ll"
965+#line 49 "Core/QueryParser/flex.ll"
966 { return token::LPARAN; }
967 YY_BREAK
968 case 14:
969 YY_RULE_SETUP
970-#line 50 "flex.ll"
971+#line 50 "Core/QueryParser/flex.ll"
972 { return token::RPARAN; }
973 YY_BREAK
974 case 15:
975 YY_RULE_SETUP
976-#line 51 "flex.ll"
977+#line 51 "Core/QueryParser/flex.ll"
978 { yylval->string = new std::string(yytext); return token::LESS; }
979 YY_BREAK
980 case 16:
981 YY_RULE_SETUP
982-#line 52 "flex.ll"
983+#line 52 "Core/QueryParser/flex.ll"
984 { yylval->string = new std::string(yytext); return token::LESSEQUAL; }
985 YY_BREAK
986 case 17:
987 YY_RULE_SETUP
988-#line 53 "flex.ll"
989+#line 53 "Core/QueryParser/flex.ll"
990 { yylval->string = new std::string(yytext); return token::EQUAL; }
991 YY_BREAK
992 case 18:
993 YY_RULE_SETUP
994-#line 54 "flex.ll"
995+#line 54 "Core/QueryParser/flex.ll"
996 { yylval->string = new std::string(yytext); return token::EQUAL; }
997 YY_BREAK
998 case 19:
999 YY_RULE_SETUP
1000-#line 55 "flex.ll"
1001+#line 55 "Core/QueryParser/flex.ll"
1002 { yylval->string = new std::string(yytext); return token::GREATEREQUAL; }
1003 YY_BREAK
1004 case 20:
1005 YY_RULE_SETUP
1006-#line 56 "flex.ll"
1007+#line 56 "Core/QueryParser/flex.ll"
1008 { yylval->string = new std::string(yytext); return token::GREATER; }
1009 YY_BREAK
1010 case 21:
1011 YY_RULE_SETUP
1012-#line 57 "flex.ll"
1013+#line 57 "Core/QueryParser/flex.ll"
1014 { yylval->string = new std::string(yytext); return token::IDENTIFIER; }
1015 YY_BREAK
1016 case 22:
1017 YY_RULE_SETUP
1018-#line 59 "flex.ll"
1019+#line 59 "Core/QueryParser/flex.ll"
1020 ECHO;
1021 YY_BREAK
1022-#line 883 "Generated/lexer.cpp"
1023+#line 897 "Core/QueryParser/Generated/lexer.cpp"
1024 case YY_STATE_EOF(INITIAL):
1025 yyterminate();
1026
1027@@ -1066,7 +1080,7 @@
1028
1029 else
1030 {
1031- yy_size_t num_to_read =
1032+ int num_to_read =
1033 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1034
1035 while ( num_to_read <= 0 )
1036@@ -1080,7 +1094,7 @@
1037
1038 if ( b->yy_is_our_buffer )
1039 {
1040- yy_size_t new_size = b->yy_buf_size * 2;
1041+ int new_size = b->yy_buf_size * 2;
1042
1043 if ( new_size <= 0 )
1044 b->yy_buf_size += b->yy_buf_size / 8;
1045@@ -1111,7 +1125,7 @@
1046
1047 /* Read in more data. */
1048 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1049- (yy_n_chars), num_to_read );
1050+ (yy_n_chars), (size_t) num_to_read );
1051
1052 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1053 }
1054@@ -1234,7 +1248,7 @@
1055
1056 else
1057 { /* need more input */
1058- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1059+ int offset = (yy_c_buf_p) - (yytext_ptr);
1060 ++(yy_c_buf_p);
1061
1062 switch ( yy_get_next_buffer( ) )
1063@@ -1258,7 +1272,7 @@
1064 case EOB_ACT_END_OF_FILE:
1065 {
1066 if ( yywrap( ) )
1067- return 0;
1068+ return EOF;
1069
1070 if ( ! (yy_did_buffer_switch_on_eof) )
1071 YY_NEW_FILE;
1072@@ -1512,7 +1526,7 @@
1073 */
1074 static void yyensure_buffer_stack (void)
1075 {
1076- yy_size_t num_to_alloc;
1077+ int num_to_alloc;
1078
1079 if (!(yy_buffer_stack)) {
1080
1081@@ -1604,16 +1618,17 @@
1082
1083 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1084 * scan from a @e copy of @a bytes.
1085- * @param bytes the byte buffer to scan
1086- * @param len the number of bytes in the buffer pointed to by @a bytes.
1087+ * @param yybytes the byte buffer to scan
1088+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1089 *
1090 * @return the newly allocated buffer state object.
1091 */
1092-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
1093+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1094 {
1095 YY_BUFFER_STATE b;
1096 char *buf;
1097- yy_size_t n, i;
1098+ yy_size_t n;
1099+ int i;
1100
1101 /* Get memory for full buffer, including space for trailing EOB's. */
1102 n = _yybytes_len + 2;
1103@@ -1695,7 +1710,7 @@
1104 /** Get the length of the current token.
1105 *
1106 */
1107-yy_size_t yyget_leng (void)
1108+int yyget_leng (void)
1109 {
1110 return yyleng;
1111 }
1112@@ -1843,7 +1858,7 @@
1113
1114 #define YYTABLES_NAME "yytables"
1115
1116-#line 59 "flex.ll"
1117+#line 59 "Core/QueryParser/flex.ll"
1118
1119
1120 namespace VerifyTAPN
1121
1122=== modified file 'src/Core/QueryParser/Generated/location.hh'
1123--- src/Core/QueryParser/Generated/location.hh 2012-04-19 12:40:05 +0000
1124+++ src/Core/QueryParser/Generated/location.hh 2013-03-31 13:25:26 +0000
1125@@ -1,8 +1,8 @@
1126-/* A Bison parser, made by GNU Bison 2.5. */
1127+/* A Bison parser, made by GNU Bison 2.6.5. */
1128
1129 /* Locations for Bison parsers in C++
1130
1131- Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
1132+ Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
1133
1134 This program is free software: you can redistribute it and/or modify
1135 it under the terms of the GNU General Public License as published by
1136@@ -31,41 +31,56 @@
1137 version 2.2 of Bison. */
1138
1139 /**
1140- ** \file location.hh
1141+ ** \file Core/QueryParser/Generated/location.hh
1142 ** Define the VerifyTAPN::location class.
1143 */
1144
1145-#ifndef BISON_LOCATION_HH
1146-# define BISON_LOCATION_HH
1147+#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_LOCATION_HH_INCLUDED
1148+# define YY_YY_CORE_QUERYPARSER_GENERATED_LOCATION_HH_INCLUDED
1149
1150-# include <iostream>
1151-# include <string>
1152 # include "position.hh"
1153
1154-
1155-/* Line 162 of location.cc */
1156-#line 5 "grammar.yy"
1157+/* Line 164 of location.cc */
1158+#line 5 "Core/QueryParser/grammar.yy"
1159 namespace VerifyTAPN {
1160-
1161-/* Line 162 of location.cc */
1162-#line 52 "Generated/location.hh"
1163+/* Line 164 of location.cc */
1164+#line 48 "Core/QueryParser/Generated/location.hh"
1165
1166 /// Abstract a location.
1167 class location
1168 {
1169 public:
1170
1171- /// Construct a location.
1172- location ()
1173- : begin (), end ()
1174+ /// Construct a location from \a b to \a e.
1175+ location (const position& b, const position& e)
1176+ : begin (b)
1177+ , end (e)
1178+ {
1179+ }
1180+
1181+ /// Construct a 0-width location in \a p.
1182+ explicit location (const position& p = position ())
1183+ : begin (p)
1184+ , end (p)
1185+ {
1186+ }
1187+
1188+ /// Construct a 0-width location in \a f, \a l, \a c.
1189+ explicit location (std::string* f,
1190+ unsigned int l = 1u,
1191+ unsigned int c = 1u)
1192+ : begin (f, l, c)
1193+ , end (f, l, c)
1194 {
1195 }
1196
1197
1198 /// Initialization.
1199- inline void initialize (std::string* fn)
1200+ void initialize (std::string* f = YY_NULL,
1201+ unsigned int l = 1u,
1202+ unsigned int c = 1u)
1203 {
1204- begin.initialize (fn);
1205+ begin.initialize (f, l, c);
1206 end = begin;
1207 }
1208
1209@@ -73,19 +88,19 @@
1210 ** \{ */
1211 public:
1212 /// Reset initial location to final location.
1213- inline void step ()
1214+ void step ()
1215 {
1216 begin = end;
1217 }
1218
1219 /// Extend the current location to the COUNT next columns.
1220- inline void columns (unsigned int count = 1)
1221+ void columns (unsigned int count = 1)
1222 {
1223 end += count;
1224 }
1225
1226 /// Extend the current location to the COUNT next lines.
1227- inline void lines (unsigned int count = 1)
1228+ void lines (unsigned int count = 1)
1229 {
1230 end.lines (count);
1231 }
1232@@ -157,12 +172,10 @@
1233 return ostr;
1234 }
1235
1236-
1237-/* Line 271 of location.cc */
1238-#line 5 "grammar.yy"
1239+/* Line 292 of location.cc */
1240+#line 5 "Core/QueryParser/grammar.yy"
1241 } // VerifyTAPN
1242-
1243-/* Line 271 of location.cc */
1244-#line 167 "Generated/location.hh"
1245-
1246-#endif // not BISON_LOCATION_HH
1247+/* Line 292 of location.cc */
1248+#line 180 "Core/QueryParser/Generated/location.hh"
1249+
1250+#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_LOCATION_HH_INCLUDED */
1251
1252=== modified file 'src/Core/QueryParser/Generated/parser.cpp'
1253--- src/Core/QueryParser/Generated/parser.cpp 2012-04-19 12:40:05 +0000
1254+++ src/Core/QueryParser/Generated/parser.cpp 2013-03-31 13:25:26 +0000
1255@@ -1,8 +1,8 @@
1256-/* A Bison parser, made by GNU Bison 2.5. */
1257+/* A Bison parser, made by GNU Bison 2.6.5. */
1258
1259 /* Skeleton implementation for Bison LALR(1) parsers in C++
1260
1261- Copyright (C) 2002-2011 Free Software Foundation, Inc.
1262+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
1263
1264 This program is free software: you can redistribute it and/or modify
1265 it under the terms of the GNU General Public License as published by
1266@@ -33,29 +33,34 @@
1267
1268 /* First part of user declarations. */
1269
1270-
1271-/* Line 293 of lalr1.cc */
1272-#line 39 "Generated/parser.cpp"
1273+/* Line 278 of lalr1.cc */
1274+#line 38 "Core/QueryParser/Generated/parser.cpp"
1275
1276
1277 #include "parser.hpp"
1278
1279 /* User implementation prologue. */
1280
1281-
1282-/* Line 299 of lalr1.cc */
1283-#line 48 "Generated/parser.cpp"
1284+/* Line 284 of lalr1.cc */
1285+#line 46 "Core/QueryParser/Generated/parser.cpp"
1286 /* Unqualified %code blocks. */
1287-
1288-/* Line 300 of lalr1.cc */
1289-#line 37 "grammar.yy"
1290+/* Line 285 of lalr1.cc */
1291+#line 37 "Core/QueryParser/grammar.yy"
1292
1293 #include "../TAPNQueryParser.hpp"
1294
1295
1296-
1297-/* Line 300 of lalr1.cc */
1298-#line 59 "Generated/parser.cpp"
1299+/* Line 285 of lalr1.cc */
1300+#line 55 "Core/QueryParser/Generated/parser.cpp"
1301+
1302+
1303+# ifndef YY_NULL
1304+# if defined __cplusplus && 201103L <= __cplusplus
1305+# define YY_NULL nullptr
1306+# else
1307+# define YY_NULL 0
1308+# endif
1309+# endif
1310
1311 #ifndef YY_
1312 # if defined YYENABLE_NLS && YYENABLE_NLS
1313@@ -69,25 +74,26 @@
1314 # endif
1315 #endif
1316
1317+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
1318 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1319 If N is 0, then set CURRENT to the empty location which ends
1320 the previous symbol: RHS[0] (always defined). */
1321
1322-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
1323-#ifndef YYLLOC_DEFAULT
1324-# define YYLLOC_DEFAULT(Current, Rhs, N) \
1325- do \
1326- if (N) \
1327- { \
1328- (Current).begin = YYRHSLOC (Rhs, 1).begin; \
1329- (Current).end = YYRHSLOC (Rhs, N).end; \
1330- } \
1331- else \
1332- { \
1333- (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
1334- } \
1335- while (false)
1336-#endif
1337+# ifndef YYLLOC_DEFAULT
1338+# define YYLLOC_DEFAULT(Current, Rhs, N) \
1339+ do \
1340+ if (N) \
1341+ { \
1342+ (Current).begin = YYRHSLOC (Rhs, 1).begin; \
1343+ (Current).end = YYRHSLOC (Rhs, N).end; \
1344+ } \
1345+ else \
1346+ { \
1347+ (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
1348+ } \
1349+ while (/*CONSTCOND*/ false)
1350+# endif
1351+
1352
1353 /* Suppress unused-variable warnings by "using" E. */
1354 #define YYUSE(e) ((void) (e))
1355@@ -137,13 +143,11 @@
1356 #define YYERROR goto yyerrorlab
1357 #define YYRECOVERING() (!!yyerrstatus_)
1358
1359-
1360-/* Line 382 of lalr1.cc */
1361-#line 5 "grammar.yy"
1362+/* Line 352 of lalr1.cc */
1363+#line 5 "Core/QueryParser/grammar.yy"
1364 namespace VerifyTAPN {
1365-
1366-/* Line 382 of lalr1.cc */
1367-#line 147 "Generated/parser.cpp"
1368+/* Line 352 of lalr1.cc */
1369+#line 151 "Core/QueryParser/Generated/parser.cpp"
1370
1371 /* Return YYSTR after stripping away unnecessary quotes and
1372 backslashes, so that it's suitable for yyerror. The heuristic is
1373@@ -209,6 +213,9 @@
1374 {
1375 YYUSE (yylocationp);
1376 YYUSE (yyvaluep);
1377+ std::ostream& yyo = debug_stream ();
1378+ std::ostream& yyoutput = yyo;
1379+ YYUSE (yyoutput);
1380 switch (yytype)
1381 {
1382 default:
1383@@ -241,140 +248,110 @@
1384
1385 switch (yytype)
1386 {
1387- case 3: /* "IDENTIFIER" */
1388-
1389-/* Line 480 of lalr1.cc */
1390-#line 52 "grammar.yy"
1391- { delete (yyvaluep->string); };
1392-
1393-/* Line 480 of lalr1.cc */
1394-#line 252 "Generated/parser.cpp"
1395- break;
1396- case 4: /* "LESS" */
1397-
1398-/* Line 480 of lalr1.cc */
1399-#line 52 "grammar.yy"
1400- { delete (yyvaluep->string); };
1401-
1402-/* Line 480 of lalr1.cc */
1403-#line 261 "Generated/parser.cpp"
1404- break;
1405- case 5: /* "LESSEQUAL" */
1406-
1407-/* Line 480 of lalr1.cc */
1408-#line 52 "grammar.yy"
1409- { delete (yyvaluep->string); };
1410-
1411-/* Line 480 of lalr1.cc */
1412-#line 270 "Generated/parser.cpp"
1413- break;
1414- case 6: /* "EQUAL" */
1415-
1416-/* Line 480 of lalr1.cc */
1417-#line 52 "grammar.yy"
1418- { delete (yyvaluep->string); };
1419-
1420-/* Line 480 of lalr1.cc */
1421-#line 279 "Generated/parser.cpp"
1422- break;
1423- case 7: /* "GREATEREQUAL" */
1424-
1425-/* Line 480 of lalr1.cc */
1426-#line 52 "grammar.yy"
1427- { delete (yyvaluep->string); };
1428-
1429-/* Line 480 of lalr1.cc */
1430-#line 288 "Generated/parser.cpp"
1431- break;
1432- case 8: /* "GREATER" */
1433-
1434-/* Line 480 of lalr1.cc */
1435-#line 52 "grammar.yy"
1436- { delete (yyvaluep->string); };
1437-
1438-/* Line 480 of lalr1.cc */
1439-#line 297 "Generated/parser.cpp"
1440- break;
1441- case 22: /* "query" */
1442-
1443-/* Line 480 of lalr1.cc */
1444-#line 54 "grammar.yy"
1445- { delete (yyvaluep->query); };
1446-
1447-/* Line 480 of lalr1.cc */
1448-#line 306 "Generated/parser.cpp"
1449- break;
1450- case 23: /* "expression" */
1451-
1452-/* Line 480 of lalr1.cc */
1453-#line 53 "grammar.yy"
1454- { delete (yyvaluep->expr); };
1455-
1456-/* Line 480 of lalr1.cc */
1457-#line 315 "Generated/parser.cpp"
1458- break;
1459- case 24: /* "parExpression" */
1460-
1461-/* Line 480 of lalr1.cc */
1462-#line 53 "grammar.yy"
1463- { delete (yyvaluep->expr); };
1464-
1465-/* Line 480 of lalr1.cc */
1466-#line 324 "Generated/parser.cpp"
1467- break;
1468- case 25: /* "notExpression" */
1469-
1470-/* Line 480 of lalr1.cc */
1471-#line 53 "grammar.yy"
1472- { delete (yyvaluep->expr); };
1473-
1474-/* Line 480 of lalr1.cc */
1475-#line 333 "Generated/parser.cpp"
1476- break;
1477- case 26: /* "orExpression" */
1478-
1479-/* Line 480 of lalr1.cc */
1480-#line 53 "grammar.yy"
1481- { delete (yyvaluep->expr); };
1482-
1483-/* Line 480 of lalr1.cc */
1484-#line 342 "Generated/parser.cpp"
1485- break;
1486- case 27: /* "andExpression" */
1487-
1488-/* Line 480 of lalr1.cc */
1489-#line 53 "grammar.yy"
1490- { delete (yyvaluep->expr); };
1491-
1492-/* Line 480 of lalr1.cc */
1493-#line 351 "Generated/parser.cpp"
1494- break;
1495- case 28: /* "boolExpression" */
1496-
1497-/* Line 480 of lalr1.cc */
1498-#line 53 "grammar.yy"
1499- { delete (yyvaluep->expr); };
1500-
1501-/* Line 480 of lalr1.cc */
1502-#line 360 "Generated/parser.cpp"
1503- break;
1504- case 29: /* "atomicProposition" */
1505-
1506-/* Line 480 of lalr1.cc */
1507-#line 53 "grammar.yy"
1508- { delete (yyvaluep->expr); };
1509-
1510-/* Line 480 of lalr1.cc */
1511-#line 369 "Generated/parser.cpp"
1512- break;
1513- case 30: /* "compareOp" */
1514-
1515-/* Line 480 of lalr1.cc */
1516-#line 52 "grammar.yy"
1517- { delete (yyvaluep->string); };
1518-
1519-/* Line 480 of lalr1.cc */
1520-#line 378 "Generated/parser.cpp"
1521+ case 3: /* IDENTIFIER */
1522+/* Line 453 of lalr1.cc */
1523+#line 52 "Core/QueryParser/grammar.yy"
1524+ { delete ((*yyvaluep).string); };
1525+/* Line 453 of lalr1.cc */
1526+#line 257 "Core/QueryParser/Generated/parser.cpp"
1527+ break;
1528+ case 4: /* LESS */
1529+/* Line 453 of lalr1.cc */
1530+#line 52 "Core/QueryParser/grammar.yy"
1531+ { delete ((*yyvaluep).string); };
1532+/* Line 453 of lalr1.cc */
1533+#line 264 "Core/QueryParser/Generated/parser.cpp"
1534+ break;
1535+ case 5: /* LESSEQUAL */
1536+/* Line 453 of lalr1.cc */
1537+#line 52 "Core/QueryParser/grammar.yy"
1538+ { delete ((*yyvaluep).string); };
1539+/* Line 453 of lalr1.cc */
1540+#line 271 "Core/QueryParser/Generated/parser.cpp"
1541+ break;
1542+ case 6: /* EQUAL */
1543+/* Line 453 of lalr1.cc */
1544+#line 52 "Core/QueryParser/grammar.yy"
1545+ { delete ((*yyvaluep).string); };
1546+/* Line 453 of lalr1.cc */
1547+#line 278 "Core/QueryParser/Generated/parser.cpp"
1548+ break;
1549+ case 7: /* GREATEREQUAL */
1550+/* Line 453 of lalr1.cc */
1551+#line 52 "Core/QueryParser/grammar.yy"
1552+ { delete ((*yyvaluep).string); };
1553+/* Line 453 of lalr1.cc */
1554+#line 285 "Core/QueryParser/Generated/parser.cpp"
1555+ break;
1556+ case 8: /* GREATER */
1557+/* Line 453 of lalr1.cc */
1558+#line 52 "Core/QueryParser/grammar.yy"
1559+ { delete ((*yyvaluep).string); };
1560+/* Line 453 of lalr1.cc */
1561+#line 292 "Core/QueryParser/Generated/parser.cpp"
1562+ break;
1563+ case 22: /* query */
1564+/* Line 453 of lalr1.cc */
1565+#line 54 "Core/QueryParser/grammar.yy"
1566+ { delete ((*yyvaluep).query); };
1567+/* Line 453 of lalr1.cc */
1568+#line 299 "Core/QueryParser/Generated/parser.cpp"
1569+ break;
1570+ case 23: /* expression */
1571+/* Line 453 of lalr1.cc */
1572+#line 53 "Core/QueryParser/grammar.yy"
1573+ { delete ((*yyvaluep).expr); };
1574+/* Line 453 of lalr1.cc */
1575+#line 306 "Core/QueryParser/Generated/parser.cpp"
1576+ break;
1577+ case 24: /* parExpression */
1578+/* Line 453 of lalr1.cc */
1579+#line 53 "Core/QueryParser/grammar.yy"
1580+ { delete ((*yyvaluep).expr); };
1581+/* Line 453 of lalr1.cc */
1582+#line 313 "Core/QueryParser/Generated/parser.cpp"
1583+ break;
1584+ case 25: /* notExpression */
1585+/* Line 453 of lalr1.cc */
1586+#line 53 "Core/QueryParser/grammar.yy"
1587+ { delete ((*yyvaluep).expr); };
1588+/* Line 453 of lalr1.cc */
1589+#line 320 "Core/QueryParser/Generated/parser.cpp"
1590+ break;
1591+ case 26: /* orExpression */
1592+/* Line 453 of lalr1.cc */
1593+#line 53 "Core/QueryParser/grammar.yy"
1594+ { delete ((*yyvaluep).expr); };
1595+/* Line 453 of lalr1.cc */
1596+#line 327 "Core/QueryParser/Generated/parser.cpp"
1597+ break;
1598+ case 27: /* andExpression */
1599+/* Line 453 of lalr1.cc */
1600+#line 53 "Core/QueryParser/grammar.yy"
1601+ { delete ((*yyvaluep).expr); };
1602+/* Line 453 of lalr1.cc */
1603+#line 334 "Core/QueryParser/Generated/parser.cpp"
1604+ break;
1605+ case 28: /* boolExpression */
1606+/* Line 453 of lalr1.cc */
1607+#line 53 "Core/QueryParser/grammar.yy"
1608+ { delete ((*yyvaluep).expr); };
1609+/* Line 453 of lalr1.cc */
1610+#line 341 "Core/QueryParser/Generated/parser.cpp"
1611+ break;
1612+ case 29: /* atomicProposition */
1613+/* Line 453 of lalr1.cc */
1614+#line 53 "Core/QueryParser/grammar.yy"
1615+ { delete ((*yyvaluep).expr); };
1616+/* Line 453 of lalr1.cc */
1617+#line 348 "Core/QueryParser/Generated/parser.cpp"
1618+ break;
1619+ case 30: /* compareOp */
1620+/* Line 453 of lalr1.cc */
1621+#line 52 "Core/QueryParser/grammar.yy"
1622+ { delete ((*yyvaluep).string); };
1623+/* Line 453 of lalr1.cc */
1624+#line 355 "Core/QueryParser/Generated/parser.cpp"
1625 break;
1626
1627 default:
1628@@ -436,17 +413,18 @@
1629 int yychar = yyempty_;
1630 int yytoken = 0;
1631
1632- /* State. */
1633+ // State.
1634 int yyn;
1635 int yylen = 0;
1636 int yystate = 0;
1637
1638- /* Error handling. */
1639+ // Error handling.
1640 int yynerrs_ = 0;
1641 int yyerrstatus_ = 0;
1642
1643 /// Semantic value of the lookahead.
1644- semantic_type yylval;
1645+ static semantic_type yyval_default;
1646+ semantic_type yylval = yyval_default;
1647 /// Location of the lookahead.
1648 location_type yylloc;
1649 /// The locations where the error started and ended.
1650@@ -462,17 +440,15 @@
1651 YYCDEBUG << "Starting parse" << std::endl;
1652
1653
1654- /* User initialization code. */
1655-
1656-/* Line 565 of lalr1.cc */
1657-#line 21 "grammar.yy"
1658+/* User initialization code. */
1659+/* Line 539 of lalr1.cc */
1660+#line 21 "Core/QueryParser/grammar.yy"
1661 {
1662 // Initialize the initial location.
1663 yylloc.begin.filename = yylloc.end.filename = &driver.file;
1664 }
1665-
1666-/* Line 565 of lalr1.cc */
1667-#line 476 "Generated/parser.cpp"
1668+/* Line 539 of lalr1.cc */
1669+#line 452 "Core/QueryParser/Generated/parser.cpp"
1670
1671 /* Initialize the stacks. The initial state will be pushed in
1672 yynewstate, since the latter expects the semantical and the
1673@@ -510,7 +486,6 @@
1674 yychar = yylex (&yylval, &yylloc, driver);
1675 }
1676
1677-
1678 /* Convert token to internal form. */
1679 if (yychar <= yyeof_)
1680 {
1681@@ -589,121 +564,104 @@
1682 switch (yyn)
1683 {
1684 case 2:
1685-
1686-/* Line 690 of lalr1.cc */
1687-#line 58 "grammar.yy"
1688+/* Line 661 of lalr1.cc */
1689+#line 58 "Core/QueryParser/grammar.yy"
1690 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::EF, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
1691 break;
1692
1693 case 3:
1694-
1695-/* Line 690 of lalr1.cc */
1696-#line 59 "grammar.yy"
1697+/* Line 661 of lalr1.cc */
1698+#line 59 "Core/QueryParser/grammar.yy"
1699 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::AG, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
1700 break;
1701
1702 case 4:
1703-
1704-/* Line 690 of lalr1.cc */
1705-#line 60 "grammar.yy"
1706+/* Line 661 of lalr1.cc */
1707+#line 60 "Core/QueryParser/grammar.yy"
1708 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::EG, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
1709 break;
1710
1711 case 5:
1712-
1713-/* Line 690 of lalr1.cc */
1714-#line 61 "grammar.yy"
1715+/* Line 661 of lalr1.cc */
1716+#line 61 "Core/QueryParser/grammar.yy"
1717 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::AF, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
1718 break;
1719
1720 case 6:
1721-
1722-/* Line 690 of lalr1.cc */
1723-#line 64 "grammar.yy"
1724+/* Line 661 of lalr1.cc */
1725+#line 64 "Core/QueryParser/grammar.yy"
1726 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
1727 break;
1728
1729 case 7:
1730-
1731-/* Line 690 of lalr1.cc */
1732-#line 65 "grammar.yy"
1733+/* Line 661 of lalr1.cc */
1734+#line 65 "Core/QueryParser/grammar.yy"
1735 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
1736 break;
1737
1738 case 8:
1739-
1740-/* Line 690 of lalr1.cc */
1741-#line 66 "grammar.yy"
1742+/* Line 661 of lalr1.cc */
1743+#line 66 "Core/QueryParser/grammar.yy"
1744 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
1745 break;
1746
1747 case 9:
1748-
1749-/* Line 690 of lalr1.cc */
1750-#line 67 "grammar.yy"
1751+/* Line 661 of lalr1.cc */
1752+#line 67 "Core/QueryParser/grammar.yy"
1753 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
1754 break;
1755
1756 case 10:
1757-
1758-/* Line 690 of lalr1.cc */
1759-#line 68 "grammar.yy"
1760+/* Line 661 of lalr1.cc */
1761+#line 68 "Core/QueryParser/grammar.yy"
1762 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
1763 break;
1764
1765 case 11:
1766-
1767-/* Line 690 of lalr1.cc */
1768-#line 69 "grammar.yy"
1769+/* Line 661 of lalr1.cc */
1770+#line 69 "Core/QueryParser/grammar.yy"
1771 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
1772 break;
1773
1774 case 12:
1775-
1776-/* Line 690 of lalr1.cc */
1777-#line 75 "grammar.yy"
1778+/* Line 661 of lalr1.cc */
1779+#line 75 "Core/QueryParser/grammar.yy"
1780 { (yyval.expr) = new VerifyTAPN::AST::ParExpression((yysemantic_stack_[(3) - (2)].expr)); }
1781 break;
1782
1783 case 13:
1784-
1785-/* Line 690 of lalr1.cc */
1786-#line 76 "grammar.yy"
1787+/* Line 661 of lalr1.cc */
1788+#line 76 "Core/QueryParser/grammar.yy"
1789 { (yyval.expr) = new VerifyTAPN::AST::NotExpression((yysemantic_stack_[(2) - (2)].expr)); }
1790 break;
1791
1792 case 14:
1793-
1794-/* Line 690 of lalr1.cc */
1795-#line 77 "grammar.yy"
1796+/* Line 661 of lalr1.cc */
1797+#line 77 "Core/QueryParser/grammar.yy"
1798 { (yyval.expr) = new VerifyTAPN::AST::OrExpression((yysemantic_stack_[(3) - (1)].expr), (yysemantic_stack_[(3) - (3)].expr)); }
1799 break;
1800
1801 case 15:
1802-
1803-/* Line 690 of lalr1.cc */
1804-#line 78 "grammar.yy"
1805+/* Line 661 of lalr1.cc */
1806+#line 78 "Core/QueryParser/grammar.yy"
1807 { (yyval.expr) = new VerifyTAPN::AST::AndExpression((yysemantic_stack_[(3) - (1)].expr), (yysemantic_stack_[(3) - (3)].expr)); }
1808 break;
1809
1810 case 16:
1811-
1812-/* Line 690 of lalr1.cc */
1813-#line 79 "grammar.yy"
1814+/* Line 661 of lalr1.cc */
1815+#line 79 "Core/QueryParser/grammar.yy"
1816 { (yyval.expr) = new VerifyTAPN::AST::BoolExpression(true); }
1817 break;
1818
1819 case 17:
1820-
1821-/* Line 690 of lalr1.cc */
1822-#line 80 "grammar.yy"
1823+/* Line 661 of lalr1.cc */
1824+#line 80 "Core/QueryParser/grammar.yy"
1825 { (yyval.expr) = new VerifyTAPN::AST::BoolExpression(false); }
1826 break;
1827
1828 case 18:
1829-
1830-/* Line 690 of lalr1.cc */
1831-#line 82 "grammar.yy"
1832+/* Line 661 of lalr1.cc */
1833+#line 82 "Core/QueryParser/grammar.yy"
1834 {
1835 int placeIndex = driver.tapn().GetPlaceIndex(*(yysemantic_stack_[(3) - (1)].string));
1836 if(placeIndex == -1) error((yylocation_stack_[(3) - (1)]), "unknown place");
1837@@ -712,9 +670,8 @@
1838 break;
1839
1840
1841-
1842-/* Line 690 of lalr1.cc */
1843-#line 718 "Generated/parser.cpp"
1844+/* Line 661 of lalr1.cc */
1845+#line 675 "Core/QueryParser/Generated/parser.cpp"
1846 default:
1847 break;
1848 }
1849@@ -956,7 +913,7 @@
1850 }
1851 }
1852
1853- char const* yyformat = 0;
1854+ char const* yyformat = YY_NULL;
1855 switch (yycount)
1856 {
1857 #define YYCASE_(N, S) \
1858@@ -1086,7 +1043,7 @@
1859 1, 1, 1, 1
1860 };
1861
1862-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1863+
1864 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1865 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
1866 const char*
1867@@ -1097,9 +1054,8 @@
1868 "LPARAN", "RPARAN", "OR", "AND", "NOT", "BOOL_TRUE", "BOOL_FALSE",
1869 "$accept", "query", "expression", "parExpression", "notExpression",
1870 "orExpression", "andExpression", "boolExpression", "atomicProposition",
1871- "compareOp", 0
1872+ "compareOp", YY_NULL
1873 };
1874-#endif
1875
1876 #if YYDEBUG
1877 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1878@@ -1217,17 +1173,13 @@
1879 const unsigned int Parser::yyuser_token_number_max_ = 275;
1880 const Parser::token_number_type Parser::yyundef_token_ = 2;
1881
1882-
1883-/* Line 1136 of lalr1.cc */
1884-#line 5 "grammar.yy"
1885+/* Line 1106 of lalr1.cc */
1886+#line 5 "Core/QueryParser/grammar.yy"
1887 } // VerifyTAPN
1888-
1889-/* Line 1136 of lalr1.cc */
1890-#line 1227 "Generated/parser.cpp"
1891-
1892-
1893-/* Line 1138 of lalr1.cc */
1894-#line 89 "grammar.yy"
1895+/* Line 1106 of lalr1.cc */
1896+#line 1181 "Core/QueryParser/Generated/parser.cpp"
1897+/* Line 1107 of lalr1.cc */
1898+#line 89 "Core/QueryParser/grammar.yy"
1899
1900
1901 void
1902@@ -1237,4 +1189,3 @@
1903 driver.error (l, m);
1904 exit(1);
1905 }
1906-
1907
1908=== modified file 'src/Core/QueryParser/Generated/parser.hpp'
1909--- src/Core/QueryParser/Generated/parser.hpp 2012-04-19 12:40:05 +0000
1910+++ src/Core/QueryParser/Generated/parser.hpp 2013-03-31 13:25:26 +0000
1911@@ -1,8 +1,8 @@
1912-/* A Bison parser, made by GNU Bison 2.5. */
1913+/* A Bison parser, made by GNU Bison 2.6.5. */
1914
1915 /* Skeleton interface for Bison LALR(1) parsers in C++
1916
1917- Copyright (C) 2002-2011 Free Software Foundation, Inc.
1918+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
1919
1920 This program is free software: you can redistribute it and/or modify
1921 it under the terms of the GNU General Public License as published by
1922@@ -30,15 +30,19 @@
1923 This special exception was added by the Free Software Foundation in
1924 version 2.2 of Bison. */
1925
1926+/**
1927+ ** \file Core/QueryParser/Generated/parser.hpp
1928+ ** Define the VerifyTAPN::parser class.
1929+ */
1930+
1931 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
1932
1933-#ifndef PARSER_HEADER_H
1934-# define PARSER_HEADER_H
1935+#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_PARSER_HPP_INCLUDED
1936+# define YY_YY_CORE_QUERYPARSER_GENERATED_PARSER_HPP_INCLUDED
1937
1938 /* "%code requires" blocks. */
1939-
1940-/* Line 35 of lalr1.cc */
1941-#line 7 "grammar.yy"
1942+/* Line 36 of lalr1.cc */
1943+#line 7 "Core/QueryParser/grammar.yy"
1944
1945 # include <string>
1946 #include "../AST.hpp"
1947@@ -47,9 +51,8 @@
1948 }
1949
1950
1951-
1952-/* Line 35 of lalr1.cc */
1953-#line 53 "Generated/parser.hpp"
1954+/* Line 36 of lalr1.cc */
1955+#line 56 "Core/QueryParser/Generated/parser.hpp"
1956
1957
1958 #include <string>
1959@@ -62,26 +65,11 @@
1960 # define YYDEBUG 0
1961 #endif
1962
1963-/* Enabling verbose error messages. */
1964-#ifdef YYERROR_VERBOSE
1965-# undef YYERROR_VERBOSE
1966-# define YYERROR_VERBOSE 1
1967-#else
1968-# define YYERROR_VERBOSE 1
1969-#endif
1970-
1971-/* Enabling the token table. */
1972-#ifndef YYTOKEN_TABLE
1973-# define YYTOKEN_TABLE 0
1974-#endif
1975-
1976-
1977-/* Line 35 of lalr1.cc */
1978-#line 5 "grammar.yy"
1979+/* Line 36 of lalr1.cc */
1980+#line 5 "Core/QueryParser/grammar.yy"
1981 namespace VerifyTAPN {
1982-
1983-/* Line 35 of lalr1.cc */
1984-#line 85 "Generated/parser.hpp"
1985+/* Line 36 of lalr1.cc */
1986+#line 73 "Core/QueryParser/Generated/parser.hpp"
1987
1988 /// A Bison parser.
1989 class Parser
1990@@ -91,9 +79,8 @@
1991 #ifndef YYSTYPE
1992 union semantic_type
1993 {
1994-
1995-/* Line 35 of lalr1.cc */
1996-#line 30 "grammar.yy"
1997+/* Line 36 of lalr1.cc */
1998+#line 30 "Core/QueryParser/grammar.yy"
1999
2000 int number;
2001 std::string* string;
2002@@ -101,9 +88,8 @@
2003 VerifyTAPN::AST::Query* query;
2004
2005
2006-
2007-/* Line 35 of lalr1.cc */
2008-#line 107 "Generated/parser.hpp"
2009+/* Line 36 of lalr1.cc */
2010+#line 93 "Core/QueryParser/Generated/parser.hpp"
2011 };
2012 #else
2013 typedef YYSTYPE semantic_type;
2014@@ -246,16 +232,14 @@
2015 /// For a rule, its LHS.
2016 static const unsigned char yyr1_[];
2017 /// For a rule, its RHS length.
2018- static const unsigned char yyr2_[];
2019-
2020-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2021+ static const unsigned char yyr2_[];
2022+
2023+ /// Convert the symbol name \a n to a form suitable for a diagnostic.
2024+ static std::string yytnamerr_ (const char *n);
2025+
2026+
2027 /// For a symbol, its name in clear.
2028 static const char* const yytname_[];
2029-#endif
2030-
2031- /// Convert the symbol name \a n to a form suitable for a diagnostic.
2032- static std::string yytnamerr_ (const char *n);
2033-
2034 #if YYDEBUG
2035 /// A type to store symbol numbers and -1.
2036 typedef signed char rhs_number_type;
2037@@ -309,14 +293,12 @@
2038 /* User arguments. */
2039 VerifyTAPN::TAPNQueryParser& driver;
2040 };
2041-
2042-/* Line 35 of lalr1.cc */
2043-#line 5 "grammar.yy"
2044+/* Line 36 of lalr1.cc */
2045+#line 5 "Core/QueryParser/grammar.yy"
2046 } // VerifyTAPN
2047-
2048-/* Line 35 of lalr1.cc */
2049-#line 319 "Generated/parser.hpp"
2050-
2051-
2052-
2053-#endif /* ! defined PARSER_HEADER_H */
2054+/* Line 36 of lalr1.cc */
2055+#line 301 "Core/QueryParser/Generated/parser.hpp"
2056+
2057+
2058+
2059+#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_PARSER_HPP_INCLUDED */
2060
2061=== modified file 'src/Core/QueryParser/Generated/position.hh'
2062--- src/Core/QueryParser/Generated/position.hh 2012-04-19 12:40:05 +0000
2063+++ src/Core/QueryParser/Generated/position.hh 2013-03-31 13:25:26 +0000
2064@@ -1,8 +1,8 @@
2065-/* A Bison parser, made by GNU Bison 2.5. */
2066+/* A Bison parser, made by GNU Bison 2.6.5. */
2067
2068 /* Positions for Bison parsers in C++
2069
2070- Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
2071+ Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
2072
2073 This program is free software: you can redistribute it and/or modify
2074 it under the terms of the GNU General Public License as published by
2075@@ -31,62 +31,72 @@
2076 version 2.2 of Bison. */
2077
2078 /**
2079- ** \file position.hh
2080+ ** \file Core/QueryParser/Generated/position.hh
2081 ** Define the VerifyTAPN::position class.
2082 */
2083
2084-#ifndef BISON_POSITION_HH
2085-# define BISON_POSITION_HH
2086+#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_POSITION_HH_INCLUDED
2087+# define YY_YY_CORE_QUERYPARSER_GENERATED_POSITION_HH_INCLUDED
2088
2089+# include <algorithm> // std::max
2090 # include <iostream>
2091 # include <string>
2092-# include <algorithm>
2093-
2094-
2095-/* Line 37 of location.cc */
2096-#line 5 "grammar.yy"
2097+
2098+# ifndef YY_NULL
2099+# if defined __cplusplus && 201103L <= __cplusplus
2100+# define YY_NULL nullptr
2101+# else
2102+# define YY_NULL 0
2103+# endif
2104+# endif
2105+
2106+/* Line 38 of location.cc */
2107+#line 5 "Core/QueryParser/grammar.yy"
2108 namespace VerifyTAPN {
2109-
2110-/* Line 37 of location.cc */
2111-#line 52 "Generated/position.hh"
2112+/* Line 38 of location.cc */
2113+#line 58 "Core/QueryParser/Generated/position.hh"
2114 /// Abstract a position.
2115 class position
2116 {
2117 public:
2118
2119 /// Construct a position.
2120- position ()
2121- : filename (0), line (1), column (1)
2122+ explicit position (std::string* f = YY_NULL,
2123+ unsigned int l = 1u,
2124+ unsigned int c = 1u)
2125+ : filename (f)
2126+ , line (l)
2127+ , column (c)
2128 {
2129 }
2130
2131
2132 /// Initialization.
2133- inline void initialize (std::string* fn)
2134+ void initialize (std::string* fn = YY_NULL,
2135+ unsigned int l = 1u,
2136+ unsigned int c = 1u)
2137 {
2138 filename = fn;
2139- line = 1;
2140- column = 1;
2141+ line = l;
2142+ column = c;
2143 }
2144
2145 /** \name Line and Column related manipulators
2146 ** \{ */
2147- public:
2148 /// (line related) Advance to the COUNT next lines.
2149- inline void lines (int count = 1)
2150+ void lines (int count = 1)
2151 {
2152- column = 1;
2153+ column = 1u;
2154 line += count;
2155 }
2156
2157 /// (column related) Advance to the COUNT next columns.
2158- inline void columns (int count = 1)
2159+ void columns (int count = 1)
2160 {
2161 column = std::max (1u, column + count);
2162 }
2163 /** \} */
2164
2165- public:
2166 /// File name to which this position refers.
2167 std::string* filename;
2168 /// Current line number.
2169@@ -96,7 +106,7 @@
2170 };
2171
2172 /// Add and assign a position.
2173- inline const position&
2174+ inline position&
2175 operator+= (position& res, const int width)
2176 {
2177 res.columns (width);
2178@@ -112,7 +122,7 @@
2179 }
2180
2181 /// Add and assign a position.
2182- inline const position&
2183+ inline position&
2184 operator-= (position& res, const int width)
2185 {
2186 return res += -width;
2187@@ -155,11 +165,9 @@
2188 return ostr << pos.line << '.' << pos.column;
2189 }
2190
2191-
2192-/* Line 144 of location.cc */
2193-#line 5 "grammar.yy"
2194+/* Line 149 of location.cc */
2195+#line 5 "Core/QueryParser/grammar.yy"
2196 } // VerifyTAPN
2197-
2198-/* Line 144 of location.cc */
2199-#line 165 "Generated/position.hh"
2200-#endif // not BISON_POSITION_HH
2201+/* Line 149 of location.cc */
2202+#line 173 "Core/QueryParser/Generated/position.hh"
2203+#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_POSITION_HH_INCLUDED */
2204
2205=== modified file 'src/Core/QueryParser/Generated/stack.hh'
2206--- src/Core/QueryParser/Generated/stack.hh 2012-04-19 12:40:05 +0000
2207+++ src/Core/QueryParser/Generated/stack.hh 2013-03-31 13:25:26 +0000
2208@@ -1,8 +1,8 @@
2209-/* A Bison parser, made by GNU Bison 2.5. */
2210+/* A Bison parser, made by GNU Bison 2.6.5. */
2211
2212 /* Stack handling for Bison parsers in C++
2213
2214- Copyright (C) 2002-2011 Free Software Foundation, Inc.
2215+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
2216
2217 This program is free software: you can redistribute it and/or modify
2218 it under the terms of the GNU General Public License as published by
2219@@ -30,23 +30,25 @@
2220 This special exception was added by the Free Software Foundation in
2221 version 2.2 of Bison. */
2222
2223-#ifndef BISON_STACK_HH
2224-# define BISON_STACK_HH
2225-
2226-#include <deque>
2227-
2228-
2229-/* Line 1149 of lalr1.cc */
2230-#line 5 "grammar.yy"
2231+/**
2232+ ** \file Core/QueryParser/Generated/stack.hh
2233+ ** Define the VerifyTAPN::stack class.
2234+ */
2235+
2236+#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_STACK_HH_INCLUDED
2237+# define YY_YY_CORE_QUERYPARSER_GENERATED_STACK_HH_INCLUDED
2238+
2239+# include <deque>
2240+
2241+/* Line 37 of stack.hh */
2242+#line 5 "Core/QueryParser/grammar.yy"
2243 namespace VerifyTAPN {
2244-
2245-/* Line 1149 of lalr1.cc */
2246-#line 45 "Generated/stack.hh"
2247+/* Line 37 of stack.hh */
2248+#line 48 "Core/QueryParser/Generated/stack.hh"
2249 template <class T, class S = std::deque<T> >
2250 class stack
2251 {
2252 public:
2253-
2254 // Hide our reversed order.
2255 typedef typename S::reverse_iterator iterator;
2256 typedef typename S::const_reverse_iterator const_iterator;
2257@@ -85,7 +87,7 @@
2258 pop (unsigned int n = 1)
2259 {
2260 for (; n; --n)
2261- seq_.pop_front ();
2262+ seq_.pop_front ();
2263 }
2264
2265 inline
2266@@ -99,7 +101,6 @@
2267 inline const_iterator end () const { return seq_.rend (); }
2268
2269 private:
2270-
2271 S seq_;
2272 };
2273
2274@@ -108,10 +109,9 @@
2275 class slice
2276 {
2277 public:
2278-
2279- slice (const S& stack,
2280- unsigned int range) : stack_ (stack),
2281- range_ (range)
2282+ slice (const S& stack, unsigned int range)
2283+ : stack_ (stack)
2284+ , range_ (range)
2285 {
2286 }
2287
2288@@ -123,17 +123,13 @@
2289 }
2290
2291 private:
2292-
2293 const S& stack_;
2294 unsigned int range_;
2295 };
2296-
2297-/* Line 1235 of lalr1.cc */
2298-#line 5 "grammar.yy"
2299+/* Line 119 of stack.hh */
2300+#line 5 "Core/QueryParser/grammar.yy"
2301 } // VerifyTAPN
2302-
2303-/* Line 1235 of lalr1.cc */
2304-#line 137 "Generated/stack.hh"
2305-
2306-#endif // not BISON_STACK_HH[]dnl
2307-
2308+/* Line 119 of stack.hh */
2309+#line 134 "Core/QueryParser/Generated/stack.hh"
2310+
2311+#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_STACK_HH_INCLUDED */
2312
2313=== modified file 'src/Core/TAPN/TimedArcPetriNet.cpp'
2314--- src/Core/TAPN/TimedArcPetriNet.cpp 2012-07-12 15:47:35 +0000
2315+++ src/Core/TAPN/TimedArcPetriNet.cpp 2013-03-31 13:25:26 +0000
2316@@ -189,6 +189,15 @@
2317 }
2318 }
2319 }
2320+
2321+ for(TimedTransition::Vector::iterator iter = transitions.begin(); iter != transitions.end(); iter++){
2322+ for(OutputArc::WeakPtrVector::const_iterator place_iter = iter->get()->GetPostset().begin(); place_iter != iter->get()->GetPostset().end(); place_iter++){
2323+ if(place_iter->lock()->OutputPlace().GetMaxConstant() > -1){
2324+ iter->get()->setUntimedPostset(false);
2325+ break;
2326+ }
2327+ }
2328+ }
2329 }
2330
2331 void TimedArcPetriNet::calculateCausality(TimedPlace& p, std::vector< TimedPlace* >* result) const
2332
2333=== modified file 'src/Core/TAPN/TimedTransition.hpp'
2334--- src/Core/TAPN/TimedTransition.hpp 2012-03-02 10:59:16 +0000
2335+++ src/Core/TAPN/TimedTransition.hpp 2013-03-31 13:25:26 +0000
2336@@ -21,8 +21,8 @@
2337 public: // typedefs
2338 typedef std::vector< boost::shared_ptr<TimedTransition> > Vector;
2339 public:
2340- TimedTransition(const std::string& name, const std::string& id) : name(name), id(id), preset(), postset(), transportArcs(), index(-1) { };
2341- TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1) { };
2342+ TimedTransition(const std::string& name, const std::string& id) : name(name), id(id), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };
2343+ TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };
2344 virtual ~TimedTransition() { /* empty */ }
2345
2346 public: // modifiers
2347@@ -46,7 +46,9 @@
2348 inline unsigned int NumberOfTransportArcs() const { return transportArcs.size(); };
2349 // bool isEnabledBy(const TimedArcPetriNet& tapn, const VerifyTAPN::SymMarking& marking) const;
2350 inline const bool isConservative() const { return preset.size() == postset.size(); }
2351- inline unsigned int GetIndex() const { return index; };
2352+ inline unsigned int GetIndex() const { return index; }
2353+ inline const bool hasUntimedPostset() const { return untimedPostset; }
2354+ inline void setUntimedPostset(bool untimed){ untimedPostset = untimed; }
2355
2356 private: // data
2357 std::string name;
2358@@ -56,6 +58,7 @@
2359 TransportArc::WeakPtrVector transportArcs;
2360 InhibitorArc::WeakPtrVector inhibitorArcs;
2361 unsigned int index;
2362+ bool untimedPostset;
2363 };
2364
2365 inline std::ostream& operator<<(std::ostream& out, const TimedTransition& transition)
2366
2367=== modified file 'src/Core/VerificationOptions.cpp'
2368--- src/Core/VerificationOptions.cpp 2012-07-09 13:19:22 +0000
2369+++ src/Core/VerificationOptions.cpp 2013-03-31 13:25:26 +0000
2370@@ -25,22 +25,31 @@
2371 }
2372 }
2373
2374- std::string FactoryEnumToString(Factory factory){
2375- switch(factory)
2376- {
2377- case OLD_FACTORY:
2378- return "old DBM";
2379- case DISCRETE_INCLUSION:
2380- return "discrete inclusion";
2381- default:
2382- return "default";
2383+ std::string VerificationTypeEnumToString(VerificationType s){
2384+ switch(s){
2385+ case TIMEDART:
2386+ return "Time darts";
2387+ default:
2388+ return "Default (discrete)";
2389+ }
2390 }
2391- }
2392-
2393-
2394+
2395+ std::string MemoryOptimizationEnumToString(MemoryOptimization m){
2396+ switch(m){
2397+ case NONE:
2398+ return "None";
2399+ case PTRIE:
2400+ return "PTrie ";
2401+ default:
2402+ return "None";
2403+ }
2404+ }
2405+
2406 std::ostream& operator<<(std::ostream& out, const VerificationOptions& options)
2407 {
2408- out << "Using " << SearchTypeEnumToString(options.GetSearchType()) << std::endl;
2409+ out << "Search type: " << SearchTypeEnumToString(options.GetSearchType()) << std::endl;
2410+ out << "Verification method: " << VerificationTypeEnumToString(options.GetVerificationType()) << std::endl;
2411+ out << "Memory optimization: " << MemoryOptimizationEnumToString(options.GetMemoryOptimization()) << std::endl;
2412 out << "k-bound is: " << options.GetKBound() << std::endl;
2413 out << "Generating " << enumToString(options.GetTrace()) << " trace";
2414 if(options.GetTrace() != NONE) out << " in " << (options.XmlTrace() ? "xml format" : "human readable format");
2415
2416=== modified file 'src/Core/VerificationOptions.hpp'
2417--- src/Core/VerificationOptions.hpp 2012-07-12 15:47:35 +0000
2418+++ src/Core/VerificationOptions.hpp 2013-03-31 13:25:26 +0000
2419@@ -8,14 +8,18 @@
2420 namespace VerifyTAPN {
2421 enum Trace { NONE, SOME };
2422 enum SearchType { BREADTHFIRST, DEPTHFIRST, RANDOM, COVERMOST };
2423- enum Factory { DEFAULT, DISCRETE_INCLUSION, OLD_FACTORY };
2424+ enum VerificationType { DISCRETE, TIMEDART };
2425+ enum MemoryOptimization { NO_MEMORY_OPTIMIZATION, PTRIE };
2426
2427 class VerificationOptions {
2428 public:
2429+ VerificationOptions(){}
2430 VerificationOptions(
2431 const std::string& inputFile,
2432 const std::string& queryFile,
2433 SearchType searchType,
2434+ VerificationType verificationType,
2435+ MemoryOptimization memOptimization,
2436 unsigned int k_bound,
2437 Trace trace,
2438 bool xml_trace,
2439@@ -24,12 +28,16 @@
2440 ) : inputFile(inputFile),
2441 queryFile(queryFile),
2442 searchType(searchType),
2443+ verificationType(verificationType),
2444+ memOptimization(memOptimization),
2445 k_bound(k_bound),
2446 trace(trace),
2447 xml_trace(xml_trace),
2448 useGlobalMaxConstants(useGlobalMaxConstants),
2449 keepDeadTokens(keepDeadTokens)
2450- { };
2451+ {
2452+
2453+ };
2454
2455 public: // inspectors
2456 const std::string GetInputFile() const { return inputFile; }
2457@@ -39,19 +47,20 @@
2458 inline const bool XmlTrace() const { return xml_trace; };
2459 inline const bool GetGlobalMaxConstantsEnabled() const { return useGlobalMaxConstants; }
2460 inline const SearchType GetSearchType() const { return searchType; }
2461+ inline const VerificationType GetVerificationType() const { return verificationType; }
2462+ inline const MemoryOptimization GetMemoryOptimization() const { return memOptimization; }
2463 inline const bool GetKeepDeadTokens() const { return keepDeadTokens; };
2464- inline Factory GetFactory() const { return DEFAULT; };
2465- inline void SetFactory(Factory f) { factory = f; };
2466 private:
2467 std::string inputFile;
2468 std::string queryFile;
2469 SearchType searchType;
2470+ VerificationType verificationType;
2471+ MemoryOptimization memOptimization;
2472 unsigned int k_bound;
2473 Trace trace;
2474 bool xml_trace;
2475 bool useGlobalMaxConstants;
2476 bool keepDeadTokens;
2477- Factory factory;
2478 };
2479
2480 std::ostream& operator<<(std::ostream& out, const VerificationOptions& options);
2481
2482=== added file 'src/DiscreteVerification/DataStructures/EncodingStructure.cpp'
2483--- src/DiscreteVerification/DataStructures/EncodingStructure.cpp 1970-01-01 00:00:00 +0000
2484+++ src/DiscreteVerification/DataStructures/EncodingStructure.cpp 2013-03-31 13:25:26 +0000
2485@@ -0,0 +1,14 @@
2486+/*
2487+ * File: Encoding.cpp
2488+ * Author: floop
2489+ *
2490+ * Created on 27. oktober 2012, 12:36
2491+ */
2492+
2493+#include "EncodingStructure.h"
2494+namespace VerifyTAPN {
2495+ namespace DiscreteVerification {
2496+
2497+
2498+ }
2499+}
2500\ No newline at end of file
2501
2502=== added file 'src/DiscreteVerification/DataStructures/EncodingStructure.h'
2503--- src/DiscreteVerification/DataStructures/EncodingStructure.h 1970-01-01 00:00:00 +0000
2504+++ src/DiscreteVerification/DataStructures/EncodingStructure.h 2013-03-31 13:25:26 +0000
2505@@ -0,0 +1,241 @@
2506+/*
2507+ * File: Encoding.h
2508+ * Author: Peter Gjøl Jense
2509+ *
2510+ * Created on 27. oktober 2012, 12:36
2511+ */
2512+
2513+#include <math.h>
2514+#include <stdio.h>
2515+#include <iostream>
2516+#include <string.h>
2517+
2518+#ifndef ENCODING_H
2519+#define ENCODING_H
2520+using namespace std;
2521+namespace VerifyTAPN {
2522+ namespace DiscreteVerification {
2523+
2524+ template<class T>
2525+ class EncodingStructure {
2526+ public:
2527+ typedef unsigned int uint;
2528+
2529+ EncodingStructure() {
2530+ };
2531+ EncodingStructure(uint size);
2532+ EncodingStructure(const EncodingStructure &other, uint offset);
2533+ EncodingStructure(const EncodingStructure &other, uint size, uint offset, uint encsize);
2534+ EncodingStructure(char* raw, uint size, uint offset, uint encsize);
2535+ EncodingStructure(char* raw, uint size){
2536+ shadow = raw;
2537+ rsize = size;
2538+ };
2539+ virtual ~EncodingStructure();
2540+
2541+ EncodingStructure Clone() {
2542+ EncodingStructure s;
2543+ s.rsize = rsize;
2544+ s.shadow = new char[rsize + sizeof (T)];
2545+ memcpy(s.shadow, shadow, rsize + sizeof (T));
2546+ return s;
2547+ }
2548+
2549+ void Copy(const EncodingStructure &other, unsigned int offset) {
2550+ memcpy(&(shadow[offset / 8]), other.shadow, other.rsize);
2551+ }
2552+
2553+ void Copy(const char* raw, unsigned int size){
2554+ shadow = new char[size + sizeof(T)];
2555+ memcpy(shadow, raw, size);
2556+ }
2557+
2558+ bool At(const uint place) const;
2559+ void Set(const uint place, const bool value) const;
2560+
2561+ void Zero() const {
2562+ memset(shadow, 0x0, rsize);
2563+ }
2564+
2565+ unsigned short int Size() const {
2566+ return rsize;
2567+ }
2568+
2569+ void Release() const {
2570+ delete[] shadow;
2571+ }
2572+
2573+ char* GetRaw() const {
2574+ return shadow;
2575+ }
2576+
2577+ void PrintEncoding() const {
2578+ for (unsigned short int i = 0; i < rsize * 8; i++)
2579+ cout << this->At(i);
2580+ cout << endl;
2581+ }
2582+
2583+ inline static uint Overhead(uint size) {
2584+ size = size % 8;
2585+ if (size == 0)
2586+ return 0;
2587+ else
2588+ return 8 - size;
2589+ }
2590+
2591+ inline void SetMetaData(T data) const {
2592+ memcpy(&(shadow[rsize]), &data, sizeof (T));
2593+ }
2594+
2595+ inline T GetMetaData() const {
2596+ T res;
2597+ memcpy(&res, &(shadow[rsize]), sizeof (T));
2598+ return res;
2599+ }
2600+
2601+ const char operator[](int i) {
2602+
2603+ if (i >= rsize) {
2604+ return 0x0;
2605+ }
2606+ return shadow[i];
2607+ }
2608+
2609+ friend bool operator==(const EncodingStructure &enc1, const EncodingStructure &enc2) {
2610+ if(enc1.rsize != enc2.rsize)
2611+ return false;
2612+ for(int i = 0; i < enc1.rsize; i++)
2613+ if(enc1.shadow[i] != enc2.shadow[i])
2614+ return false;
2615+ return true;
2616+ }
2617+
2618+
2619+ friend bool operator<(const EncodingStructure &enc1, const EncodingStructure &enc2) {
2620+ int count = enc1.rsize > enc2.rsize ? enc1.rsize : enc2.rsize;
2621+
2622+ for (int i = 0; i < count; i++) {
2623+ if (enc1.rsize > i && enc2.rsize > i && enc1.shadow[i] != enc2.shadow[i]) {
2624+ return ((unsigned short int) enc1.shadow[i]) < ((unsigned short int) enc2.shadow[i]);
2625+ }
2626+
2627+ }
2628+ if (enc1.rsize > enc2.rsize) {
2629+ return false;
2630+
2631+ } else if (enc1.rsize < enc2.rsize) {
2632+ return true;
2633+ }
2634+
2635+ return false;
2636+ }
2637+
2638+ private:
2639+ char* shadow;
2640+ unsigned short rsize;
2641+ const static char masks[8];
2642+ };
2643+
2644+ template<class T>
2645+ const char EncodingStructure<T>::masks[8] = {
2646+ 0x01,
2647+ 0x02,
2648+ 0x04,
2649+ 0x08,
2650+ 0x10,
2651+ 0x20,
2652+ 0x40,
2653+ 0x80
2654+ };
2655+
2656+ template<class T>
2657+ EncodingStructure<T>::EncodingStructure(uint size) {
2658+ rsize = (size + Overhead(size)) / 8;
2659+ shadow = new char[rsize + sizeof (T)];
2660+ memset(shadow, 0x0, rsize + sizeof (T));
2661+ }
2662+
2663+ template<class T>
2664+ EncodingStructure<T>::EncodingStructure(const EncodingStructure &other, uint offset) {
2665+ offset = offset / 8;
2666+
2667+ rsize = other.rsize;
2668+ if (rsize > offset)
2669+ rsize -= offset;
2670+ else {
2671+ rsize = 0;
2672+ }
2673+
2674+ shadow = new char[rsize + sizeof (T)];
2675+ memcpy(shadow, &(other.shadow[offset]), rsize);
2676+ SetMetaData(other.GetMetaData());
2677+ }
2678+
2679+ template<class T>
2680+ EncodingStructure<T>::EncodingStructure(const EncodingStructure &other, uint size, uint offset, uint encsize) {
2681+
2682+ uint so = size + offset;
2683+ offset = ((so - 1) / 8) - ((size - 1) / 8);
2684+
2685+ rsize = ((encsize + this->Overhead(encsize)) / 8);
2686+ if (rsize > offset)
2687+ rsize -= offset;
2688+ else {
2689+ rsize = 0;
2690+ }
2691+
2692+ shadow = new char[rsize + sizeof (T)];
2693+ memcpy(shadow, &(other.shadow[offset]), rsize);
2694+ SetMetaData(other.GetMetaData());
2695+ }
2696+
2697+ template<class T>
2698+ EncodingStructure<T>::EncodingStructure(char* raw, uint size, uint offset, uint encsize) {
2699+
2700+ uint so = size + offset;
2701+ offset = ((so - 1) / 8) - ((size - 1) / 8);
2702+
2703+ rsize = ((encsize + this->Overhead(encsize)) / 8);
2704+ if (rsize > offset)
2705+ rsize -= offset;
2706+ else {
2707+ rsize = 0;
2708+ }
2709+
2710+ shadow = &(raw[offset]);
2711+ }
2712+
2713+ template<class T>
2714+ EncodingStructure<T>::~EncodingStructure() {
2715+
2716+ }
2717+
2718+ template<class T>
2719+ bool EncodingStructure<T>::At(const uint place) const {
2720+ // return data[place];
2721+ uint offset = place % 8;
2722+ bool res2;
2723+ if (place / 8 < rsize)
2724+ res2 = (shadow[place / 8] & masks[offset]) != 0;
2725+ else
2726+ res2 = false;
2727+
2728+ return res2;
2729+ }
2730+
2731+ template<class T>
2732+ void EncodingStructure<T>::Set(const uint place, const bool value) const {
2733+ uint offset = place % 8;
2734+ uint theplace = place / 8;
2735+ if (value) {
2736+ shadow[theplace] |= masks[offset];
2737+ } else {
2738+ shadow[theplace] &= ~masks[offset];
2739+ }
2740+
2741+ }
2742+
2743+ }
2744+}
2745+#endif /* ENCODING_H */
2746+
2747
2748=== modified file 'src/DiscreteVerification/DataStructures/NonStrictMarking.cpp'
2749--- src/DiscreteVerification/DataStructures/NonStrictMarking.cpp 2012-07-13 17:50:33 +0000
2750+++ src/DiscreteVerification/DataStructures/NonStrictMarking.cpp 2013-03-31 13:25:26 +0000
2751@@ -11,245 +11,5 @@
2752
2753 namespace VerifyTAPN {
2754 namespace DiscreteVerification {
2755-
2756-NonStrictMarking::NonStrictMarking() : inTrace(false), children(0), passed(false){
2757- // TODO Auto-generated constructor stub
2758-
2759-}
2760-
2761-NonStrictMarking::NonStrictMarking(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v) : inTrace(false), children(0), passed(false){
2762- int prevPlaceId = -1;
2763- for(std::vector<int>::const_iterator iter = v.begin(); iter != v.end(); iter++){
2764- if(*iter == prevPlaceId){
2765- Place& p = places.back();
2766- if(p.tokens.size() == 0){
2767- Token t(0,1);
2768- p.tokens.push_back(t);
2769- }else{
2770- p.tokens.begin()->add(1);
2771- }
2772- }else{
2773-
2774- Place p(&tapn.GetPlace(*iter));
2775- Token t(0,1);
2776- p.tokens.push_back(t);
2777- places.push_back(p);
2778- }
2779- prevPlaceId = *iter;
2780- }
2781-}
2782-
2783-NonStrictMarking::NonStrictMarking(const NonStrictMarking& nsm) : inTrace(false), children(0), passed(false){
2784- for(PlaceList::const_iterator it = nsm.places.begin(); it != nsm.places.end(); it++){
2785- places.push_back(Place(*it));
2786- }
2787-
2788- parent = nsm.parent;
2789- generatedBy = nsm.generatedBy;
2790-}
2791-
2792-unsigned int NonStrictMarking::size(){
2793- int count = 0;
2794- for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
2795- for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
2796- count += it->getCount();
2797- }
2798- }
2799- return count;
2800-}
2801-
2802-//int NonStrictMarking::NumberOfTokensInPlace(const Place& place) const{
2803-// int count = 0;
2804-// for(TokenList::const_iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
2805-// count = count + it->getCount();
2806-// }
2807-// return count;
2808-//}
2809-
2810-int NonStrictMarking::NumberOfTokensInPlace(int placeId) const{
2811- int count = 0;
2812- for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
2813- if(iter->place->GetIndex() == placeId){
2814- for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
2815- count = count + it->getCount();
2816- }
2817- }
2818- }
2819- return count;
2820-}
2821-
2822-const TokenList& NonStrictMarking::GetTokenList(int placeId){
2823- for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
2824- if(iter->place->GetIndex() == placeId) return iter->tokens;
2825- }
2826- return emptyTokenList;
2827-}
2828-
2829-bool NonStrictMarking::RemoveToken(int placeId, int age){
2830- for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
2831- if(pit->place->GetIndex() == placeId){
2832- for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
2833- if(tit->getAge() == age){
2834- return RemoveToken(*pit, *tit);
2835- }
2836- }
2837- }
2838- }
2839- return false;
2840-}
2841-
2842-void NonStrictMarking::RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end){
2843- place.tokens.erase(begin, end);
2844-}
2845-
2846-bool NonStrictMarking::RemoveToken(Place& place, Token& token){
2847- if(token.getCount() > 1){
2848- token.remove(1);
2849- return true;
2850- }else{
2851- for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
2852- if(iter->getAge() == token.getAge()){
2853- place.tokens.erase(iter);
2854- if(place.tokens.empty()){
2855- for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
2856- if(it->place->GetIndex() == place.place->GetIndex()){
2857- places.erase(it);
2858- return true;
2859- }
2860- }
2861- }
2862- return true;
2863- }
2864- }
2865- }
2866- return false;
2867-}
2868-
2869-void NonStrictMarking::AddTokenInPlace(TAPN::TimedPlace& place, int age){
2870- for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
2871- if(pit->place->GetIndex() == place.GetIndex()){
2872- for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
2873- if(tit->getAge() == age){
2874- Token t(age, 1);
2875- AddTokenInPlace(*pit, t);
2876- return;
2877- }
2878- }
2879- Token t(age,1);
2880- AddTokenInPlace(*pit, t);
2881- return;
2882- }
2883- }
2884- Token t(age,1);
2885- Place p(&place);
2886- AddTokenInPlace(p,t);
2887-
2888- // Insert place
2889- bool inserted = false;
2890- for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
2891- if(it->place->GetIndex() > place.GetIndex()){
2892- places.insert(it, p);
2893- inserted = true;
2894- break;
2895- }
2896- }
2897- if(!inserted){
2898- places.push_back(p);
2899- }
2900-}
2901-
2902-void NonStrictMarking::AddTokenInPlace(TAPN::TimedPlace& place, Token& token){
2903- for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
2904- if(pit->place->GetIndex() == place.GetIndex()){
2905- AddTokenInPlace(*pit, token);
2906- return;
2907- }
2908- }
2909-
2910- Place p(&place);
2911- AddTokenInPlace(p,token);
2912-
2913- // Insert place
2914- bool inserted = false;
2915- for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
2916- if(it->place->GetIndex() > place.GetIndex()){
2917- places.insert(it, p);
2918- inserted = true;
2919- break;
2920- }
2921- }
2922- if(!inserted){
2923- places.push_back(p);
2924- }
2925-}
2926-
2927-void NonStrictMarking::AddTokenInPlace(Place& place, Token& token){
2928- if(token.getCount() == 0) return;
2929- for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
2930- if(iter->getAge() == token.getAge()){
2931- iter->add(token.getCount());
2932- return;
2933- }
2934- }
2935- // Insert token
2936- bool inserted = false;
2937- for(TokenList::iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
2938- if(it->getAge() > token.getAge()){
2939- place.tokens.insert(it, token);
2940- inserted = true;
2941- break;
2942- }
2943- }
2944- if(!inserted){
2945- place.tokens.push_back(token);
2946- }
2947-}
2948-
2949-void NonStrictMarking::incrementAge(){
2950- for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
2951- iter->incrementAge();
2952- }
2953-}
2954-void NonStrictMarking::decrementAge(){
2955- for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
2956- iter->decrementAge();
2957- }
2958-}
2959-
2960-NonStrictMarking::~NonStrictMarking() {
2961- // TODO: Should we destruct something here? (places)
2962-}
2963-
2964-bool NonStrictMarking::equals(const NonStrictMarking &m1) const{
2965- if(m1.places.size() != places.size()) return false;
2966-
2967- PlaceList::const_iterator p_iter = m1.places.begin();
2968- for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++, p_iter++){
2969- if(iter->place->GetIndex() != p_iter->place->GetIndex()) return false;
2970- if(iter->tokens.size() != p_iter->tokens.size()) return false;
2971- TokenList::const_iterator pt_iter = p_iter->tokens.begin();
2972- for(TokenList::const_iterator t_iter = iter->tokens.begin(); t_iter != iter->tokens.end(); t_iter++, pt_iter++){
2973- if(!t_iter->equals(*pt_iter)) return false;
2974- }
2975- }
2976-
2977- return true;
2978-}
2979-
2980-std::ostream& operator<<(std::ostream& out, NonStrictMarking& x ) {
2981- out << "-";
2982- for(PlaceList::iterator iter = x.places.begin(); iter != x.places.end(); iter++){
2983- out << "place " << iter->place->GetId() << " has tokens (age, count): ";
2984- for(TokenList::iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
2985- out << "(" << it->getAge() << ", " << it->getCount() << ") ";
2986- }
2987- if(iter != x.places.end()-1){
2988- out << endl;
2989- }
2990- }
2991-
2992- return out;
2993-}
2994-
2995 } /* namespace DiscreteVerification */
2996 } /* namespace VerifyTAPN */
2997
2998=== modified file 'src/DiscreteVerification/DataStructures/NonStrictMarking.hpp'
2999--- src/DiscreteVerification/DataStructures/NonStrictMarking.hpp 2012-09-10 18:54:32 +0000
3000+++ src/DiscreteVerification/DataStructures/NonStrictMarking.hpp 2013-03-31 13:25:26 +0000
3001@@ -11,171 +11,49 @@
3002 #include <assert.h>
3003 #include <vector>
3004 #include "boost/functional/hash.hpp"
3005-#include "NonStrictMarking.hpp"
3006+#include "NonStrictMarkingBase.hpp"
3007 #include <iostream>
3008 #include "../../Core/TAPN/TAPN.hpp"
3009-#include <iostream>
3010
3011 using namespace std;
3012
3013 namespace VerifyTAPN {
3014 namespace DiscreteVerification {
3015-
3016-class Place;
3017-class Token;
3018-typedef vector<Token> TokenList;
3019-
3020-class Token {
3021-private:
3022- int age;
3023- int count;
3024-public:
3025- Token(int age, int count) : age(age), count(count) { };
3026- Token(const Token& t) : age(t.age), count(t.count) { };
3027-
3028- bool equals(const Token &t) const { return (this->age == t.age && this->count == t.count); };
3029-
3030- void add(int num){ count = count + num; };
3031- int getCount() const { return count; };
3032- int getAge() const { return age; };
3033- void setAge(int i) { age = i; };
3034- void setCount(int i) { count = i; };
3035- void remove(int num){ count = count - num; };
3036-
3037- // Ages all tokens by 1
3038- inline void incrementAge(){
3039- age++;
3040- }
3041- inline void decrementAge(){
3042- age--;
3043- }
3044-
3045- friend std::size_t hash_value(Token const& t)
3046- {
3047- size_t seed = 0;
3048- boost::hash_combine(seed, t.getAge());
3049- boost::hash_combine(seed, t.getCount());
3050- return seed;
3051- }
3052-};
3053-
3054-class Place {
3055-public:
3056- const TAPN::TimedPlace* place;
3057- TokenList tokens;
3058-
3059- Place(const TAPN::TimedPlace* place) : place(place){};
3060- Place(const Place& p) : place(p.place){
3061- for(TokenList::const_iterator it = p.tokens.begin(); it != p.tokens.end(); it++){
3062- tokens.push_back(*it);
3063- }
3064- };
3065-
3066- friend std::size_t hash_value(Place const& p)
3067- {
3068- std::size_t seed = boost::hash_range(p.tokens.begin(), p.tokens.end());
3069- boost::hash_combine(seed, p.place->GetIndex());
3070-
3071- return seed;
3072- }
3073-
3074- int NumberOfTokens() const{
3075- int count = 0;
3076- for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3077- count += iter->getCount();
3078- }
3079- return count;
3080- }
3081-
3082- int MaxTokenAge() const{
3083- int max = -1;
3084- for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3085- if(iter->getAge() > max) max = iter->getAge();
3086- }
3087- return max;
3088- }
3089-
3090- // Ages all tokens by 1
3091- void incrementAge(){
3092- for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3093- iter->incrementAge();
3094- }
3095- }
3096-
3097- void decrementAge(){
3098- for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3099- iter->decrementAge();
3100- }
3101- }
3102-};
3103-
3104-typedef vector<Place> PlaceList;
3105-
3106-class NonStrictMarking {
3107-public:
3108- NonStrictMarking();
3109- NonStrictMarking(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v);
3110- NonStrictMarking(const NonStrictMarking& nsm);
3111-
3112-public:
3113- friend std::ostream& operator<<(std::ostream& out, NonStrictMarking& x );
3114- friend class DiscreteVerification;
3115-
3116- virtual ~NonStrictMarking();
3117-
3118- virtual size_t HashKey() const { return boost::hash_range(places.begin(), places.end()); };
3119-
3120- virtual NonStrictMarking& Clone()
3121- {
3122- NonStrictMarking* clone = new NonStrictMarking(*this);
3123- return *clone;
3124- };
3125-
3126- public: // inspectors
3127- //int NumberOfTokensInPlace(const Place& palce) const;
3128- int NumberOfTokensInPlace(int placeId) const;
3129- const TokenList& GetTokenList(int placeId);
3130- const PlaceList& GetPlaceList() const{ return places; }
3131- unsigned int size();
3132- const NonStrictMarking* GetParent() const { return parent; }
3133- const TAPN::TimedTransition* GetGeneratedBy() const { return generatedBy; }
3134-
3135-
3136- public: // modifiers
3137- bool RemoveToken(int placeId, int age);
3138- bool RemoveToken(Place& place, Token& token);
3139- void AddTokenInPlace(TAPN::TimedPlace& place, int age);
3140- void AddTokenInPlace(Place& place, Token& token);
3141- void AddTokenInPlace(TAPN::TimedPlace& place, Token& token);
3142- void incrementAge(); // increment
3143- void decrementAge(); // decrement
3144- void RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end);
3145- void SetParent(NonStrictMarking* parent) { this->parent = parent; }
3146- void SetGeneratedBy(const TAPN::TimedTransition* generatedBy) { this->generatedBy = generatedBy; }
3147- void CleanUp() {
3148- for(unsigned int i = 0; i < places.size(); i++){
3149- if(places[i].tokens.empty()){
3150- places.erase(places.begin()+i);
3151- }
3152- }
3153- }
3154-
3155- public:
3156- bool equals(const NonStrictMarking &m1) const;
3157-
3158- public:
3159- bool inTrace;
3160- int children;
3161- bool passed;
3162- PlaceList places;
3163- TokenList emptyTokenList;
3164-
3165- public:
3166- NonStrictMarking* parent;
3167- const TAPN::TimedTransition* generatedBy;
3168-};
3169-
3170-std::ostream& operator<<(std::ostream& out, NonStrictMarking& x);
3171+
3172+ struct MetaData {
3173+ public:
3174+ MetaData() : passed(false), inTrace(false) {};
3175+ bool passed;
3176+ bool inTrace;
3177+ };
3178+
3179+ struct MetaDataWithTrace : public MetaData {
3180+ const TAPN::TimedTransition* generatedBy;
3181+ };
3182+
3183+ // ugly forward declaration
3184+ template<class MetaData>
3185+ class EncodingPointer;
3186+
3187+ struct MetaDataWithTraceAndEncoding : public MetaDataWithTrace {
3188+ EncodingPointer<MetaData>* ep;
3189+ MetaDataWithTraceAndEncoding* parent;
3190+ };
3191+
3192+ class NonStrictMarking : public NonStrictMarkingBase{
3193+ public:
3194+ NonStrictMarking():NonStrictMarkingBase(), meta(new MetaData()){}
3195+ NonStrictMarking(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v):NonStrictMarkingBase(tapn, v){}
3196+ NonStrictMarking(const NonStrictMarkingBase& nsm):NonStrictMarkingBase(nsm){
3197+
3198+ }
3199+ NonStrictMarking(const NonStrictMarking& nsm):NonStrictMarkingBase(nsm){
3200+
3201+ }
3202+ public:
3203+ MetaData* meta;
3204+ };
3205+
3206
3207 } /* namespace DiscreteVerification */
3208 } /* namespace VerifyTAPN */
3209
3210=== added file 'src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp'
3211--- src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp 1970-01-01 00:00:00 +0000
3212+++ src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp 2013-03-31 13:25:26 +0000
3213@@ -0,0 +1,339 @@
3214+/*
3215+ * NonStrictMarkingBase.cpp
3216+ *
3217+ * Created on: 29/02/2012
3218+ * Author: MathiasGS
3219+ */
3220+
3221+#include "NonStrictMarkingBase.hpp"
3222+
3223+using namespace std;
3224+
3225+namespace VerifyTAPN {
3226+namespace DiscreteVerification {
3227+
3228+NonStrictMarkingBase::NonStrictMarkingBase() : children(0), generatedBy(NULL){
3229+ // TODO Auto-generated constructor stub
3230+
3231+}
3232+
3233+NonStrictMarkingBase::NonStrictMarkingBase(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v) :children(0), generatedBy(NULL){
3234+ int prevPlaceId = -1;
3235+ for(std::vector<int>::const_iterator iter = v.begin(); iter != v.end(); iter++){
3236+ if(*iter == prevPlaceId){
3237+ Place& p = places.back();
3238+ if(p.tokens.size() == 0){
3239+ Token t(0,1);
3240+ p.tokens.push_back(t);
3241+ }else{
3242+ p.tokens.begin()->add(1);
3243+ }
3244+ }else{
3245+
3246+ Place p(&tapn.GetPlace(*iter));
3247+ Token t(0,1);
3248+ p.tokens.push_back(t);
3249+ places.push_back(p);
3250+ }
3251+ prevPlaceId = *iter;
3252+ }
3253+}
3254+
3255+NonStrictMarkingBase::NonStrictMarkingBase(const NonStrictMarkingBase& nsm) : children(0), generatedBy(NULL){
3256+ //for(PlaceList::const_iterator it = nsm.places.begin(); it != nsm.places.end(); it++){
3257+ // places.push_back(Place(*it));
3258+ //}
3259+
3260+ places = nsm.places;
3261+
3262+ parent = nsm.parent;
3263+ generatedBy = nsm.generatedBy;
3264+}
3265+
3266+unsigned int NonStrictMarkingBase::size(){
3267+ int count = 0;
3268+ for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
3269+ for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
3270+ count += it->getCount();
3271+ }
3272+ }
3273+ return count;
3274+}
3275+
3276+//int NonStrictMarkingBase::NumberOfTokensInPlace(const Place& place) const{
3277+// int count = 0;
3278+// for(TokenList::const_iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
3279+// count = count + it->getCount();
3280+// }
3281+// return count;
3282+//}
3283+
3284+int NonStrictMarkingBase::NumberOfTokensInPlace(int placeId) const{
3285+ int count = 0;
3286+ for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
3287+ if(iter->place->GetIndex() == placeId){
3288+ for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
3289+ count = count + it->getCount();
3290+ }
3291+ }
3292+ }
3293+ return count;
3294+}
3295+
3296+const TokenList& NonStrictMarkingBase::GetTokenList(int placeId) const{
3297+ for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
3298+ if(iter->place->GetIndex() == placeId) return iter->tokens;
3299+ }
3300+ return emptyTokenList;
3301+}
3302+
3303+bool NonStrictMarkingBase::RemoveToken(int placeId, int age){
3304+ for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
3305+ if(pit->place->GetIndex() == placeId){
3306+ for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
3307+ if(tit->getAge() == age){
3308+ return RemoveToken(*pit, *tit);
3309+ }
3310+ }
3311+ }
3312+ }
3313+ return false;
3314+}
3315+
3316+void NonStrictMarkingBase::RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end){
3317+ place.tokens.erase(begin, end);
3318+}
3319+
3320+bool NonStrictMarkingBase::RemoveToken(Place& place, Token& token){
3321+ if(token.getCount() > 1){
3322+ token.remove(1);
3323+ return true;
3324+ }else{
3325+ for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
3326+ if(iter->getAge() == token.getAge()){
3327+ place.tokens.erase(iter);
3328+ if(place.tokens.empty()){
3329+ for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
3330+ if(it->place->GetIndex() == place.place->GetIndex()){
3331+ places.erase(it);
3332+ return true;
3333+ }
3334+ }
3335+ }
3336+ return true;
3337+ }
3338+ }
3339+ }
3340+ return false;
3341+}
3342+
3343+void NonStrictMarkingBase::AddTokenInPlace(TAPN::TimedPlace& place, int age){
3344+ for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
3345+ if(pit->place->GetIndex() == place.GetIndex()){
3346+ for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
3347+ if(tit->getAge() == age){
3348+ Token t(age, 1);
3349+ AddTokenInPlace(*pit, t);
3350+ return;
3351+ }
3352+ }
3353+ Token t(age,1);
3354+ AddTokenInPlace(*pit, t);
3355+ return;
3356+ }
3357+ }
3358+ Token t(age,1);
3359+ Place p(&place);
3360+ AddTokenInPlace(p,t);
3361+
3362+ // Insert place
3363+ bool inserted = false;
3364+ for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
3365+ if(it->place->GetIndex() > place.GetIndex()){
3366+ places.insert(it, p);
3367+ inserted = true;
3368+ break;
3369+ }
3370+ }
3371+ if(!inserted){
3372+ places.push_back(p);
3373+ }
3374+}
3375+
3376+void NonStrictMarkingBase::AddTokenInPlace(const TAPN::TimedPlace& place, Token& token){
3377+ for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
3378+ if(pit->place->GetIndex() == place.GetIndex()){
3379+ AddTokenInPlace(*pit, token);
3380+ return;
3381+ }
3382+ }
3383+
3384+ Place p(&place);
3385+ AddTokenInPlace(p,token);
3386+
3387+ // Insert place
3388+ bool inserted = false;
3389+ for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
3390+ if(it->place->GetIndex() > place.GetIndex()){
3391+ places.insert(it, p);
3392+ inserted = true;
3393+ break;
3394+ }
3395+ }
3396+ if(!inserted){
3397+ places.push_back(p);
3398+ }
3399+}
3400+
3401+void NonStrictMarkingBase::AddTokenInPlace(Place& place, Token& token){
3402+ if(token.getCount() == 0) return;
3403+ for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
3404+ if(iter->getAge() == token.getAge()){
3405+ iter->add(token.getCount());
3406+ return;
3407+ }
3408+ }
3409+ // Insert token
3410+ bool inserted = false;
3411+ for(TokenList::iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
3412+ if(it->getAge() > token.getAge()){
3413+ place.tokens.insert(it, token);
3414+ inserted = true;
3415+ break;
3416+ }
3417+ }
3418+ if(!inserted){
3419+ place.tokens.push_back(token);
3420+ }
3421+}
3422+
3423+void NonStrictMarkingBase::incrementAge(){
3424+ for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
3425+ iter->incrementAge();
3426+ }
3427+}
3428+
3429+void NonStrictMarkingBase::incrementAge(int age){
3430+ for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
3431+ iter->incrementAge(age);
3432+ }
3433+}
3434+
3435+void NonStrictMarkingBase::decrementAge(){
3436+ for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
3437+ iter->decrementAge();
3438+ }
3439+}
3440+
3441+NonStrictMarkingBase::~NonStrictMarkingBase() { }
3442+
3443+bool NonStrictMarkingBase::equals(const NonStrictMarkingBase &m1) const{
3444+ if(m1.places.size() != places.size()) return false;
3445+
3446+ PlaceList::const_iterator p_iter = m1.places.begin();
3447+ for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++, p_iter++){
3448+ if(iter->place->GetIndex() != p_iter->place->GetIndex()) return false;
3449+ if(iter->tokens.size() != p_iter->tokens.size()) return false;
3450+ TokenList::const_iterator pt_iter = p_iter->tokens.begin();
3451+ for(TokenList::const_iterator t_iter = iter->tokens.begin(); t_iter != iter->tokens.end(); t_iter++, pt_iter++){
3452+ if(!t_iter->equals(*pt_iter)) return false;
3453+ }
3454+ }
3455+
3456+ return true;
3457+}
3458+
3459+std::ostream& operator<<(std::ostream& out, NonStrictMarkingBase& x ) {
3460+ out << "-";
3461+ for(PlaceList::iterator iter = x.places.begin(); iter != x.places.end(); iter++){
3462+ out << "place " << iter->place->GetId() << " has tokens (age, count): ";
3463+ for(TokenList::iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
3464+ out << "(" << it->getAge() << ", " << it->getCount() << ") ";
3465+ }
3466+ if(iter != x.places.end()-1){
3467+ out << endl;
3468+ }
3469+ }
3470+
3471+ return out;
3472+}
3473+
3474+void NonStrictMarkingBase::cut(){
3475+#ifdef DEBUG
3476+ std::cout << "Before cut: " << *this << std::endl;
3477+#endif
3478+ for(PlaceList::iterator place_iter = this->places.begin(); place_iter != this->places.end(); place_iter++){
3479+ //remove dead tokens
3480+ if (place_iter->place->GetType() == TAPN::Dead) {
3481+ for(TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++){
3482+ if(token_iter->getAge() > place_iter->place->GetMaxConstant()){
3483+ token_iter->remove(token_iter->getCount());
3484+ }
3485+ }
3486+ }
3487+ //set age of too old tokens to max age
3488+ int count = 0;
3489+ for(TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++){
3490+ if(token_iter->getAge() > place_iter->place->GetMaxConstant()){
3491+ TokenList::iterator beginDelete = token_iter;
3492+ if(place_iter->place->GetType() == TAPN::Std){
3493+ for(; token_iter != place_iter->tokens.end(); token_iter++){
3494+ count += token_iter->getCount();
3495+ }
3496+ }
3497+ this->RemoveRangeOfTokens(*place_iter, beginDelete, place_iter->tokens.end());
3498+ break;
3499+ }
3500+ }
3501+ Token t(place_iter->place->GetMaxConstant()+1,count);
3502+ this->AddTokenInPlace(*place_iter, t);
3503+ }
3504+ this->CleanUp();
3505+ #ifdef DEBUG
3506+ std::cout << "After cut: " << *this << std::endl;
3507+ #endif
3508+}
3509+
3510+int NonStrictMarkingBase::getYoungest(){
3511+ int youngest = INT_MAX;
3512+ for(PlaceList::const_iterator place_iter = GetPlaceList().begin(); place_iter != GetPlaceList().end(); place_iter++){
3513+ if(youngest > place_iter->tokens.front().getAge() && place_iter->tokens.front().getAge() <= place_iter->place->GetMaxConstant()){
3514+ youngest = place_iter->tokens.front().getAge();
3515+ }
3516+ }
3517+
3518+ if(youngest == INT_MAX){
3519+ youngest = 0;
3520+ }
3521+ return youngest;
3522+}
3523+
3524+int NonStrictMarkingBase::makeBase(TAPN::TimedArcPetriNet* tapn){
3525+ #ifdef DEBUG
3526+ std::cout << "Before makeBase: " << *this << std::endl;
3527+ #endif
3528+ int youngest = getYoungest();
3529+
3530+ for(PlaceList::iterator place_iter = places.begin(); place_iter != places.end(); place_iter++){
3531+ for(TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++){
3532+ if(token_iter->getAge() != place_iter->place->GetMaxConstant() + 1){
3533+ token_iter->setAge(token_iter->getAge()-youngest);
3534+ }
3535+#ifdef DEBUG
3536+ else if(token_iter->getAge() > place_iter->place->GetMaxConstant() + 1){
3537+ assert(false);
3538+ }
3539+#endif
3540+ }
3541+ }
3542+
3543+ #ifdef DEBUG
3544+ std::cout << "After makeBase: " << *this << std::endl;
3545+ std::cout << "Youngest: " << youngest << std::endl;
3546+ #endif
3547+
3548+ return youngest;
3549+}
3550+
3551+} /* namespace DiscreteVerification */
3552+} /* namespace VerifyTAPN */
3553
3554=== added file 'src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp'
3555--- src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp 1970-01-01 00:00:00 +0000
3556+++ src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp 2013-03-31 13:25:26 +0000
3557@@ -0,0 +1,196 @@
3558+/*
3559+ * NonStrictMarkingBase.hpp
3560+ *
3561+ * Created on: 29/02/2012
3562+ * Author: MathiasGS
3563+ */
3564+
3565+#ifndef NonStrictMarkingBase_HPP_
3566+#define NonStrictMarkingBase_HPP_
3567+
3568+#include <assert.h>
3569+#include <vector>
3570+#include "boost/functional/hash.hpp"
3571+#include <iostream>
3572+#include "../../Core/TAPN/TAPN.hpp"
3573+#include <iostream>
3574+
3575+using namespace std;
3576+
3577+namespace VerifyTAPN {
3578+namespace DiscreteVerification {
3579+
3580+class Place;
3581+class Token;
3582+typedef vector<Token> TokenList;
3583+
3584+class Token {
3585+private:
3586+ int age;
3587+ int count;
3588+public:
3589+ Token(int age, int count) : age(age), count(count) { };
3590+ Token(const Token& t) : age(t.age), count(t.count) { };
3591+
3592+ bool equals(const Token &t) const { return (this->age == t.age && this->count == t.count); };
3593+
3594+ void add(int num){ count = count + num; };
3595+ int getCount() const { return count; };
3596+ int getAge() const { return age; };
3597+ void setAge(int i) { age = i; };
3598+ void setCount(int i) { count = i; };
3599+ void remove(int num){ count = count - num; };
3600+
3601+ // Ages all tokens by 1
3602+ inline void incrementAge(){
3603+ age++;
3604+ }
3605+
3606+ inline void incrementAge(int x){
3607+ age += x;
3608+ }
3609+
3610+ inline void decrementAge(){
3611+ age--;
3612+ }
3613+
3614+ friend std::size_t hash_value(Token const& t)
3615+ {
3616+ size_t seed = 0;
3617+ boost::hash_combine(seed, t.getAge());
3618+ boost::hash_combine(seed, t.getCount());
3619+ return seed;
3620+ }
3621+};
3622+
3623+class Place {
3624+public:
3625+ const TAPN::TimedPlace* place;
3626+ TokenList tokens;
3627+
3628+ Place(const TAPN::TimedPlace* place) : place(place){};
3629+ Place(const Place& p) : place(p.place){
3630+ for(TokenList::const_iterator it = p.tokens.begin(); it != p.tokens.end(); it++){
3631+ tokens.push_back(*it);
3632+ }
3633+ };
3634+
3635+ friend std::size_t hash_value(Place const& p)
3636+ {
3637+ std::size_t seed = boost::hash_range(p.tokens.begin(), p.tokens.end());
3638+ boost::hash_combine(seed, p.place->GetIndex());
3639+
3640+ return seed;
3641+ }
3642+
3643+ int NumberOfTokens() const{
3644+ int count = 0;
3645+ for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3646+ count += iter->getCount();
3647+ }
3648+ return count;
3649+ }
3650+
3651+ int MaxTokenAge() const{
3652+ int max = -1;
3653+ for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3654+ if(iter->getAge() > max) max = iter->getAge();
3655+ }
3656+ return max;
3657+ }
3658+
3659+ // Ages all tokens by 1
3660+ void incrementAge(){
3661+ for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3662+ iter->incrementAge();
3663+ }
3664+ }
3665+
3666+ void incrementAge(int age){
3667+ for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3668+ iter->incrementAge(age);
3669+ }
3670+ }
3671+
3672+ void decrementAge(){
3673+ for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
3674+ iter->decrementAge();
3675+ }
3676+ }
3677+};
3678+
3679+typedef vector<Place> PlaceList;
3680+
3681+class NonStrictMarkingBase {
3682+public:
3683+ NonStrictMarkingBase();
3684+ NonStrictMarkingBase(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v);
3685+ NonStrictMarkingBase(const NonStrictMarkingBase& nsm);
3686+
3687+public:
3688+ friend std::ostream& operator<<(std::ostream& out, NonStrictMarkingBase& x );
3689+ friend class DiscreteVerification;
3690+
3691+ virtual ~NonStrictMarkingBase();
3692+
3693+ virtual size_t HashKey() const { return boost::hash_range(places.begin(), places.end()); };
3694+
3695+ virtual NonStrictMarkingBase& Clone()
3696+ {
3697+ NonStrictMarkingBase* clone = new NonStrictMarkingBase(*this);
3698+ return *clone;
3699+ };
3700+
3701+ public: // inspectors
3702+ //int NumberOfTokensInPlace(const Place& palce) const;
3703+ int NumberOfTokensInPlace(int placeId) const;
3704+ const TokenList& GetTokenList(int placeId) const;
3705+ const PlaceList& GetPlaceList() const{ return places; }
3706+ unsigned int size();
3707+ const NonStrictMarkingBase* GetParent() const { return parent; }
3708+ const TAPN::TimedTransition* GetGeneratedBy() const { return generatedBy; }
3709+
3710+
3711+ public: // modifiers
3712+ void cut();
3713+ bool RemoveToken(int placeId, int age);
3714+ bool RemoveToken(Place& place, Token& token);
3715+ void AddTokenInPlace(TAPN::TimedPlace& place, int age);
3716+ void AddTokenInPlace(Place& place, Token& token);
3717+ void AddTokenInPlace(const TAPN::TimedPlace& place, Token& token);
3718+ void incrementAge(); // increment
3719+ void incrementAge(int age);
3720+ void decrementAge(); // decrement
3721+ void RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end);
3722+ void SetParent(NonStrictMarkingBase* parent) { this->parent = parent; }
3723+ void SetGeneratedBy(const TAPN::TimedTransition* generatedBy) { this->generatedBy = generatedBy; }
3724+ void CleanUp() {
3725+ for(unsigned int i = 0; i < places.size(); i++){
3726+ if(places[i].tokens.empty()){
3727+ places.erase(places.begin()+i);
3728+ i--;
3729+ }
3730+ }
3731+ }
3732+ int getYoungest();
3733+ int makeBase(TAPN::TimedArcPetriNet* tapn);
3734+
3735+ public:
3736+ bool equals(const NonStrictMarkingBase &m1) const;
3737+
3738+ public:
3739+ int children;
3740+ PlaceList places;
3741+ TokenList emptyTokenList;
3742+
3743+ public:
3744+ NonStrictMarkingBase* parent;
3745+ const TAPN::TimedTransition* generatedBy;
3746+};
3747+
3748+std::ostream& operator<<(std::ostream& out, NonStrictMarkingBase& x);
3749+
3750+} /* namespace DiscreteVerification */
3751+} /* namespace VerifyTAPN */
3752+
3753+#endif /* NonStrictMarkingBase_HPP_ */
3754
3755=== added file 'src/DiscreteVerification/DataStructures/PData.cpp'
3756--- src/DiscreteVerification/DataStructures/PData.cpp 1970-01-01 00:00:00 +0000
3757+++ src/DiscreteVerification/DataStructures/PData.cpp 2013-03-31 13:25:26 +0000
3758@@ -0,0 +1,16 @@
3759+/*
3760+ * File: PData.cpp
3761+ * Author: floop
3762+ *
3763+ * Created on 5. november 2012, 10:22
3764+ */
3765+
3766+#include <set>
3767+
3768+#include "PData.h"
3769+namespace VerifyTAPN {
3770+ namespace DiscreteVerification {
3771+
3772+
3773+ }
3774+}
3775\ No newline at end of file
3776
3777=== added file 'src/DiscreteVerification/DataStructures/PData.h'
3778--- src/DiscreteVerification/DataStructures/PData.h 1970-01-01 00:00:00 +0000
3779+++ src/DiscreteVerification/DataStructures/PData.h 2013-03-31 13:25:26 +0000
3780@@ -0,0 +1,427 @@
3781+/*
3782+ * File: PData.h
3783+ * Author: Peter Gjøl Jensen
3784+ *
3785+ * Created on 5. november 2012, 10:22
3786+ */
3787+
3788+
3789+#include "NonStrictMarking.hpp"
3790+#include "EncodingStructure.h"
3791+#include "TimeDart.hpp"
3792+
3793+#ifndef PDATA_H
3794+#define PDATA_H
3795+namespace VerifyTAPN {
3796+ namespace DiscreteVerification {
3797+
3798+ // pointer containing enough data to reconstruct the stored data at any time!
3799+ template<typename T>
3800+ struct EncodingPointer {
3801+ EncodingStructure<T*> encoding;
3802+ unsigned int node;
3803+
3804+ EncodingPointer() {
3805+ };
3806+
3807+ EncodingPointer(EncodingPointer<T> &en) : encoding(en.encoding.Clone()), node(en.node) {}; // possible mem-leak?
3808+
3809+ EncodingPointer(EncodingStructure<T*> &en, unsigned int n) : encoding(en.Clone()), node(n) {
3810+ }
3811+ };
3812+
3813+ template<typename T>
3814+ class PData {
3815+ public:
3816+ typedef unsigned int uint;
3817+ typedef EncodingStructure<T*> MarkingEncoding;
3818+
3819+ struct Result {
3820+ bool isNew;
3821+ MarkingEncoding encoding;
3822+ uint pos;
3823+
3824+ Result(bool ex, MarkingEncoding en, uint node) : isNew(ex), encoding(en), pos(node) {
3825+ };
3826+ };
3827+
3828+
3829+ PData(boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn, int knumber, int nplaces, int mage) :
3830+ k(knumber),
3831+ maxAge(mage + 1),
3832+ numberOfPlaces(nplaces),
3833+ countSize(ceil(log2((knumber ? knumber : 1)) + 1)),
3834+ enumeratedOffset(ceil(log2((nplaces * (mage + 1))) + 1) + countSize),
3835+ numberOfVariables(enumeratedOffset * (knumber ? knumber : 1)),
3836+ cachesize(128),
3837+ tapn(tapn) {
3838+ overhead = MarkingEncoding::Overhead(this->numberOfVariables);
3839+ this->numberOfVariables += overhead;
3840+ stored = 0;
3841+ bddsize = cachesize;
3842+ this->BDDArr.push_back(new PNode[this->bddsize]);
3843+ memset(this->BDDArr[0], 0xffffffff, this->bddsize * sizeof (PNode));
3844+ BDDArr[0][0].shadow = NULL;
3845+ BDDArr[0][0].highCount = BDDArr[0][0].lowCount = 0;
3846+ BDDArr[0][0].lowpos = BDDArr[0][0].highpos = 0;
3847+ BDDArr[0][0].parent = 0;
3848+ bddnext = 1;
3849+ encoding = MarkingEncoding(this->numberOfVariables);
3850+ listcount = 0;
3851+ maxCount = sizeof (PNode) * 4 + sizeof (std::list<PNode>) * 4;
3852+
3853+ };
3854+ virtual ~PData();
3855+
3856+ uint maxCount;
3857+
3858+ struct PNode {
3859+ MarkingEncoding* shadow;
3860+ uint highpos;
3861+
3862+ uint lowpos;
3863+
3864+ short int highCount;
3865+ short int lowCount;
3866+ uint parent;
3867+ };
3868+
3869+ bool search(MarkingEncoding* arr, MarkingEncoding en, int size) {
3870+ for (int i = 0; i < size; i++) {
3871+ if (arr[i] == en)
3872+ return true;
3873+ }
3874+ return false;
3875+ }
3876+ /* bool equal(MarkingEncoding* arr, EncodingList* lst){
3877+ EncodingList::const_iterator it = lst->begin();
3878+ while(it != lst->end()){
3879+ if(!search(arr, *it, lst->size()))
3880+ return false;
3881+ it++;
3882+ }
3883+ return true;
3884+ }*/
3885+
3886+ Result Add(NonStrictMarkingBase* marking);
3887+
3888+ unsigned int size() {
3889+ return stored;
3890+ }
3891+ void PrintMemStats();
3892+ void PrintEncoding(bool* encoding, int length);
3893+
3894+ inline PNode* FetchNode(uint i) {
3895+ return &BDDArr[i / cachesize][i % cachesize];
3896+ }
3897+ NonStrictMarkingBase* EnumerateDecode(const EncodingPointer<T>& pointer);
3898+
3899+ int EnumeratedEncoding(NonStrictMarkingBase* marking);
3900+ const uint k;
3901+ const uint maxAge;
3902+ const uint numberOfPlaces;
3903+ const uint countSize;
3904+ const uint enumeratedOffset;
3905+ uint numberOfVariables;
3906+ const uint cachesize;
3907+
3908+ boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn;
3909+
3910+ MarkingEncoding encoding;
3911+ vector<PNode*> BDDArr;
3912+ uint bddsize;
3913+ uint stored;
3914+ uint bddnext;
3915+ uint overhead;
3916+ uint listcount;
3917+ };
3918+
3919+ template<typename T>
3920+ PData<T>::~PData() {
3921+ }
3922+
3923+
3924+ template<typename T>
3925+ int PData<T>::EnumeratedEncoding(NonStrictMarkingBase* marking) {
3926+ encoding.Zero();
3927+
3928+ int tc = 0;
3929+ uint bitcount = 0;
3930+
3931+ for (vector<Place>::const_iterator pi = marking->places.begin();
3932+ pi != marking->places.end();
3933+ pi++) { // for each place
3934+
3935+ int pc = pi->place->GetIndex();
3936+
3937+ for (TokenList::const_iterator ti = pi->tokens.begin(); // for each token-element
3938+ ti != pi->tokens.end();
3939+ ti++) {
3940+
3941+ // for (int i = 0; i < ti->getCount(); i++) // for each ACTUAL token
3942+ // {
3943+ int offset = tc * this->enumeratedOffset; // the offset of the variables for this token
3944+ uint number = ti->getCount();
3945+ bitcount = 0;
3946+ while (number) { // set the vars while there are bits left
3947+ if (number & 1) {
3948+ this->encoding.Set(overhead + offset + bitcount, true);
3949+ }
3950+ bitcount++;
3951+ number = number >> 1;
3952+ }
3953+ uint pos = pc + this->numberOfPlaces * ti->getAge(); // the enumerated configuration of the token
3954+ bitcount = countSize;
3955+ /* binary */
3956+ while (pos) { // set the vars while there are bits left
3957+ if (pos & 1) {
3958+ this->encoding.Set(overhead + offset + bitcount, true);
3959+ }
3960+ bitcount++;
3961+ pos = pos >> 1;
3962+ }
3963+ tc++;
3964+ // }
3965+
3966+ }
3967+ }
3968+ if (tc == 0)
3969+ return 0;
3970+ else
3971+ return ((tc - 1) * this->enumeratedOffset) + bitcount;
3972+ }
3973+
3974+ template<typename T>
3975+ NonStrictMarkingBase* PData<T>::EnumerateDecode(const EncodingPointer<T> &pointer) {
3976+ NonStrictMarkingBase* m = new NonStrictMarkingBase();
3977+ this->encoding.Zero();
3978+
3979+ uint var = 0;
3980+ uint n = pointer.node;
3981+ while (n) {
3982+ n = FetchNode(n)->parent;
3983+ var++;
3984+ }
3985+ var += this->overhead;
3986+
3987+ // m->meta = pointer.encoding.GetMetaData();
3988+ this->encoding.Copy(pointer.encoding, var);
3989+ uint nbits = (var - (var % 8)) + pointer.encoding.Size()*8;
3990+ uint self = pointer.node;
3991+
3992+ while (self) {
3993+ var--;
3994+ n = FetchNode(self)->parent;
3995+ bool branch = FetchNode(n)->highpos == self;
3996+ this->encoding.Set(var, branch);
3997+ self = n;
3998+
3999+ }
4000+
4001+ var = this->numberOfVariables - 1;
4002+ // foreach token
4003+ uint data = 0;
4004+ uint count = 0;
4005+ for (int i = this->k - 1; i >= 0; i--) {
4006+ uint offset = (this->enumeratedOffset * i) + this->overhead + this->countSize;
4007+ while (nbits >= offset) {
4008+ data = data << 1;
4009+
4010+ if (encoding.At(nbits)) {
4011+ data = data | 1;
4012+ }
4013+ if (nbits == 0) {
4014+ break;
4015+ }
4016+ nbits--;
4017+ }
4018+ offset -= this->countSize;
4019+ while (nbits >= offset) {
4020+ count = count << 1;
4021+
4022+ if (encoding.At(nbits)) {
4023+ count = count | 1;
4024+ }
4025+ if (nbits == 0) {
4026+ break;
4027+ }
4028+ nbits--;
4029+ }
4030+
4031+ if (count) {
4032+ int age = floor(data / this->numberOfPlaces);
4033+ uint place = (data % this->numberOfPlaces);
4034+ Token t = Token(age, count);
4035+ m->AddTokenInPlace(tapn->GetPlace(place), t);
4036+ data = 0;
4037+ count = 0;
4038+ }
4039+ }
4040+ return m;
4041+ }
4042+
4043+ template<typename T>
4044+ typename PData<T>::Result PData<T>::Add(NonStrictMarkingBase* marking) {
4045+
4046+ int encsize = this->EnumeratedEncoding(marking) + overhead;
4047+ // go through the BDD as far as possible with the encoding of the marking
4048+ uint c_count = 0;
4049+ uint prev_count = 0;
4050+ int var = overhead;
4051+ do {
4052+
4053+ prev_count = c_count;
4054+ if (encoding.At(var)) {
4055+ c_count = BDDArr[c_count / cachesize][c_count % cachesize].highpos;
4056+
4057+ } else {
4058+ c_count = BDDArr[c_count / cachesize][c_count % cachesize].lowpos;
4059+ }
4060+
4061+ var++;
4062+
4063+ } while (c_count != 0);
4064+ var--;
4065+
4066+ PNode* prev_node = FetchNode(prev_count);
4067+
4068+ int listsize = 0;
4069+ if (prev_node->highCount >= 0) {
4070+ listsize += prev_node->highCount;
4071+ }
4072+ if (prev_node->lowCount >= 0) {
4073+ listsize += prev_node->lowCount;
4074+ }
4075+
4076+ int size = this->numberOfVariables - var;
4077+ MarkingEncoding en = MarkingEncoding(encoding.GetRaw(), size, var, encsize);
4078+
4079+ int ins = 0;
4080+
4081+ for (; ins < listsize; ins++) {
4082+ if (prev_node->shadow[ins] == en) {
4083+ break;
4084+ }
4085+ }
4086+ if (ins != listsize) {
4087+ return Result(false, prev_node->shadow[ins], prev_count);
4088+ }
4089+
4090+ en = MarkingEncoding(encoding, size, var, encsize);
4091+ short unsigned int count;
4092+
4093+ MarkingEncoding* nlist = new MarkingEncoding[listsize + 1];
4094+ nlist[listsize] = en;
4095+
4096+ for (int i = 0; i < listsize; i++) {
4097+ nlist[i] = prev_node->shadow[i];
4098+ }
4099+ delete[] prev_node->shadow;
4100+ prev_node->shadow = nlist;
4101+
4102+
4103+ bool branch = encoding.At(var);
4104+ if (branch) {
4105+ count = (++prev_node->highCount);
4106+ } else {
4107+ count = (++prev_node->lowCount);
4108+ }
4109+
4110+ if (count > maxCount) {
4111+
4112+ size--;
4113+ int testclist = 0;
4114+ int testnlist = 0;
4115+ PNode* c_node = &this->BDDArr[floor(this->bddnext / this->cachesize)][this->bddnext % this->cachesize];
4116+ if (branch) {
4117+ prev_node->highpos = this->bddnext;
4118+ c_node->shadow = new MarkingEncoding[testclist = prev_node->highCount];
4119+ prev_node->highCount = -1;
4120+ if (prev_node->lowCount > 0)
4121+ nlist = new MarkingEncoding[testnlist = prev_node->lowCount];
4122+ else
4123+ nlist = NULL;
4124+ } else {
4125+ prev_node->lowpos = this->bddnext;
4126+ c_node->shadow = new MarkingEncoding[testclist = prev_node->lowCount];
4127+ prev_node->lowCount = -1;
4128+ if (prev_node->highCount > 0)
4129+ nlist = new MarkingEncoding[testnlist = prev_node->highCount];
4130+ else
4131+ nlist = NULL;
4132+ }
4133+ c_node->parent = prev_count;
4134+ prev_count = this->bddnext;
4135+ listcount++;
4136+ c_node->lowCount = c_node->highCount = 0;
4137+ c_node->lowpos = c_node->highpos = 0;
4138+ uint npos = ((this->numberOfVariables - (size + 1)) % 8);
4139+
4140+ MarkingEncoding nee;
4141+ int clistcount = 0;
4142+ int nlistcount = 0;
4143+ for (int i = 0; i < listsize + 1; i++) {
4144+ if (prev_node->shadow[i].At(npos) == branch) {
4145+ if (!(size % 8)) {
4146+ nee = MarkingEncoding(prev_node->shadow[i], 8);
4147+ if (i == ins) {
4148+ en = nee;
4149+ }
4150+ prev_node->shadow[i].Release();
4151+ } else {
4152+ nee = prev_node->shadow[i];
4153+ }
4154+ if (nee.At((npos + 1) % 8)) {
4155+ c_node->highCount++;
4156+ } else {
4157+ c_node->lowCount++;
4158+ }
4159+ c_node->shadow[clistcount] = nee;
4160+ clistcount++;
4161+ } else {
4162+ nlist[nlistcount] = prev_node->shadow[i];
4163+ nlistcount++;
4164+ }
4165+
4166+ }
4167+ delete[] prev_node->shadow;
4168+ prev_node->shadow = nlist;
4169+
4170+ if (prev_node->highCount == -1 && prev_node->lowCount == -1) {
4171+ listcount--;
4172+ delete[] prev_node->shadow;
4173+ }
4174+
4175+ this->bddnext++;
4176+ if (this->bddnext == this->bddsize) {
4177+ this->bddsize += this->cachesize;
4178+ this->BDDArr.push_back(new PNode[this->cachesize]);
4179+ memset(this->BDDArr[floor(this->bddsize / this->cachesize) - 1], 0xffffffff, (this->cachesize) * sizeof (PNode));
4180+ }
4181+ }
4182+
4183+ stored++;
4184+ return Result(true, en, prev_count);
4185+
4186+ }
4187+
4188+ template<typename T>
4189+ void PData<T>::PrintMemStats() {
4190+ cout << endl << "Encoding size;" << endl <<
4191+ "\t\t\t" << this->numberOfVariables << endl;
4192+ cout << "Lists:" << endl <<
4193+ "\t count \t\t" << this->listcount << endl;
4194+ cout << "Nodes:" << endl <<
4195+ "\t count \t\t" << this->bddnext - 1 << endl;
4196+ }
4197+
4198+ template<typename T>
4199+ void PData<T>::PrintEncoding(bool* encoding, int length) {
4200+ for (int i = 0; i < length; i++)
4201+ cout << encoding[i];
4202+ cout << endl;
4203+ }
4204+ }
4205+}
4206+#endif /* PDATA_H */
4207+
4208
4209=== modified file 'src/DiscreteVerification/DataStructures/PWList.cpp' (properties changed: +x to -x)
4210--- src/DiscreteVerification/DataStructures/PWList.cpp 2012-11-24 11:35:27 +0000
4211+++ src/DiscreteVerification/DataStructures/PWList.cpp 2013-03-31 13:25:26 +0000
4212@@ -17,22 +17,26 @@
4213 iter != m.end();
4214 iter++){
4215 if((*iter)->equals(*marking)){
4216- if(!(*iter)->passed){
4217- waiting_list->Add(*iter);
4218- return true;
4219- }
4220- return false;
4221+ if(isLiveness){
4222+ marking->meta = (*iter)->meta;
4223+ if(!marking->meta->passed){
4224+ (*iter)->SetGeneratedBy(marking->GetGeneratedBy());
4225+ waiting_list->Add(*iter, *iter);
4226+ return true;
4227+ }
4228+ }
4229+ return false;
4230 }
4231 }
4232 stored++;
4233 m.push_back(marking);
4234- waiting_list->Add(marking);
4235+ marking->meta = new MetaData();
4236+ waiting_list->Add(marking, marking);
4237 return true;
4238 }
4239
4240 NonStrictMarking* PWList::GetNextUnexplored(){
4241- // TODO: Is this really it?
4242- return waiting_list->Next();
4243+ return waiting_list->Pop();
4244 }
4245
4246 PWList::~PWList() {
4247@@ -50,5 +54,70 @@
4248 return out;
4249 }
4250
4251+ bool PWListHybrid::Add(NonStrictMarking* marking) {
4252+
4253+ discoveredMarkings++;
4254+ // reset the encoding array
4255+
4256+ PData<MetaData>::Result res = passed->Add(marking);
4257+ if(res.isNew){
4258+ if(isLiveness){
4259+ MetaData* meta;
4260+ if(this->makeTrace){
4261+ meta = new MetaDataWithTrace();
4262+ ((MetaDataWithTrace*)meta)->generatedBy = marking->generatedBy;
4263+ } else {
4264+ meta = new MetaData();
4265+ }
4266+ res.encoding.SetMetaData(meta);
4267+ marking->meta = meta;
4268+ } else if(this->makeTrace){
4269+ MetaDataWithTraceAndEncoding* meta = new MetaDataWithTraceAndEncoding();
4270+ meta->generatedBy = marking->generatedBy;
4271+ res.encoding.SetMetaData(meta);
4272+ meta->ep = new EncodingPointer<MetaData > (res.encoding, res.pos);
4273+ meta->parent = parent;
4274+ }
4275+ this->waiting_list->Add(marking, new EncodingPointer<MetaData > (res.encoding, res.pos));
4276+ } else{
4277+ if(isLiveness){
4278+ marking->meta = res.encoding.GetMetaData();
4279+ if(this->makeTrace){
4280+ ((MetaDataWithTrace*)marking->meta)->generatedBy = marking->generatedBy;
4281+ }
4282+ }
4283+ if(isLiveness && !marking->meta->passed){
4284+ this->waiting_list->Add(marking, new EncodingPointer<MetaData > (res.encoding, res.pos));
4285+ return true;
4286+ }
4287+ }
4288+ return res.isNew;
4289+ }
4290+
4291+ NonStrictMarking* PWListHybrid::GetNextUnexplored() {
4292+ // TODO: Is this really it?
4293+ EncodingPointer<MetaData>* p = waiting_list->Pop();
4294+ NonStrictMarkingBase* base = passed->EnumerateDecode(*p);
4295+ NonStrictMarking* m = new NonStrictMarking(*base);
4296+ delete base;
4297+
4298+ m->meta = p->encoding.GetMetaData();
4299+
4300+ if(this->makeTrace){
4301+ if(isLiveness){
4302+ m->generatedBy = ((MetaDataWithTrace*)(m->meta))->generatedBy;
4303+ } else {
4304+ this->parent = (MetaDataWithTraceAndEncoding*)(m->meta);
4305+ }
4306+ }
4307+ if(isLiveness || !this->makeTrace)
4308+ p->encoding.Release();
4309+ return m;
4310+ }
4311+
4312+ PWListHybrid::~PWListHybrid() {
4313+ // TODO Auto-generated destructor stub
4314+ }
4315+
4316 } /* namespace DiscreteVerification */
4317 } /* namespace VerifyTAPN */
4318
4319=== modified file 'src/DiscreteVerification/DataStructures/PWList.hpp' (properties changed: +x to -x)
4320--- src/DiscreteVerification/DataStructures/PWList.hpp 2012-11-24 11:35:27 +0000
4321+++ src/DiscreteVerification/DataStructures/PWList.hpp 2013-03-31 13:25:26 +0000
4322@@ -17,13 +17,31 @@
4323
4324 namespace VerifyTAPN {
4325 namespace DiscreteVerification {
4326-class PWList {
4327+
4328+ class PWListBase {
4329+ public:
4330+ PWListBase() : stored(0), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), isLiveness(false) {};
4331+ PWListBase(bool isLiveness) : stored(0), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), isLiveness(isLiveness){};
4332+ int stored;
4333+ int discoveredMarkings;
4334+ int maxNumTokensInAnyMarking;
4335+ bool isLiveness;
4336+
4337+ virtual bool HasWaitingStates() = 0;
4338+ virtual long long Size() const = 0;
4339+ virtual bool Add(NonStrictMarking* marking) = 0;
4340+ virtual NonStrictMarking* GetNextUnexplored() = 0;
4341+ virtual long long Explored()= 0;
4342+ inline void SetMaxNumTokensIfGreater(int i){ if(i>maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i; };
4343+ };
4344+
4345+class PWList : public PWListBase {
4346 public:
4347 typedef std::vector<NonStrictMarking*> NonStrictMarkingList;
4348 typedef google::sparse_hash_map<size_t, NonStrictMarkingList> HashMap;
4349 public:
4350- PWList() : markings_storage(256000), waiting_list(), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {};
4351- PWList(WaitingList* w_l) : markings_storage(256000), waiting_list(w_l), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {};
4352+ PWList() : PWListBase(false), markings_storage(256000), waiting_list(){};
4353+ PWList(WaitingList<NonStrictMarking>* w_l, bool isLiveness) :PWListBase(isLiveness), markings_storage(256000), waiting_list(w_l) {};
4354 virtual ~PWList();
4355 friend std::ostream& operator<<(std::ostream& out, PWList& x);
4356
4357@@ -36,18 +54,65 @@
4358 return stored;
4359 };
4360
4361+ virtual long long Explored() {return waiting_list->Size();};
4362+
4363 public: // modifiers
4364 virtual bool Add(NonStrictMarking* marking);
4365 virtual NonStrictMarking* GetNextUnexplored();
4366- inline void SetMaxNumTokensIfGreater(int i){ if(i>maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i; };
4367
4368 public:
4369 HashMap markings_storage;
4370- WaitingList* waiting_list;
4371- int discoveredMarkings;
4372- int maxNumTokensInAnyMarking;
4373-private:
4374- unsigned int stored;
4375+ WaitingList<NonStrictMarking>* waiting_list;
4376+};
4377+
4378+class PWListHybrid : public PWListBase {
4379+ public:
4380+ typedef unsigned int uint;
4381+ // typedef google::sparse_hash_map<size_t, EncodingList> HashMap;
4382+ PData<MetaData>* passed;
4383+
4384+ public:
4385+
4386+ PWListHybrid(boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn, WaitingList<EncodingPointer<MetaData> >* w_l, int knumber, int nplaces, int mage, bool isLiveness, bool makeTrace) :
4387+ PWListBase(isLiveness),
4388+ waiting_list(w_l),
4389+ makeTrace(makeTrace) {
4390+ discoveredMarkings = 0;
4391+ passed = new PData<MetaData>(tapn, knumber,nplaces,mage);
4392+ parent = NULL;
4393+ };
4394+ virtual ~PWListHybrid();
4395+ friend std::ostream& operator<<(std::ostream& out, PWListHybrid& x);
4396+
4397+ public: // inspectors
4398+ NonStrictMarking* Decode(EncodingPointer<MetaData>* ep){
4399+ NonStrictMarkingBase* base = this->passed->EnumerateDecode(*ep);
4400+ NonStrictMarking* m = new NonStrictMarking(*base);
4401+ delete base;
4402+ return m;
4403+ };
4404+ virtual bool HasWaitingStates() {
4405+ return (waiting_list->Size() > 0);
4406+ };
4407+
4408+ virtual long long Size() const {
4409+ return passed->stored;
4410+ };
4411+ virtual long long Explored() {return waiting_list->Size();};
4412+ void PrintMemStats() {
4413+ passed->PrintMemStats();
4414+ }
4415+
4416+ public: // modifiers
4417+ virtual bool Add(NonStrictMarking* marking);
4418+ virtual NonStrictMarking* GetNextUnexplored();
4419+
4420+ public:
4421+
4422+ WaitingList<EncodingPointer<MetaData> >* waiting_list;
4423+ bool makeTrace;
4424+ //ugly tracefix
4425+ MetaDataWithTraceAndEncoding* parent;
4426 };
4427
4428 std::ostream& operator<<(std::ostream& out, PWList& x);
4429
4430=== added file 'src/DiscreteVerification/DataStructures/TimeDart.hpp'
4431--- src/DiscreteVerification/DataStructures/TimeDart.hpp 1970-01-01 00:00:00 +0000
4432+++ src/DiscreteVerification/DataStructures/TimeDart.hpp 2013-03-31 13:25:26 +0000
4433@@ -0,0 +1,128 @@
4434+/*
4435+ * TimeDart.hpp
4436+ *
4437+ * Created on: 18/09/2012
4438+ * Author: MathiasGS
4439+ */
4440+
4441+#ifndef TIMEDART_HPP_
4442+#define TIMEDART_HPP_
4443+
4444+#include "NonStrictMarking.hpp"
4445+#include "PData.h"
4446+
4447+namespace VerifyTAPN {
4448+namespace DiscreteVerification {
4449+
4450+struct WaitingDart;
4451+struct TraceDart;
4452+class TimeDartBase;
4453+
4454+typedef EncodingPointer<TimeDartBase> TimeDartEncodingPointer; // used for memory-optimization for reachability
4455+typedef EncodingPointer<WaitingDart> WaitingDartEncodingPointer; // mem-optimization for liveness
4456+
4457+
4458+typedef vector<WaitingDart*> TraceMetaDataList;
4459+
4460+class TimeDartBase {
4461+public:
4462+ TimeDartBase(NonStrictMarkingBase* base, int waiting, int passed)
4463+ : base(base), waiting(waiting), passed(passed){
4464+ }
4465+ ~TimeDartBase(){
4466+ }
4467+
4468+ //Getters
4469+ inline NonStrictMarkingBase* getBase(){ return base; }
4470+ inline void setBase(NonStrictMarkingBase* newbase) { base = newbase;}
4471+ inline int getWaiting(){ return waiting; }
4472+ inline int getPassed(){ return passed; }
4473+
4474+ //Getters
4475+ inline void setWaiting(int w){ waiting = w; }
4476+ inline void setPassed(int p){ passed = p; }
4477+
4478+private:
4479+ NonStrictMarkingBase* base;
4480+ int waiting;
4481+ int passed;
4482+};
4483+
4484+
4485+class ReachabilityTraceableDart : public TimeDartBase {
4486+public:
4487+ ReachabilityTraceableDart(NonStrictMarkingBase* base, int waiting, int passed)
4488+ : TimeDartBase(base, waiting, passed), trace(NULL){
4489+ }
4490+ TraceDart* trace;
4491+};
4492+
4493+class EncodedReachabilityTraceableDart : public ReachabilityTraceableDart {
4494+public:
4495+ EncodedReachabilityTraceableDart(NonStrictMarkingBase* base, int waiting, int passed)
4496+ : ReachabilityTraceableDart(base, waiting, passed) {
4497+
4498+
4499+ }
4500+ TimeDartEncodingPointer* encoding;
4501+};
4502+
4503+class LivenessDart : public TimeDartBase {
4504+public:
4505+ LivenessDart(NonStrictMarkingBase* base, int waiting, int passed)
4506+ : TimeDartBase(base, waiting, passed), traceData(NULL){
4507+ }
4508+ TraceMetaDataList* traceData;
4509+};
4510+
4511+class EncodedLivenessDart : public LivenessDart {
4512+public:
4513+ EncodedLivenessDart(NonStrictMarkingBase* base, int waiting, int passed)
4514+ : LivenessDart(base, waiting, passed) {
4515+
4516+ }
4517+ WaitingDartEncodingPointer* encoding;
4518+};
4519+
4520+struct WaitingDart{
4521+ TimeDartBase* dart;
4522+ WaitingDart* parent;
4523+ int w;
4524+ int upper;
4525+
4526+ WaitingDart(TimeDartBase* dart, WaitingDart* parent, int w, int upper) : dart(dart), parent(parent), w(w), upper(upper){
4527+
4528+ }
4529+
4530+ ~WaitingDart(){
4531+
4532+ if(parent != NULL && ((LivenessDart*)parent->dart)->traceData != NULL){
4533+ for(TraceMetaDataList::iterator iter = ((LivenessDart*)parent->dart)->traceData->begin(); iter != ((LivenessDart*)parent->dart)->traceData->end(); iter++){
4534+ if((*iter) == this){
4535+ ((LivenessDart*)parent->dart)->traceData->erase(iter);
4536+ break;
4537+ }
4538+ }
4539+ if(((LivenessDart*)parent->dart)->traceData->empty()){
4540+ delete ((LivenessDart*)parent->dart)->traceData;
4541+ ((LivenessDart*)parent->dart)->traceData = NULL;
4542+ }
4543+ }
4544+ }
4545+};
4546+
4547+struct TraceDart : WaitingDart {
4548+ const TAPN::TimedTransition* generatedBy;
4549+ const int start;
4550+ TraceDart(TraceDart &t) : WaitingDart(t.dart, t.parent, t.w, t.upper), generatedBy(t.generatedBy), start(t.start){
4551+
4552+ };
4553+ TraceDart(TimeDartBase* dart, WaitingDart* parent, int w, int start, int upper, const TAPN::TimedTransition* GeneratedBy) : WaitingDart(dart, parent, w, upper), generatedBy(GeneratedBy), start(start){
4554+
4555+ }
4556+
4557+};
4558+}
4559+}
4560+
4561+#endif /* TIMEDART_HPP_ */
4562
4563=== added file 'src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp'
4564--- src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp 1970-01-01 00:00:00 +0000
4565+++ src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp 2013-03-31 13:25:26 +0000
4566@@ -0,0 +1,164 @@
4567+/*
4568+ * PWList.cpp
4569+ *
4570+ * Created on: 01/03/2012
4571+ * Author: MathiasGS
4572+ */
4573+
4574+#include "TimeDartLivenessPWList.hpp"
4575+
4576+namespace VerifyTAPN {
4577+ namespace DiscreteVerification {
4578+
4579+ std::pair<LivenessDart*, bool> TimeDartLivenessPWHashMap::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start) {
4580+ discoveredMarkings++;
4581+ TimeDartList& m = markings_storage[marking->HashKey()];
4582+ for (TimeDartList::const_iterator iter = m.begin();
4583+ iter != m.end();
4584+ iter++) {
4585+ if ((*iter)->getBase()->equals(*marking)) {
4586+ std::pair < LivenessDart*, bool> result(*iter, false);
4587+ (*iter)->setWaiting(min((*iter)->getWaiting(), youngest));
4588+
4589+ if ((*iter)->getWaiting() < (*iter)->getPassed()) {
4590+ if(options.GetTrace()){
4591+ waiting_list->Add((*iter)->getBase(), new TraceDart((*iter), parent, youngest, start, upper, marking->generatedBy));
4592+
4593+ } else {
4594+ waiting_list->Add((*iter)->getBase(), new WaitingDart((*iter), parent, youngest, upper));
4595+ }
4596+ result.second = true;
4597+ delete marking;
4598+ }
4599+
4600+ return result;
4601+ }
4602+ }
4603+ stored++;
4604+ LivenessDart* dart = new LivenessDart(marking, youngest, INT_MAX);
4605+ m.push_back(dart);
4606+ if(options.GetTrace()){
4607+
4608+ waiting_list->Add(dart->getBase(), new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy));
4609+
4610+ } else {
4611+ waiting_list->Add(dart->getBase(), new WaitingDart(dart, parent, youngest, upper));
4612+ }
4613+ std::pair < LivenessDart*, bool> result(dart, true);
4614+ return result;
4615+ }
4616+
4617+ WaitingDart* TimeDartLivenessPWHashMap::GetNextUnexplored() {
4618+ return waiting_list->Peek();
4619+ }
4620+
4621+ void TimeDartLivenessPWHashMap::PopWaiting() {
4622+ delete waiting_list->Pop();
4623+ }
4624+
4625+ void TimeDartLivenessPWHashMap::flushBuffer() {
4626+ // Flush buffer if w has changed
4627+ waiting_list->flushBuffer();
4628+ }
4629+
4630+ std::pair<LivenessDart*, bool> TimeDartLivenessPWPData::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start) {
4631+
4632+
4633+ discoveredMarkings++;
4634+ PData<LivenessDart>::Result res = passed.Add(marking);
4635+
4636+ if (!res.isNew) {
4637+ LivenessDart* td = res.encoding.GetMetaData();
4638+ td->setBase(marking);
4639+ std::pair < LivenessDart*, bool> result(td, false);
4640+ td->setWaiting(min(td->getWaiting(), youngest));
4641+
4642+ if (td->getWaiting() < td->getPassed()) {
4643+ EncodingStructure<WaitingDart*> es(res.encoding.GetRaw(), res.encoding.Size());
4644+
4645+ EncodingPointer<WaitingDart>* ewp = new EncodingPointer<WaitingDart > (es, res.pos);
4646+ WaitingDart *wd;
4647+ if(options.GetTrace()){
4648+ wd = new TraceDart(td, parent, youngest, start, upper, marking->generatedBy);
4649+
4650+ } else {
4651+ wd = new WaitingDart(td, parent, youngest, upper);
4652+ }
4653+ ewp->encoding.SetMetaData(wd);
4654+
4655+ waiting_list->Add(marking, ewp);
4656+ result.second = true;
4657+ } else {
4658+ if(options.GetTrace() == SOME){
4659+ EncodingStructure<WaitingDart*> es(res.encoding.GetRaw(), res.encoding.Size());
4660+ ((EncodedLivenessDart*)td)->encoding = new EncodingPointer<WaitingDart > (es, res.pos);
4661+ result.first = td;
4662+ }
4663+ }
4664+ return result;
4665+ }
4666+
4667+ stored++;
4668+ LivenessDart* dart;
4669+ if(options.GetTrace()){
4670+ dart= new EncodedLivenessDart(marking, youngest, INT_MAX);
4671+ } else {
4672+ dart = new LivenessDart(marking, youngest, INT_MAX);
4673+ }
4674+ res.encoding.SetMetaData(dart);
4675+
4676+ EncodingStructure<WaitingDart*> es(res.encoding.GetRaw(), res.encoding.Size());
4677+ EncodingPointer<WaitingDart>* ewp = new EncodingPointer<WaitingDart > (es, res.pos);
4678+
4679+ WaitingDart *wd;
4680+ if(options.GetTrace()){
4681+ wd = new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy);
4682+ ((EncodedLivenessDart*)dart)->encoding = ewp;
4683+ } else {
4684+ wd = new WaitingDart(dart, parent, youngest, upper);
4685+ }
4686+ ewp->encoding.SetMetaData(wd);
4687+
4688+ waiting_list->Add(marking, ewp);
4689+ std::pair < LivenessDart*, bool> result(dart, true);
4690+ return result;
4691+ }
4692+
4693+ WaitingDart* TimeDartLivenessPWPData::GetNextUnexplored() {
4694+ EncodingPointer<WaitingDart>* ewp = waiting_list->Peek();
4695+ WaitingDart* wd = ewp->encoding.GetMetaData();
4696+ NonStrictMarkingBase* base = passed.EnumerateDecode(*((EncodingPointer<LivenessDart>*)ewp));
4697+ wd->dart->setBase(base);
4698+ if(options.GetTrace() == SOME){
4699+ ((EncodedLivenessDart*)wd->dart)->encoding = ewp;
4700+ }
4701+ return wd;
4702+ }
4703+
4704+ void TimeDartLivenessPWPData::PopWaiting() {
4705+ EncodingPointer<WaitingDart>* ewp = waiting_list->Pop();
4706+ WaitingDart* wd = ewp->encoding.GetMetaData();
4707+ delete wd->dart->getBase();
4708+ delete wd;
4709+ ewp->encoding.Release();
4710+ delete ewp;
4711+ }
4712+
4713+ void TimeDartLivenessPWPData::flushBuffer() {
4714+ // Flush buffer if w has changed
4715+ waiting_list->flushBuffer();
4716+ }
4717+
4718+ std::ostream& operator<<(std::ostream& out, TimeDartLivenessPWHashMap& x) {
4719+ out << "Passed and waiting:" << std::endl;
4720+ for (TimeDartLivenessPWHashMap::HashMap::iterator iter = x.markings_storage.begin(); iter != x.markings_storage.end(); iter++) {
4721+ for (TimeDartLivenessPWHashMap::TimeDartList::iterator m_iter = iter->second.begin(); m_iter != iter->second.end(); m_iter++) {
4722+ out << "- " << *m_iter << std::endl;
4723+ }
4724+ }
4725+ out << "Waiting:" << std::endl << x.waiting_list;
4726+ return out;
4727+ }
4728+
4729+ } /* namespace DiscreteVerification */
4730+} /* namespace VerifyTAPN */
4731
4732=== added file 'src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp'
4733--- src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp 1970-01-01 00:00:00 +0000
4734+++ src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp 2013-03-31 13:25:26 +0000
4735@@ -0,0 +1,118 @@
4736+/*
4737+ * PWList.hpp
4738+ *
4739+ * Created on: 01/03/2012
4740+ * Author: MathiasGS
4741+ */
4742+
4743+#ifndef TimeDartLivenessPWList_HPP_
4744+#define TimeDartLivenessPWList_HPP_
4745+
4746+#include "WaitingList.hpp"
4747+#include <iostream>
4748+#include "google/sparse_hash_map"
4749+#include "NonStrictMarkingBase.hpp"
4750+#include "WaitingList.hpp"
4751+#include "TimeDart.hpp"
4752+#include "PData.h"
4753+
4754+namespace VerifyTAPN {
4755+ namespace DiscreteVerification {
4756+ class TimeDartLivenessPWBase;
4757+ class TimeDartLivenessPWHashMap;
4758+ // class TimeDartPWPData;
4759+
4760+ class TimeDartLivenessPWBase {
4761+ public:
4762+ typedef std::vector<LivenessDart*> TimeDartList;
4763+ typedef google::sparse_hash_map<size_t, TimeDartList> HashMap;
4764+
4765+ public:
4766+
4767+ TimeDartLivenessPWBase() : discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {
4768+ };
4769+
4770+ virtual ~TimeDartLivenessPWBase() {
4771+ };
4772+
4773+
4774+ public: // inspectors
4775+ virtual bool HasWaitingStates() = 0;
4776+
4777+ virtual long long Size() const {
4778+ return stored;
4779+ };
4780+
4781+ public: // modifiers
4782+ virtual std::pair<LivenessDart*, bool> Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* base, int youngest, WaitingDart* parent, int upper, int start) = 0;
4783+ virtual WaitingDart* GetNextUnexplored() = 0;
4784+ virtual void PopWaiting() = 0;
4785+ virtual void flushBuffer() = 0;
4786+
4787+ inline void SetMaxNumTokensIfGreater(int i) {
4788+ if (i > maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i;
4789+ };
4790+
4791+ public:
4792+ int discoveredMarkings;
4793+ int maxNumTokensInAnyMarking;
4794+ long long stored;
4795+ };
4796+
4797+ class TimeDartLivenessPWHashMap : public TimeDartLivenessPWBase {
4798+ public:
4799+
4800+ TimeDartLivenessPWHashMap() : markings_storage(), waiting_list(){};
4801+
4802+ TimeDartLivenessPWHashMap(VerificationOptions options, WaitingList<WaitingDart>* w_l) : TimeDartLivenessPWBase(), options(options), markings_storage(256000), waiting_list(w_l) {
4803+ };
4804+
4805+ ~TimeDartLivenessPWHashMap() {
4806+ };
4807+ friend std::ostream& operator<<(std::ostream& out, TimeDartLivenessPWHashMap& x);
4808+ virtual std::pair<LivenessDart*, bool> Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* base, int youngest, WaitingDart* parent, int upper, int start);
4809+ virtual WaitingDart* GetNextUnexplored();
4810+ virtual void PopWaiting();
4811+
4812+ virtual bool HasWaitingStates() {
4813+ return (waiting_list->Size() > 0);
4814+ };
4815+ virtual void flushBuffer();
4816+ private:
4817+ VerificationOptions options;
4818+ HashMap markings_storage;
4819+ WaitingList<WaitingDart>* waiting_list;
4820+ };
4821+
4822+ class TimeDartLivenessPWPData : public TimeDartLivenessPWBase {
4823+ public:
4824+
4825+
4826+
4827+ TimeDartLivenessPWPData(VerificationOptions options, WaitingList<EncodingPointer<WaitingDart> >* w_l, boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn, int nplaces, int mage) : TimeDartLivenessPWBase(), options(options), waiting_list(w_l), passed(tapn, options.GetKBound(), nplaces, mage) {
4828+ };
4829+
4830+ ~TimeDartLivenessPWPData() {
4831+ };
4832+ friend std::ostream& operator<<(std::ostream& out, TimeDartLivenessPWHashMap& x);
4833+ virtual std::pair<LivenessDart*, bool> Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* base, int youngest, WaitingDart* parent, int upper, int start);
4834+ virtual WaitingDart* GetNextUnexplored();
4835+ virtual void PopWaiting();
4836+
4837+ virtual bool HasWaitingStates() {
4838+ return (waiting_list->Size() > 0);
4839+ };
4840+ virtual void flushBuffer();
4841+ NonStrictMarkingBase* Decode(EncodingPointer<LivenessDart> *ewp){
4842+ return passed.EnumerateDecode(*ewp);
4843+ }
4844+
4845+ private:
4846+ VerificationOptions options;
4847+ WaitingList<EncodingPointer<WaitingDart> >* waiting_list;
4848+ PData<LivenessDart> passed;
4849+ };
4850+
4851+ } /* namespace DiscreteVerification */
4852+} /* namespace VerifyTAPN */
4853+#endif /* PWLIST_HPP_ */
4854
4855=== added file 'src/DiscreteVerification/DataStructures/TimeDartPWList.cpp'
4856--- src/DiscreteVerification/DataStructures/TimeDartPWList.cpp 1970-01-01 00:00:00 +0000
4857+++ src/DiscreteVerification/DataStructures/TimeDartPWList.cpp 2013-03-31 13:25:26 +0000
4858@@ -0,0 +1,126 @@
4859+/*
4860+ * PWList.cpp
4861+ *
4862+ * Created on: 01/03/2012
4863+ * Author: MathiasGS
4864+ */
4865+
4866+#include "TimeDartPWList.hpp"
4867+
4868+namespace VerifyTAPN {
4869+namespace DiscreteVerification {
4870+
4871+bool TimeDartPWHashMap::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start){
4872+ discoveredMarkings++;
4873+ TimeDartList& m = markings_storage[marking->HashKey()];
4874+ for(TimeDartList::const_iterator iter = m.begin();
4875+ iter != m.end();
4876+ iter++){
4877+ if((*iter)->getBase()->equals(*marking)){
4878+ bool inWaiting = (*iter)->getWaiting() < (*iter)->getPassed();
4879+
4880+ (*iter)->setWaiting(min((*iter)->getWaiting(),youngest));
4881+
4882+ if((*iter)->getWaiting() < (*iter)->getPassed() && !inWaiting){
4883+ waiting_list->Add((*iter)->getBase(),(*iter));
4884+ if(this->trace){
4885+ ((ReachabilityTraceableDart*)(*iter))->trace = new TraceDart((*iter), parent, youngest, start, upper, marking->generatedBy);
4886+ this->last = ((ReachabilityTraceableDart*)(*iter))->trace;
4887+ }
4888+ }
4889+
4890+ delete marking;
4891+
4892+ return false;
4893+ }
4894+ }
4895+ TimeDartBase* dart;
4896+ if(this->trace){
4897+ dart = new ReachabilityTraceableDart(marking, youngest, INT_MAX);
4898+ ((ReachabilityTraceableDart*)dart)->trace = new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy);
4899+ this->last = ((ReachabilityTraceableDart*)(dart))->trace;
4900+ } else {
4901+ dart = new TimeDartBase(marking, youngest, INT_MAX);
4902+ }
4903+ stored++;
4904+ m.push_back(dart);
4905+
4906+ waiting_list->Add(dart->getBase(), dart);
4907+ return true;
4908+}
4909+
4910+TimeDartBase* TimeDartPWHashMap::GetNextUnexplored(){
4911+ return waiting_list->Pop();
4912+}
4913+
4914+bool TimeDartPWPData::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start){
4915+ discoveredMarkings++;
4916+ PData<TimeDartBase>::Result res = passed.Add(marking);
4917+
4918+ if(!res.isNew){
4919+ TimeDartBase* t = res.encoding.GetMetaData();
4920+ bool inWaiting = t->getWaiting() < t->getPassed();
4921+ t->setWaiting(min(t->getWaiting(),youngest));
4922+
4923+ if(t->getWaiting() < t->getPassed() && !inWaiting){
4924+ if(this->trace){
4925+ ((EncodedReachabilityTraceableDart*)t)->trace = new TraceDart(t, parent, youngest, start, upper, marking->generatedBy);
4926+ this->last = ((EncodedReachabilityTraceableDart*)t)->trace;
4927+ }
4928+ waiting_list->Add(marking, new EncodingPointer<TimeDartBase>(res.encoding, res.pos));
4929+ // waiting_list->Add(t->getBase(), t);
4930+ }
4931+ return false;
4932+ }
4933+
4934+
4935+ TimeDartBase* dart;
4936+ if (this->trace) {
4937+ dart = new EncodedReachabilityTraceableDart(marking, youngest, INT_MAX);
4938+ ((EncodedReachabilityTraceableDart*) dart)->trace = new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy);
4939+ this->last = ((ReachabilityTraceableDart*) (dart))->trace;
4940+ } else {
4941+ dart = new TimeDartBase(marking, youngest, INT_MAX);
4942+ }
4943+ stored++;
4944+ res.encoding.SetMetaData(dart);
4945+ EncodingPointer<TimeDartBase>* ep = new EncodingPointer<TimeDartBase>(res.encoding, res.pos);
4946+ waiting_list->Add(marking, ep);
4947+ if (this->trace) {
4948+ // if trace, create new (persistent) encodingpointer as regular one gets deleted every time we pop from waiting.
4949+ ((EncodedReachabilityTraceableDart*) dart)->encoding = new EncodingPointer<TimeDartBase>(res.encoding, res.pos);
4950+ }
4951+// waiting_list->Add(dart->getBase(), dart);
4952+ return true;
4953+}
4954+
4955+TimeDartBase* TimeDartPWPData::GetNextUnexplored(){
4956+
4957+ EncodingPointer<TimeDartBase>* p = waiting_list->Pop();
4958+ NonStrictMarkingBase* m = passed.EnumerateDecode(*p);
4959+ TimeDartBase* dart = p->encoding.GetMetaData();
4960+ dart->setBase(m);
4961+
4962+ p->encoding.Release();
4963+ delete p;
4964+ return dart;
4965+}
4966+
4967+
4968+TimeDartPWHashMap::~TimeDartPWHashMap() {
4969+ // TODO Auto-generated destructor stub
4970+}
4971+
4972+std::ostream& operator<<(std::ostream& out, TimeDartPWHashMap& x){
4973+ out << "Passed and waiting:" << std::endl;
4974+ for(TimeDartPWHashMap::HashMap::iterator iter = x.markings_storage.begin(); iter != x.markings_storage.end(); iter++){
4975+ for(TimeDartPWHashMap::TimeDartList::iterator m_iter = iter->second.begin(); m_iter != iter->second.end(); m_iter++){
4976+ out << "- "<< *m_iter << std::endl;
4977+ }
4978+ }
4979+ out << "Waiting:" << std::endl << x.waiting_list;
4980+ return out;
4981+}
4982+
4983+} /* namespace DiscreteVerification */
4984+} /* namespace VerifyTAPN */
4985
4986=== added file 'src/DiscreteVerification/DataStructures/TimeDartPWList.hpp'
4987--- src/DiscreteVerification/DataStructures/TimeDartPWList.hpp 1970-01-01 00:00:00 +0000
4988+++ src/DiscreteVerification/DataStructures/TimeDartPWList.hpp 2013-03-31 13:25:26 +0000
4989@@ -0,0 +1,112 @@
4990+/*
4991+ * PWList.hpp
4992+ *
4993+ * Created on: 01/03/2012
4994+ * Author: MathiasGS
4995+ */
4996+
4997+#ifndef TIMEDARTPWLIST_HPP_
4998+#define TIMEDARTPWLIST_HPP_
4999+
5000+#include "WaitingList.hpp"
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches