Browse Source

Added option to specify one global capacity for all places of a gspn

tempestpy_adaptions
TimQu 6 years ago
parent
commit
629c305456
  1. 7
      src/storm-gspn-cli/storm-gspn.cpp
  2. 15
      src/storm-gspn/settings/modules/GSPNSettings.cpp
  3. 11
      src/storm-gspn/settings/modules/GSPNSettings.h

7
src/storm-gspn-cli/storm-gspn.cpp

@ -110,6 +110,13 @@ int main(const int argc, const char **argv) {
if(storm::settings::getModule<storm::settings::modules::GSPNSettings>().isCapacitiesFileSet()) {
auto capacities = parseCapacitiesList(storm::settings::getModule<storm::settings::modules::GSPNSettings>().getCapacitiesFilename());
gspn->setCapacities(capacities);
} else if (storm::settings::getModule<storm::settings::modules::GSPNSettings>().isCapacitySet()) {
uint64_t capacity = storm::settings::getModule<storm::settings::modules::GSPNSettings>().getCapacity();
std::unordered_map<std::string, uint64_t> capacities;
for (auto const& place : gspn->getPlaces()) {
capacities.emplace(place.getName(), capacity);
}
gspn->setCapacities(capacities);
}
storm::api::handleGSPNExportSettings(*gspn, [&](storm::builder::JaniGSPNBuilder const&) { return properties; });

15
src/storm-gspn/settings/modules/GSPNSettings.cpp

@ -18,11 +18,13 @@ namespace storm {
const std::string GSPNSettings::gspnFileOptionShortName = "gspn";
const std::string GSPNSettings::capacitiesFileOptionName = "capacitiesfile";
const std::string GSPNSettings::capacitiesFileOptionShortName = "capacities";
const std::string GSPNSettings::capacityOptionName = "capacity";
GSPNSettings::GSPNSettings() : ModuleSettings(moduleName) {
this->addOption(storm::settings::OptionBuilder(moduleName, gspnFileOptionName, false, "Parses the GSPN.").setShortName(gspnFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidatorString(ArgumentValidatorFactory::createExistingFileValidator()).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, capacitiesFileOptionName, false, "Capacaties as invariants for places.").setShortName(capacitiesFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidatorString(ArgumentValidatorFactory::createExistingFileValidator()).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, capacityOptionName, false, "Global capacity as invariants for all places.").addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("value", "capacity").build()).build());
}
bool GSPNSettings::isGspnFileSet() const {
@ -41,6 +43,14 @@ namespace storm {
return this->getOption(capacitiesFileOptionName).getArgumentByName("filename").getValueAsString();
}
bool GSPNSettings::isCapacitySet() const {
return this->getOption(capacityOptionName).getHasOptionBeenSet();
}
uint64_t GSPNSettings::getCapacity() const {
return this->getOption(capacityOptionName).getArgumentByName("value").getValueAsUnsignedInteger();
}
void GSPNSettings::finalize() {
}
@ -51,6 +61,11 @@ namespace storm {
return false;
}
}
if (isCapacitiesFileSet() && isCapacitySet()) {
STORM_LOG_ERROR("Conflicting settings: Capacity file AND capacity was set.");
return false;
}
return true;
}
}

11
src/storm-gspn/settings/modules/GSPNSettings.h

@ -34,6 +34,16 @@ namespace storm {
*/
std::string getCapacitiesFilename() const;
/**
* Retrievew whether a global capacity was set
*/
bool isCapacitySet() const;
/**
* Retrieves the global capacity
*/
uint64_t getCapacity() const;
bool check() const override;
void finalize() override;
@ -45,6 +55,7 @@ namespace storm {
static const std::string gspnFileOptionShortName;
static const std::string capacitiesFileOptionName;
static const std::string capacitiesFileOptionShortName;
static const std::string capacityOptionName;
};
}

Loading…
Cancel
Save