3
#include "PetriNets/OnTheFlyDG.h"
5
#include "DependencyGraph/Edge.h"
7
#include "SearchStrategy/DFSSearch.h"
9
#include "Algorithm/CertainZeroFPA.h"
10
#include "Algorithm/LocalFPA.h"
12
#include "PetriEngine/PQL/PQL.h"
14
#include "Stopwatch.h"
15
#include "PetriEngine/options.h"
16
#include "CTL/Algorithm/AlgorithmTypes.h"
25
using namespace PetriEngine::PQL;
28
ReturnValue getAlgorithm(std::shared_ptr<Algorithm::FixedPointAlgorithm>& algorithm,
29
CTL::CTLAlgorithmType algorithmtype, PetriEngine::Reachability::Strategy search)
33
case CTL::CTLAlgorithmType::Local:
34
algorithm = std::make_shared<Algorithm::LocalFPA>(search);
36
case CTL::CTLAlgorithmType::CZero:
37
algorithm = std::make_shared<Algorithm::CertainZeroFPA>(search);
40
cerr << "Error: Unknown or unsupported algorithm" << endl;
46
void printResult(const std::string& qname, CTLResult& result, bool statisticslevel, bool mccouput, bool only_stats, size_t index, options_t& options){
47
const static string techniques = "TECHNIQUES COLLATERAL_PROCESSING EXPLICIT STATE_COMPRESSION SAT_SMT ";
54
<< " " << (result.result ? "TRUE" : "FALSE") << " "
56
<< (options.isCPN ? "UNFOLDING_TO_PT " : "")
57
<< (options.stubbornreduction ? "STUBBORN_SETS " : "")
58
<< (options.ctlalgorithm == CTL::CZero ? "CTL_CZERO " : "")
59
<< (options.ctlalgorithm == CTL::Local ? "CTL_LOCAL " : "")
61
std::cout << "Query index " << index << " was solved" << std::endl;
62
cout << "Query is" << (result.result ? "" : " NOT") << " satisfied." << endl;
67
cout << "STATS:" << endl;
68
cout << " Time (seconds) : " << setprecision(4) << result.duration / 1000 << endl;
69
cout << " Configurations : " << result.numberOfConfigurations << endl;
70
cout << " Markings : " << result.numberOfMarkings << endl;
71
cout << " Edges : " << result.numberOfEdges << endl;
72
cout << " Processed Edges : " << result.processedEdges << endl;
73
cout << " Processed N. Edges: " << result.processedNegationEdges << endl;
74
cout << " Explored Configs : " << result.exploredConfigurations << endl;
79
ReturnValue CTLMain(PetriEngine::PetriNet* net,
80
CTL::CTLAlgorithmType algorithmtype,
81
PetriEngine::Reachability::Strategy strategytype,
86
const std::vector<std::string>& querynames,
87
const std::vector<std::shared_ptr<Condition>>& queries,
88
const std::vector<size_t>& querynumbers,
93
for(auto qnum : querynumbers){
94
CTLResult result(queries[qnum]);
95
PetriNets::OnTheFlyDG graph(net, partial_order);
96
graph.setQuery(result.query);
97
std::shared_ptr<Algorithm::FixedPointAlgorithm> alg = nullptr;
99
switch(graph.initialEval())
101
case Condition::Result::RFALSE:
102
result.result = false;
105
case Condition::Result::RTRUE:
106
result.result = true;
115
if(getAlgorithm(alg, algorithmtype, strategytype) == ErrorCode)
122
result.result = alg->search(graph);
125
result.duration = timer.duration();
127
result.numberOfConfigurations = graph.configurationCount();
128
result.numberOfMarkings = graph.markingCount();
129
result.processedEdges = alg ? alg->processedEdges() : 0;
130
result.processedNegationEdges = alg ? alg->processedNegationEdges() : 0;
131
result.exploredConfigurations = alg ? alg->exploredConfigurations() : 0;
132
result.numberOfEdges = alg ? alg->numberOfEdges() : 0;
133
printResult(querynames[qnum], result, printstatistics, mccoutput, false, qnum, options);