本文整理汇总了C++中Condition::analyze方法的典型用法代码示例。如果您正苦于以下问题:C++ Condition::analyze方法的具体用法?C++ Condition::analyze怎么用?C++ Condition::analyze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::analyze方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if(listformulas){
typedef map<string, SUMoQuery>::iterator iter;
for(iter it = queries.begin(); it != queries.end(); it++){
fprintf(stdout, "%s\n", (*it).second.name.c_str());
}
return SuccessCode;
}
// Assign queries and invariant
string formula(queryname);
query = queries[formula].query;
isInvariant = queries[formula].isInvariant;
//Cleanup
typedef map<string, SUMoQuery>::iterator iter;
for(iter it = queries.begin(); it != queries.end(); it++){
if((*it).first != formula)
delete (*it).second.query;
}
}
//----------------------- Models -----------------------//
//Load the model, begin scope to release memory from the stack
PetriNet* net = NULL;
MarkVal* m0 = NULL;
VarVal* v0 = NULL;
{
//Load the model
ifstream modelfile(model, ifstream::in);
if(!modelfile){
fprintf(stderr, "Argument Error: Model file \"%s\" couldn't be opened\n", model);
return ErrorCode;
}
//Read everything
stringstream buffer;
buffer << modelfile.rdbuf();
//Parse and build the petri net
PetriNetBuilder builder(false);
PNMLParser parser;
parser.parse(buffer.str(), &builder);
parser.makePetriNet();
//Build the petri net
net = builder.makePetriNet();
m0 = builder.makeInitialMarking();
v0 = builder.makeInitialAssignment();
// Close the file
modelfile.close();
}
//----------------------- Reachability -----------------------//
//Begin reachability search, begin scope to release memory from the stack
{
//Fallback strategy
int flags = DistanceContext::AndSum | DistanceContext::OrExtreme;
BestFirstReachabilitySearch fallback((DistanceContext::DistanceStrategy)flags);
//Linear Approximation
LinearOverApprox strategy(&fallback);
//Context analysis
{
AnalysisContext context(*net);
query->analyze(context);
for(size_t i = 0; i < context.errors().size(); i++){
fprintf(stderr, "Query Context Analysis Error: %s\n", context.errors()[i].toString().c_str());
}
if(context.errors().size() > 0)
return ErrorCode;
}
ReachabilityResult result = strategy.reachable(*net, m0, v0, query);
//TODO: Double check technique print.. I don't really know what to put here
string techniques("EXPLICIT HEURISTIC");
if(result.result() == ReachabilityResult::Satisfied){
string resultText = isInvariant ? "FALSE" : "TRUE";
fprintf(stdout, "FORMULA %s %s %s\n", queryname, resultText.c_str(), techniques.c_str());
return FailedCode;
}else if(result.result() == ReachabilityResult::NotSatisfied){
string resultText = isInvariant ? "TRUE" : "FALSE";
fprintf(stdout, "FORMULA %s %s %s\n", queryname, resultText.c_str(), techniques.c_str());
return SuccessCode;
} else {
//Unknown. Could not compute.
fprintf(stdout, "CANNOT_COMPUTE\n");
return UnknownCode;
}
}
return UnknownCode;
}