46template<
typename ValueType, storm::dd::DdType DdType>
50 bool preprocessingPerformed =
false;
51 if (pomdpSettings.isSelfloopReductionSet()) {
55 uint64_t oldChoiceCount = pomdp->getNumberOfChoices();
57 STORM_PRINT_AND_LOG(oldChoiceCount - pomdp->getNumberOfChoices() <<
" choices eliminated through self-loop elimination.\n");
58 preprocessingPerformed =
true;
60 STORM_PRINT_AND_LOG(
"Not eliminating self-loop choices as it does not preserve the formula.\n");
67 std::cout << prob0States <<
'\n';
73 pomdp = kpt.
transform(*pomdp, prob0States, prob1States);
77 preprocessingPerformed =
true;
79 return preprocessingPerformed;
82template<
typename ValueType>
83void printResult(ValueType
const& lowerBound, ValueType
const& upperBound) {
84 if (lowerBound == upperBound) {
90 }
else if (storm::utility::isInfinity<ValueType>(-lowerBound)) {
100 STORM_PRINT_AND_LOG(
"[" << lowerBound <<
", " << upperBound <<
"] (width=" << ValueType(upperBound - lowerBound) <<
")");
104 double roundedLowerBound =
105 storm::utility::isInfinity<ValueType>(-lowerBound) ? -storm::utility::infinity<double>() : storm::utility::convertNumber<double>(lowerBound);
106 double roundedUpperBound =
107 storm::utility::isInfinity(upperBound) ? storm::utility::infinity<double>() : storm::utility::convertNumber<double>(upperBound);
118 uint64_t loglevel = 0;
133 if (qualSettings.isExportSATCallsSet()) {
140template<
typename ValueType>
145 std::stringstream sstr;
146 origpomdp->printModelInformationToStream(sstr);
149 "Qualitative memoryless scheduler search is not implemented for this property type.");
157 bool computedSomething =
false;
158 if (qualSettings.isMemlessSearchSet()) {
159 computedSomething =
true;
160 std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
161 uint64_t lookahead = qualSettings.getLookahead();
162 if (lookahead == 0) {
165 if (qualSettings.getMemlessSearchMethod() ==
"one-shot") {
167 if (qualSettings.isWinningRegionSet()) {
168 STORM_LOG_ERROR(
"Computing winning regions is not supported by the one-shot method.");
177 }
else if (qualSettings.getMemlessSearchMethod() ==
"iterative") {
180 if (qualSettings.isWinningRegionSet()) {
192 if (qualSettings.isPrintWinningRegionSet()) {
196 if (qualSettings.isExportWinningRegionSet()) {
197 std::size_t hash = pomdp.
hash();
208 if (state == initialState) {
222 STORM_LOG_WARN(
"Output for multiple initial states is incomplete");
225 if (coreSettings.isShowStatisticsSet()) {
227 if (qualSettings.computeExpensiveStats()) {
229 STORM_PRINT_AND_LOG(
"#STATS Number of winning belief support states: [" << wbss.first <<
"," << wbss.second <<
"]");
238 if (qualSettings.isComputeOnBeliefSupportSet()) {
239 computedSomething =
true;
241 janicreator.
generate(targetStates, surelyNotAlmostSurelyReachTarget);
242 bool initialOnly = !qualSettings.isWinningRegionSet();
246 STORM_LOG_THROW(computedSomething, storm::exceptions::InvalidSettingsException,
"Nothing to be done, did you forget to set a method?");
249template<
typename ValueType, storm::dd::DdType DdType,
typename BeliefType>
253 bool analysisPerformed =
false;
254 if (pomdpSettings.isBeliefExplorationSet()) {
257 pomdpSettings.isBeliefExplorationUnfoldSet());
259 beliefExplorationSettings.setValuesInOptionsStruct(options);
261 auto result = checker.
check(formula);
270 analysisPerformed =
true;
272 if (pomdpSettings.isQualitativeAnalysisSet()) {
274 analysisPerformed =
true;
276 if (pomdpSettings.isCheckFullyObservableSet()) {
281 auto result = resultPtr->template asExplicitQuantitativeCheckResult<ValueType>();
293 analysisPerformed =
true;
295 return analysisPerformed;
298template<
typename ValueType, storm::dd::DdType DdType>
303 bool transformationPerformed =
false;
304 bool memoryUnfolded =
false;
305 if (pomdpSettings.getMemoryBound() > 1) {
306 STORM_PRINT_AND_LOG(
"Computing the unfolding for memory bound " << pomdpSettings.getMemoryBound() <<
" and memory pattern '"
309 std::cout << memory.
toString() <<
'\n';
313 pomdp->printModelInformationToStream(std::cout);
314 transformationPerformed =
true;
315 memoryUnfolded =
true;
320 if (transformSettings.isMecReductionSet()) {
323 uint64_t oldChoiceCount = pomdp->getNumberOfChoices();
325 pomdp = mecChoiceEliminator.
transform(formula);
327 STORM_PRINT_AND_LOG(oldChoiceCount - pomdp->getNumberOfChoices() <<
" choices eliminated through MEC choice elimination.\n");
328 pomdp->printModelInformationToStream(std::cout);
329 transformationPerformed =
true;
332 if (transformSettings.isTransformBinarySet() || transformSettings.isTransformSimpleSet()) {
333 if (transformSettings.isTransformSimpleSet()) {
340 pomdp->printModelInformationToStream(std::cout);
342 transformationPerformed =
true;
345 if (pomdpSettings.isExportToParametricSet()) {
348 std::string transformMode = transformSettings.getFscApplicationTypeString();
351 if (transformSettings.allowPostSimplifications()) {
355 ->template as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
357 pmc->printModelInformationToStream(std::cout);
362 std::vector<storm::RationalFunctionVariable> parameters(parameterSet.begin(), parameterSet.end());
363 std::vector<std::string> parameterNames;
364 for (
auto const& parameter : parameters) {
365 parameterNames.push_back(parameter.name());
368 !ioSettings.isExplicitExportPlaceholdersDisabled());
370 transformationPerformed =
true;
372 if (transformationPerformed && !memoryUnfolded) {
373 STORM_PRINT_AND_LOG(
"Implicitly assumed restriction to memoryless schedulers for at least one transformation.\n");
375 return transformationPerformed;
378template<
typename ValueType, storm::dd::DdType DdType>
382 auto model = storm::cli::buildPreprocessExportModelWithValueTypeAndDdlib<DdType, ValueType>(symbolicInput, mpi);
388 "Expected a POMDP in sparse representation.");
390 std::shared_ptr<storm::models::sparse::Pomdp<ValueType>> pomdp = model->template as<storm::models::sparse::Pomdp<ValueType>>();
392 std::shared_ptr<storm::logic::Formula const> formula;
394 formula = symbolicInput.
properties.front().getRawFormula();
397 "There is currently no support for multiple properties. All other properties will be ignored.");
400 if (!pomdpSettings.isNoCanonicSet()) {
405 if (pomdpSettings.isAnalyzeUniqueObservationsSet()) {
408 std::cout << uniqueAnalysis.
analyse() <<
'\n';
413 STORM_LOG_THROW(!formulaInfo.isUnsupported(), storm::exceptions::InvalidPropertyException,
414 "The formula '" << *formula <<
"' is not supported by storm-pomdp.");
418 if (performPreprocessing<ValueType, DdType>(pomdp, formulaInfo, *formula)) {
421 pomdp->printModelInformationToStream(std::cout);
425 if (performTransformation<ValueType, DdType>(pomdp, *formula)) {
431 if (performAnalysis<ValueType, DdType, ValueType>(pomdp, formulaInfo, *formula)) {
436 STORM_LOG_WARN(
"Nothing to be done. Did you forget to specify a formula?");
440template<storm::dd::DdType DdType>
443 "Build value type differs from verification value type. Will ignore Verification value type.");
446 processOptionsWithValueTypeAndDdLib<double, DdType>(symbolicInput, mpi);
450 "Exact arithmetic is only supported with Dd library Sylvan.");
451 processOptionsWithValueTypeAndDdLib<storm::RationalNumber, storm::dd::DdType::Sylvan>(symbolicInput, mpi);
454 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unexpected ValueType for model building.");
464 processOptionsWithDdLib<storm::dd::DdType::CUDD>(symbolicInput, mpi);
467 processOptionsWithDdLib<storm::dd::DdType::Sylvan>(symbolicInput, mpi);
470 STORM_LOG_THROW(
false, storm::exceptions::UnexpectedException,
"Unexpected Dd Type.");
484int main(
const int argc,
const char** argv) {
Class to collect constraints on parametric Markov chains.
std::set< storm::RationalFunctionVariable > const & getVariables() const
Returns the set of variables in the model.
storm::storage::BitVector analyseProb0(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyseProbSmaller1(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyseProb1(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyse() const
This class represents a discrete-time Markov chain.
This class represents a (discrete-time) Markov decision process.
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
storm::storage::BitVector const & getInitialStates() const
Retrieves the initial states of the model.
This class represents a partially observable Markov decision process.
virtual std::size_t hash() const override
uint32_t getObservation(uint64_t state) const
bool analyzeForInitialStates(uint64_t k)
void computeWinningRegion(uint64_t k)
Statistics const & getStatistics() const
void finalizeStatistics()
WinningRegion const & getLastWinningRegion() const
void setDebugLevel(uint64_t level=1)
void setExportSATCalls(std::string const &path)
bool onlyDeterministicStrategies
MemlessSearchPathVariables pathVariableType
bool analyzeForInitialStates(uint64_t k)
Check if you can find a memoryless policy from the initial states.
std::pair< storm::RationalNumber, storm::RationalNumber > computeNrWinningBeliefs() const
storm::RationalNumber beliefSupportStates() const
bool isWinning(uint64_t observation, uint64_t offset) const
void storeToFile(std::string const &path, std::string const &preamble="", bool append=false) const
Model checker for checking reachability queries on POMDPs using approximations based on exploration o...
Result check(storm::Environment const &env, storm::logic::Formula const &formula, storm::Environment const &preProcEnv, std::vector< std::vector< std::unordered_map< uint64_t, ValueType > > > const &additionalUnderApproximationBounds=std::vector< std::vector< std::unordered_map< uint64_t, ValueType > > >())
Performs model checking of the given POMDP with regards to a formula using the previously specified o...
void printStatisticsToStream(std::ostream &stream) const
Prints statistics of the process to a given output stream.
void verifySymbolic(bool onlyInitial=true)
bool isInitialWinning() const
void generate(storm::storage::BitVector const &targetStates, storm::storage::BitVector const &badStates)
A bit vector that is internally represented as a vector of 64-bit values.
uint_fast64_t getNextSetIndex(uint_fast64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to true in the bit vector.
uint_fast64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
PomdpMemory build(PomdpMemoryPattern pattern, uint64_t numStates) const
std::string toString() const
A class that provides convenience operations to display run times.
void restart()
Reset the stopwatch and immediately start it.
void stop()
Stop stopwatch and add measured time to total time.
#define STORM_LOG_INFO(message)
#define STORM_LOG_WARN(message)
#define STORM_LOG_TRACE(message)
#define STORM_LOG_ERROR(message)
#define STORM_LOG_WARN_COND(cond, message)
#define STORM_LOG_ERROR_COND(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
#define STORM_PRINT_AND_LOG(message)
void exportSparseModelAsDrn(std::shared_ptr< storm::models::sparse::Model< ValueType > > const &model, std::string const &filename, std::vector< std::string > const ¶meterNames={}, bool allowPlaceholders=true)
SymbolicInput parseSymbolicInput()
int process(std::string const &name, std::string const &executableName, std::function< void(std::string const &, std::string const &)> initSettingsFunc, std::function< void(void)> processOptionsFunc, const int argc, const char **argv)
Processes the options and returns the exit code.
std::pair< SymbolicInput, ModelProcessingInformation > preprocessSymbolicInput(SymbolicInput const &input)
FormulaInformation getFormulaInformation(PomdpType const &pomdp, storm::logic::ProbabilityOperatorFormula const &formula)
MemlessSearchOptions fillMemlessSearchOptionsFromSettings()
void processOptionsWithValueTypeAndDdLib(storm::cli::SymbolicInput const &symbolicInput, storm::cli::ModelProcessingInformation const &mpi)
void processOptionsWithDdLib(storm::cli::SymbolicInput const &symbolicInput, storm::cli::ModelProcessingInformation const &mpi)
void performQualitativeAnalysis(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > const &origpomdp, storm::pomdp::analysis::FormulaInformation const &formulaInfo, storm::logic::Formula const &formula)
void printResult(ValueType const &lowerBound, ValueType const &upperBound)
bool performTransformation(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &pomdp, storm::logic::Formula const &formula)
bool performPreprocessing(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > &pomdp, storm::pomdp::analysis::FormulaInformation &formulaInfo, storm::logic::Formula const &formula)
Perform preprocessings based on the graph structure (if requested or necessary). Return true,...
bool performAnalysis(std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > const &pomdp, storm::pomdp::analysis::FormulaInformation const &formulaInfo, storm::logic::Formula const &formula)
MemlessSearchPathVariables pathVariableTypeFromString(std::string const &in)
void initializePomdpSettings(std::string const &name, std::string const &executableName)
Initialize the settings manager.
SettingsType const & getModule()
Get module.
std::string toString(PomdpMemoryPattern const &pattern)
bool isTerminate()
Check whether the program should terminate (due to some abort signal).
bool isInfinity(ValueType const &a)
l3pp::LogLevel getLogLevel()
Gets the global log level.
int main(const int argc, const char **argv)
Entry point for the pomdp backend.