You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

153 lines
7.3 KiB

#pragma once
#include "storm/logic/Formula.h"
#include "storm/modelchecker/results/CheckResult.h"
#include "storm/api/storm.h"
#include "storm/utility/Stopwatch.h"
#include "storm-dft/storage/dft/DFT.h"
namespace storm {
namespace modelchecker {
/*!
* Analyser for DFTs.
*/
template<typename ValueType>
class DFTModelChecker {
public:
typedef std::pair<ValueType, ValueType> approximation_result;
typedef std::vector<boost::variant<ValueType, approximation_result>> dft_results;
typedef std::vector<std::shared_ptr<storm::logic::Formula const>> property_vector;
class ResultOutputVisitor : public boost::static_visitor<std::string> {
public:
std::string operator()(ValueType result) const {
std::stringstream stream;
stream << result;
return stream.str();
}
std::string operator()(std::pair<ValueType, ValueType> const& result) const {
std::stringstream stream;
stream << "(" << result.first << ", " << result.second << ")";
return stream.str();
}
};
/*!
* Constructor.
*/
DFTModelChecker(bool printOutput) : printInfo(printOutput) {
}
/*!
* Main method for checking DFTs.
*
* @param origDft Original DFT.
* @param properties Properties to check for.
* @param symred Flag whether symmetry reduction should be used.
* @param allowModularisation Flag indicating if modularisation is allowed.
* @param relevantEvents List with ids of relevant events which should be observed.
* @param approximationError Error allowed for approximation. Value 0 indicates no approximation.
* @param approximationHeuristic Heuristic used for state space exploration.
* @return Model checking results for the given properties..
*/
dft_results check(storm::storage::DFT<ValueType> const& origDft, property_vector const& properties, bool symred = true, bool allowModularisation = true, std::set<size_t> const& relevantEvents = {}, double approximationError = 0.0, storm::builder::ApproximationHeuristic approximationHeuristic = storm::builder::ApproximationHeuristic::DEPTH);
/*!
* Print timings of all operations to stream.
*
* @param os Output stream to write to.
*/
void printTimings(std::ostream& os = std::cout);
/*!
* Print result to stream.
*
* @param results List of results.
* @param os Output stream to write to.
*/
void printResults(dft_results const& results, std::ostream& os = std::cout);
private:
bool printInfo;
// Timing values
storm::utility::Stopwatch buildingTimer;
storm::utility::Stopwatch explorationTimer;
storm::utility::Stopwatch bisimulationTimer;
storm::utility::Stopwatch modelCheckingTimer;
storm::utility::Stopwatch totalTimer;
/*!
* Internal helper for model checking a DFT.
*
* @param dft DFT.
* @param properties Properties to check for.
* @param symred Flag indicating if symmetry reduction should be used.
* @param allowModularisation Flag indicating if modularisation is allowed.
* @param relevantEvents List with ids of relevant events which should be observed.
* @param approximationError Error allowed for approximation. Value 0 indicates no approximation.
* @param approximationHeuristic Heuristic used for approximation.
* @return Model checking results (or in case of approximation two results for lower and upper bound)
*/
dft_results checkHelper(storm::storage::DFT<ValueType> const& dft, property_vector const& properties, bool symred, bool allowModularisation, std::set<size_t> const& relevantEvents, double approximationError, storm::builder::ApproximationHeuristic approximationHeuristic = storm::builder::ApproximationHeuristic::DEPTH);
/*!
* Internal helper for building a CTMC from a DFT via parallel composition.
*
* @param dft DFT.
* @param properties Properties to check for.
* @param symred Flag indicating if symmetry reduction should be used.
* @param allowModularisation Flag indicating if modularisation is allowed.
* @param relevantEvents List with ids of relevant events which should be observed.
* @return CTMC representing the DFT
*/
std::shared_ptr<storm::models::sparse::Ctmc<ValueType>> buildModelViaComposition(storm::storage::DFT<ValueType> const& dft, property_vector const& properties, bool symred, bool allowModularisation, std::set<size_t> const& relevantEvents);
/*!
* Check model generated from DFT.
*
* @param dft The DFT.
* @param properties Properties to check for.
* @param symred Flag indicating if symmetry reduction should be used.
* @param relevantEvents List with ids of relevant events which should be observed.
* @param approximationError Error allowed for approximation. Value 0 indicates no approximation.
* @param approximationHeuristic Heuristic used for approximation.
*
* @return Model checking result
*/
dft_results checkDFT(storm::storage::DFT<ValueType> const& dft, property_vector const& properties, bool symred, std::set<size_t> const& relevantEvents = {}, double approximationError = 0.0, storm::builder::ApproximationHeuristic approximationHeuristic = storm::builder::ApproximationHeuristic::DEPTH);
/*!
* Check the given markov model for the given properties.
*
* @param model Model to check
* @param properties Properties to check for
*
* @return Model checking result
*/
std::vector<ValueType> checkModel(std::shared_ptr<storm::models::sparse::Model<ValueType>>& model, property_vector const& properties);
/*!
* Checks if the computed approximation is sufficient, i.e.
* upperBound - lowerBound <= approximationError * mean(lowerBound, upperBound).
*
* @param lowerBound The lower bound on the result.
* @param upperBound The upper bound on the result.
* @param approximationError The allowed error for approximating.
* @param relative Flag indicating if the error should be relative to 1 or
to the mean of lower and upper bound.
*
* @return True, if the approximation is sufficient.
*/
bool isApproximationSufficient(ValueType lowerBound, ValueType upperBound, double approximationError, bool relative);
};
}
}