Browse Source
added export of constraints and resultfile
added export of constraints and resultfile
Former-commit-id: 9389adfeae
tempestpy_adaptions
sjunges
10 years ago
11 changed files with 307 additions and 23 deletions
-
3src/adapters/extendedCarl.h
-
63src/modelchecker/reachability/CollectConstraints.h
-
2src/modelchecker/reachability/DirectEncoding.h
-
8src/settings/Option.h
-
43src/settings/modules/ParametricSettings.cpp
-
45src/settings/modules/ParametricSettings.h
-
5src/storage/parameters.h
-
48src/stormParametric.cpp
-
8src/utility/cli.h
-
52src/utility/constants.h
-
51src/utility/export.h
@ -0,0 +1,63 @@ |
|||||
|
/** |
||||
|
* @file: CollectConstraints.h |
||||
|
* @author: Sebastian Junges |
||||
|
* |
||||
|
* @since October 8, 2014 |
||||
|
*/ |
||||
|
|
||||
|
#pragma once |
||||
|
#include "src/models/Dtmc.h" |
||||
|
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace modelchecker { |
||||
|
namespace reachability { |
||||
|
template<typename ValueType> |
||||
|
class CollectConstraints |
||||
|
{ |
||||
|
private: |
||||
|
std::unordered_set<carl::Constraint<ValueType>> wellformedConstraintSet; |
||||
|
std::unordered_set<carl::Constraint<ValueType>> graphPreservingConstraintSet; |
||||
|
|
||||
|
public: |
||||
|
std::unordered_set<carl::Constraint<ValueType>> const& wellformedConstraints() const { |
||||
|
return this->wellformedConstraintSet; |
||||
|
} |
||||
|
|
||||
|
std::unordered_set<carl::Constraint<ValueType>> const& graphPreservingConstraints() const { |
||||
|
return this->graphPreservingConstraintSet; |
||||
|
} |
||||
|
|
||||
|
void process(storm::models::Dtmc<ValueType> const& dtmc) |
||||
|
{ |
||||
|
for(uint_fast64_t state = 0; state < dtmc.getNumberOfStates(); ++state) |
||||
|
{ |
||||
|
ValueType sum; |
||||
|
assert(storm::utility::isZero(sum)); |
||||
|
for(auto const& transition : dtmc.getRows(state)) |
||||
|
{ |
||||
|
sum += transition.getValue(); |
||||
|
if(!transition.getValue().isConstant()) |
||||
|
{ |
||||
|
wellformedConstraintSet.emplace(transition.getValue() - 1, storm::CompareRelation::LEQ); |
||||
|
wellformedConstraintSet.emplace(transition.getValue(), storm::CompareRelation::GEQ); |
||||
|
graphPreservingConstraintSet.emplace(transition.getValue(), storm::CompareRelation::GT); |
||||
|
} |
||||
|
} |
||||
|
assert(!sum.isConstant() || storm::utility::isOne(sum)); |
||||
|
if(!sum.isConstant()) { |
||||
|
wellformedConstraintSet.emplace(sum - 1, storm::CompareRelation::EQ); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void operator()(storm::models::Dtmc<ValueType> const& dtmc) |
||||
|
{ |
||||
|
process(dtmc); |
||||
|
} |
||||
|
|
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
/** |
||||
|
* @file: export.h |
||||
|
* @author: Sebastian Junges |
||||
|
* |
||||
|
* @since October 7, 2014 |
||||
|
*/ |
||||
|
|
||||
|
#ifndef STORM_UTILITY_EXPORT_H_ |
||||
|
#define STORM_UTILITY_EXPORT_H_ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
#include "src/storage/parameters.h" |
||||
|
#include "src/settings/modules/ParametricSettings.h" |
||||
|
#include "src/modelchecker/reachability/CollectConstraints.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace utility { |
||||
|
|
||||
|
template<typename ValueType> |
||||
|
void exportParametricMcResult(const ValueType& mcresult, storm::modelchecker::reachability::CollectConstraints<storm::RationalFunction> const& constraintCollector) { |
||||
|
std::string path = storm::settings::parametricSettings().exportResultPath(); |
||||
|
std::ofstream filestream; |
||||
|
filestream.open(path); |
||||
|
// todo add checks. |
||||
|
filestream << "!Parameters: "; |
||||
|
std::set<storm::Variable> vars = mcresult.gatherVariables(); |
||||
|
std::copy(vars.begin(), vars.end(), std::ostream_iterator<storm::Variable>(filestream, " ")); |
||||
|
filestream << std::endl; |
||||
|
filestream << "!Result: " << mcresult << std::endl; |
||||
|
filestream << "!Well-formed Constraints: " << std::endl; |
||||
|
std::copy(constraintCollector.wellformedConstraints().begin(), constraintCollector.wellformedConstraints().end(), std::ostream_iterator<carl::Constraint<ValueType>>(filestream, "\n")); |
||||
|
filestream << "!Graph-preserving Constraints: " << std::endl; |
||||
|
std::copy(constraintCollector.graphPreservingConstraints().begin(), constraintCollector.graphPreservingConstraints().end(), std::ostream_iterator<carl::Constraint<ValueType>>(filestream, "\n")); |
||||
|
filestream.close(); |
||||
|
} |
||||
|
|
||||
|
void exportStringStreamToFile(std::stringstream& stream, std::string filepath) { |
||||
|
// todo add checks. |
||||
|
std::ofstream filestream; |
||||
|
filestream.open(filepath); |
||||
|
filestream << stream.str(); |
||||
|
filestream.close(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue