Browse Source

Merge branch 'master' into prismlang-sim

main
Sebastian Junges 4 years ago
parent
commit
52f88bca4d
  1. 4
      .github/workflows/buildtest.yml
  2. 12
      src/storm-pars/api/region.h
  3. 24
      src/storm-pars/modelchecker/region/SparseParameterLiftingModelChecker.cpp
  4. 8
      src/storm-pars/parser/ParameterRegionParser.cpp
  5. 8
      src/storm-pars/parser/ParameterRegionParser.h
  6. 2
      src/storm-parsers/parser/PrismParser.cpp

4
.github/workflows/buildtest.yml

@ -45,7 +45,7 @@ jobs:
- name: Init Docker - name: Init Docker
run: sudo docker run -d -it --name storm --privileged movesrwth/storm-basesystem:${{ matrix.distro }} run: sudo docker run -d -it --name storm --privileged movesrwth/storm-basesystem:${{ matrix.distro }}
- name: Git clone - name: Git clone
run: sudo docker exec storm git clone --depth 1 --branch $STORM_BRANCH $STORM_GIT_URL /opt/storm run: sudo docker exec storm git clone --branch $STORM_BRANCH $STORM_GIT_URL /opt/storm
- name: Run cmake - name: Run cmake
run: sudo docker exec storm bash -c "mkdir /opt/storm/build; cd /opt/storm/build; cmake .. ${CMAKE_ARGS}" run: sudo docker exec storm bash -c "mkdir /opt/storm/build; cd /opt/storm/build; cmake .. ${CMAKE_ARGS}"
- name: Build storm - name: Build storm
@ -115,7 +115,7 @@ jobs:
# Build & TEST & DEPLOY STORM # Build & TEST & DEPLOY STORM
##### #####
- name: Git clone - name: Git clone
run: sudo docker exec storm git clone --depth 1 --branch $STORM_BRANCH $STORM_GIT_URL /opt/storm run: sudo docker exec storm git clone --branch $STORM_BRANCH $STORM_GIT_URL /opt/storm
- name: Run cmake - name: Run cmake
run: sudo docker exec storm bash -c "mkdir /opt/storm/build; cd /opt/storm/build; cmake .. ${CMAKE_ARGS}" run: sudo docker exec storm bash -c "mkdir /opt/storm/build; cd /opt/storm/build; cmake .. ${CMAKE_ARGS}"
- name: Build storm - name: Build storm

12
src/storm-pars/api/region.h

