Browse Source

Add message if nothing about monotonicity is known

main
Jip Spel 7 years ago
parent
commit
b0551b540a
  1. 21
      src/storm-pars/analysis/MonotonicityChecker.cpp

21
src/storm-pars/analysis/MonotonicityChecker.cpp

@ -68,15 +68,19 @@ namespace storm {
template <typename ValueType> template <typename ValueType>
std::map<storm::analysis::Lattice*, std::map<carl::Variable, std::pair<bool, bool>>> MonotonicityChecker<ValueType>::checkMonotonicity(std::map<storm::analysis::Lattice*, std::vector<std::shared_ptr<storm::expressions::BinaryRelationExpression>>> map, storm::storage::SparseMatrix<ValueType> matrix) { std::map<storm::analysis::Lattice*, std::map<carl::Variable, std::pair<bool, bool>>> MonotonicityChecker<ValueType>::checkMonotonicity(std::map<storm::analysis::Lattice*, std::vector<std::shared_ptr<storm::expressions::BinaryRelationExpression>>> map, storm::storage::SparseMatrix<ValueType> matrix) {
storm::utility::Stopwatch finalCheckWatch(true); storm::utility::Stopwatch finalCheckWatch(true);
std::map<storm::analysis::Lattice *, std::map<carl::Variable, std::pair<bool, bool>>> result;
if (map.size() == 0) {
STORM_PRINT(std::endl << "Do not know about monotonicity" << std::endl);
} else {
auto i = 0; auto i = 0;
std::map<storm::analysis::Lattice*, std::map<carl::Variable, std::pair<bool, bool>>> result;
for (auto itr = map.begin(); i < map.size() && itr != map.end(); ++itr) { for (auto itr = map.begin(); i < map.size() && itr != map.end(); ++itr) {
auto lattice = itr->first; auto lattice = itr->first;
auto assumptions = itr->second; auto assumptions = itr->second;
std::ofstream myfile; std::ofstream myfile;
std::string filename = "lattice" + std::to_string(i) + ".dot"; std::string filename = "lattice" + std::to_string(i) + ".dot";
myfile.open (filename);
myfile.open(filename);
lattice->toDotFile(myfile); lattice->toDotFile(myfile);
myfile.close(); myfile.close();
@ -99,24 +103,28 @@ namespace storm {
STORM_PRINT(std::endl); STORM_PRINT(std::endl);
} }
std::map<carl::Variable, std::pair<bool, bool>> varsMonotone = analyseMonotonicity(i, lattice, matrix);
std::map<carl::Variable, std::pair<bool, bool>> varsMonotone = analyseMonotonicity(i, lattice,
matrix);
if (varsMonotone.size() == 0) { if (varsMonotone.size() == 0) {
STORM_PRINT("Result is constant" << std::endl); STORM_PRINT("Result is constant" << std::endl);
} else { } else {
for (auto itr2 = varsMonotone.begin(); itr2 != varsMonotone.end(); ++itr2) { for (auto itr2 = varsMonotone.begin(); itr2 != varsMonotone.end(); ++itr2) {
if (resultCheckOnSamples.find(itr2->first) != resultCheckOnSamples.end() && if (resultCheckOnSamples.find(itr2->first) != resultCheckOnSamples.end() &&
(!resultCheckOnSamples[itr2->first].first && !resultCheckOnSamples[itr2->first].second)) {
(!resultCheckOnSamples[itr2->first].first &&
!resultCheckOnSamples[itr2->first].second)) {
STORM_PRINT(" - Not monotone in: " << itr2->first << std::endl); STORM_PRINT(" - Not monotone in: " << itr2->first << std::endl);
} else { } else {
if (itr2->second.first) { if (itr2->second.first) {
STORM_PRINT(" - Monotone increasing in: " << itr2->first << std::endl); STORM_PRINT(" - Monotone increasing in: " << itr2->first << std::endl);
} else { } else {
STORM_PRINT(" - Do not know if monotone increasing in: " << itr2->first << std::endl);
STORM_PRINT(
" - Do not know if monotone increasing in: " << itr2->first << std::endl);
} }
if (itr2->second.second) { if (itr2->second.second) {
STORM_PRINT(" - Monotone decreasing in: " << itr2->first << std::endl); STORM_PRINT(" - Monotone decreasing in: " << itr2->first << std::endl);
} else { } else {
STORM_PRINT(" - Do not know if monotone decreasing in: " << itr2->first << std::endl);
STORM_PRINT(
" - Do not know if monotone decreasing in: " << itr2->first << std::endl);
} }
} }
} }
@ -126,6 +134,7 @@ namespace storm {
} }
++i; ++i;
} }
}
finalCheckWatch.stop(); finalCheckWatch.stop();
STORM_PRINT(std::endl << "Time for monotonicity check on lattice: " << finalCheckWatch << "." << std::endl << std::endl); STORM_PRINT(std::endl << "Time for monotonicity check on lattice: " << finalCheckWatch << "." << std::endl << std::endl);

Loading…
Cancel
Save