@ -39,7 +39,7 @@ namespace storm {
}; };
template <typename ValueType> template <typename ValueType>
std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none) { std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none) {
// If the given input string looks like a file (containing a dot and there exists a file with that name), // If the given input string looks like a file (containing a dot and there exists a file with that name),
// we try to parse it as a file, otherwise we assume it's a region string. // we try to parse it as a file, otherwise we assume it's a region string.
if (inputString.find(".") != std::string::npos && std::ifstream(inputString).good()) { if (inputString.find(".") != std::string::npos && std::ifstream(inputString).good()) {
@ -50,12 +50,12 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
storm::storage::ParameterRegion<ValueType> createRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> splittingThreshold= boost::none) { storm::storage::ParameterRegion<ValueType> createRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none) {
return storm::parser::ParameterRegionParser<ValueType>().createRegion(inputString, consideredVariables, splittingThreshold); return storm::parser::ParameterRegionParser<ValueType>().createRegion(inputString, consideredVariables, splittingThreshold);
} }
template <typename ValueType> template <typename ValueType>
std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> splittingThreshold= boost::none) { std::vector<storm::storage::ParameterRegion<ValueType>> parseRegions(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> const& splittingThreshold = boost::none) {
std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters; std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters;
if (model.isSparseModel()) { if (model.isSparseModel()) {
auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model); auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model);
@ -69,7 +69,7 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
std::vector<storm::storage::ParameterRegion<ValueType>> createRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> splittingThreshold= boost::none) { std::vector<storm::storage::ParameterRegion<ValueType>> createRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> const& splittingThreshold = boost::none) {
std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters; std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> modelParameters;
if (model.isSparseModel()) { if (model.isSparseModel()) {
auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model); auto const& sparseModel = dynamic_cast<storm::models::sparse::Model<ValueType> const&>(model);
@ -83,7 +83,7 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> splittingThreshold= boost::none) { storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, std::set<typename storm::storage::ParameterRegion<ValueType>::VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none) {
// Handle the "empty region" case // Handle the "empty region" case
if (inputString == "" && consideredVariables.empty()) { if (inputString == "" && consideredVariables.empty()) {
return storm::storage::ParameterRegion<ValueType>(); return storm::storage::ParameterRegion<ValueType>();
@ -95,7 +95,7 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> splittingThreshold= boost::none) { storm::storage::ParameterRegion<ValueType> parseRegion(std::string const& inputString, storm::models::ModelBase const& model, boost::optional<int> const& splittingThreshold = boost::none) {
// Handle the "empty region" case // Handle the "empty region" case
if (inputString == "" && !model.hasParameters()) { if (inputString == "" && !model.hasParameters()) {
return storm::storage::ParameterRegion<ValueType>(); return storm::storage::ParameterRegion<ValueType>();

24
src/storm-pars/modelchecker/region/SparseParameterLiftingModelChecker.cpp

@ -247,11 +247,8 @@ namespace storm {
storm::utility::Stopwatch boundsWatch(false); storm::utility::Stopwatch boundsWatch(false);
auto numberOfPLACallsBounds = 0; auto numberOfPLACallsBounds = 0;
ConstantType initBound; ConstantType initBound;
if (minimize) { initBound = storm::utility::zero<ConstantType>();
initBound = storm::utility::zero<ConstantType>(); bool first = true;
} else {
initBound = storm::utility::one<ConstantType>();
}
if (useMonotonicity) { if (useMonotonicity) {
if (this->isUseBoundsSet()) { if (this->isUseBoundsSet()) {
numberOfPLACallsBounds++; numberOfPLACallsBounds++;
@ -273,17 +270,10 @@ namespace storm {
monotonicityWatch.stop(); monotonicityWatch.stop();
STORM_LOG_INFO(std::endl << "Total time for monotonicity checking: " << monotonicityWatch << "." << std::endl << std::endl); STORM_LOG_INFO(std::endl << "Total time for monotonicity checking: " << monotonicityWatch << "." << std::endl << std::endl);
if (minimize) { regionQueue.emplace(region, order, monRes, initBound);
regionQueue.emplace(region, order, monRes, initBound); first = false;
} else {
regionQueue.emplace(region, order, monRes, initBound);
}
} else { } else {
if (minimize) { regionQueue.emplace(region, nullptr, nullptr, initBound);
regionQueue.emplace(region, nullptr, nullptr, initBound);
} else {
regionQueue.emplace(region, nullptr, nullptr, initBound);
}
} }
// The results // The results
@ -309,7 +299,6 @@ namespace storm {
auto numberOfPLACalls = 0; auto numberOfPLACalls = 0;
auto numberOfOrderCopies = 0; auto numberOfOrderCopies = 0;
auto numberOfMonResCopies = 0; auto numberOfMonResCopies = 0;
bool first = true;
storm::utility::Stopwatch loopWatch(true); storm::utility::Stopwatch loopWatch(true);
if (!(useMonotonicity && regionQueue.top().localMonRes->getGlobalMonotonicityResult()->isDone() && regionQueue.top().localMonRes->getGlobalMonotonicityResult()->isAllMonotonicity())) { if (!(useMonotonicity && regionQueue.top().localMonRes->getGlobalMonotonicityResult()->isDone() && regionQueue.top().localMonRes->getGlobalMonotonicityResult()->isAllMonotonicity())) {
// Doing the extremal computation, only when we don't use monotonicity or there are possibly not monotone variables. // Doing the extremal computation, only when we don't use monotonicity or there are possibly not monotone variables.
@ -325,8 +314,9 @@ namespace storm {
std::vector<storm::storage::ParameterRegion<typename SparseModelType::ValueType>> newRegions; std::vector<storm::storage::ParameterRegion<typename SparseModelType::ValueType>> newRegions;
// Check whether this region needs further investigation based on the bound of the parent region // Check whether this region needs further investigation based on the bound of the parent region
bool investigateBounds = (minimize && currBound < value.get() - storm::utility::convertNumber<ConstantType>(precision)) bool investigateBounds = first || (minimize && currBound < value.get() - storm::utility::convertNumber<ConstantType>(precision))
|| (!minimize && currBound > value.get() + storm::utility::convertNumber<ConstantType>(precision)); || (!minimize && currBound > value.get() + storm::utility::convertNumber<ConstantType>(precision));
first = false;
if (investigateBounds) { if (investigateBounds) {
numberOfPLACalls++; numberOfPLACalls++;
auto bounds = getBound(env, currRegion, dir, localMonotonicityResult)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector(); auto bounds = getBound(env, currRegion, dir, localMonotonicityResult)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();

8
src/storm-pars/parser/ParameterRegionParser.cpp

@ -42,7 +42,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
Valuation lowerBoundaries; Valuation lowerBoundaries;
Valuation upperBoundaries; Valuation upperBoundaries;
std::vector<std::string> parameterBoundaries; std::vector<std::string> parameterBoundaries;
@ -66,7 +66,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { storm::storage::ParameterRegion<ParametricType> ParameterRegionParser<ParametricType>::createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
Valuation lowerBoundaries; Valuation lowerBoundaries;
Valuation upperBoundaries; Valuation upperBoundaries;
std::vector<std::string> parameterBoundaries; std::vector<std::string> parameterBoundaries;
@ -84,7 +84,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
std::vector<storm::storage::ParameterRegion<ParametricType>> result; std::vector<storm::storage::ParameterRegion<ParametricType>> result;
std::vector<std::string> regionsStrVec; std::vector<std::string> regionsStrVec;
boost::split(regionsStrVec, regionsString, boost::is_any_of(";")); boost::split(regionsStrVec, regionsString, boost::is_any_of(";"));
@ -97,7 +97,7 @@ namespace storm {
} }
template<typename ParametricType> template<typename ParametricType>
std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold) { std::vector<storm::storage::ParameterRegion<ParametricType>> ParameterRegionParser<ParametricType>::parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold) {
// Open file and initialize result. // Open file and initialize result.
std::ifstream inputFileStream; std::ifstream inputFileStream;

8
src/storm-pars/parser/ParameterRegionParser.h

@ -25,21 +25,21 @@ namespace storm {
* Parse a single region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7". * Parse a single region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7".
* *
*/ */
static storm::storage::ParameterRegion<ParametricType> parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static storm::storage::ParameterRegion<ParametricType> parseRegion(std::string const& regionString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
static storm::storage::ParameterRegion<ParametricType> createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static storm::storage::ParameterRegion<ParametricType> createRegion(std::string const& regionBound, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
/* /*
* Parse a vector of region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7;0.1<=p<=0.3,0.2<=q<=0.4". * Parse a vector of region from a string of the form "0.3<=p<=0.5,0.4<=q<=0.7;0.1<=p<=0.3,0.2<=q<=0.4".
* *
*/ */
static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegions(std::string const& regionsString, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
/* /*
* Parse multiple regions from a file * Parse multiple regions from a file
* *
*/ */
static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> splittingThreshold = boost::none); static std::vector<storm::storage::ParameterRegion<ParametricType>> parseMultipleRegionsFromFile(std::string const& fileName, std::set<VariableType> const& consideredVariables, boost::optional<int> const& splittingThreshold = boost::none);
}; };
} }

2
src/storm-parsers/parser/PrismParser.cpp

@ -453,7 +453,7 @@ namespace storm {
return false; return false;
} }
return true; return true;
}; }
bool PrismParser::isFreshIdentifier(std::string const& identifier) { bool PrismParser::isFreshIdentifier(std::string const& identifier) {
if (!this->secondRun && this->manager->hasVariable(identifier)) { if (!this->secondRun && this->manager->hasVariable(identifier)) {

|||||||
100:0
Loading…
Cancel
Save