diff --git a/src/counterexamples/MILPMinimalLabelSetGenerator.h b/src/counterexamples/MILPMinimalLabelSetGenerator.h index 04face217..d98025597 100644 --- a/src/counterexamples/MILPMinimalLabelSetGenerator.h +++ b/src/counterexamples/MILPMinimalLabelSetGenerator.h @@ -1025,7 +1025,7 @@ namespace storm { // Delegate the actual computation work to the function of equal name. auto startTime = std::chrono::high_resolution_clock::now(); - boost::container::flat_set usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, bound, strictBound, true, storm::settings::counterexampleGeneratorSettings().useSchedulerCuts()); + boost::container::flat_set usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, bound, strictBound, true, storm::settings::counterexampleGeneratorSettings().isUseSchedulerCutsSet()); auto endTime = std::chrono::high_resolution_clock::now(); std::cout << std::endl << "Computed minimal label set of size " << usedLabelSet.size() << " in " << std::chrono::duration_cast(endTime - startTime).count() << "ms." << std::endl; diff --git a/src/settings/Argument.h b/src/settings/Argument.h index e93ce0c84..a9fe0f268 100644 --- a/src/settings/Argument.h +++ b/src/settings/Argument.h @@ -95,8 +95,8 @@ namespace storm { template bool isCompatibleWith(Argument const& other) const { LOG_THROW(this->getType() == other.getType(), storm::exceptions::ArgumentUnificationException, "Unable to unify the arguments " << this->getName() << " and " << other.getName() << ", because they have different types."); - LOG_THROW(this->getIsOptional() != other.getIsOptional(), storm::exceptions::ArgumentUnificationException, "Unable to unify the arguments " << this->getName() << " and " << other.getName() << ", because one of them is optional and the other one is not."); - LOG_THROW(this->getHasDefaultValue() != other.getHasDefaultValue(), storm::exceptions::ArgumentUnificationException, "Unable to unify the arguments " << this->getName() << " and " << other.getName() << ", because one of them has a default value and the other one does not."); + LOG_THROW(this->getIsOptional() == other.getIsOptional(), storm::exceptions::ArgumentUnificationException, "Unable to unify the arguments '" << this->getName() << "' and '" << other.getName() << "', because one of them is optional and the other one is not."); + LOG_THROW(this->getHasDefaultValue() == other.getHasDefaultValue(), storm::exceptions::ArgumentUnificationException, "Unable to unify the arguments " << this->getName() << " and " << other.getName() << ", because one of them has a default value and the other one does not."); return true; } diff --git a/src/settings/ArgumentBase.cpp b/src/settings/ArgumentBase.cpp new file mode 100644 index 000000000..79c1b574b --- /dev/null +++ b/src/settings/ArgumentBase.cpp @@ -0,0 +1,76 @@ +#include "src/settings/ArgumentBase.h" + +#include + +namespace storm { + namespace settings { + uint_fast64_t ArgumentBase::getPrintLength() const { + return this->getName().length() + 2; + } + + std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument) { + std::streamsize width = out.width(); + uint_fast64_t charactersPrinted = 0; + out << std::setw(0) << std::left << "<" << argument.getName() << "> "; + charactersPrinted += 2 + argument.getName().length(); + + for (uint_fast64_t i = charactersPrinted; i < width; ++i) { + out << out.fill(); + } + + out << "\t" << argument.getDescription(); + return out; + } + + template + TargetType ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful) { + std::istringstream stream(valueAsString); + TargetType t; + conversionSuccessful = (stream >> t) && (stream >> std::ws).eof(); + return t; + } + + template <> + bool ArgumentBase::convertFromString(std::string const& s, bool& ok) { + static const std::string lowerTrueString = "true"; + static const std::string lowerFalseString = "false"; + static const std::string lowerYesString = "yes"; + static const std::string lowerNoString = "no"; + + std::string lowerInput = boost::algorithm::to_lower_copy(s); + + if (s.compare(lowerTrueString) == 0 || s.compare(lowerYesString) == 0) { + ok = true; + return true; + } else if (s.compare(lowerFalseString) == 0 || s.compare(lowerNoString) == 0) { + ok = true; + return false; + } + + std::istringstream stream(s); + bool t; + ok = (stream >> t) && (stream >> std::ws).eof(); + return t; + } + + template + std::string ArgumentBase::convertToString(ValueType const& value) { + std::ostringstream stream; + stream << value; + return stream.str(); + } + + // Explicitly instantiate the templates. + template std::string ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); + template int_fast64_t ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); + template uint_fast64_t ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); + template double ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); + template bool ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); + + template std::string ArgumentBase::convertToString(std::string const& value); + template std::string ArgumentBase::convertToString(int_fast64_t const& value); + template std::string ArgumentBase::convertToString(uint_fast64_t const& value); + template std::string ArgumentBase::convertToString(double const& value); + template std::string ArgumentBase::convertToString(bool const& value); + } +} \ No newline at end of file diff --git a/src/settings/ArgumentBase.h b/src/settings/ArgumentBase.h index 8a94dfe17..3531ccd20 100644 --- a/src/settings/ArgumentBase.h +++ b/src/settings/ArgumentBase.h @@ -127,6 +127,15 @@ namespace storm { */ virtual bool getValueAsBoolean() const = 0; + /*! + * Retrieves the (print) length of the argument. + * + * @return The length of the argument. + */ + uint_fast64_t getPrintLength() const; + + friend std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument); + protected: // A flag indicating whether the argument has been set. bool hasBeenSet; @@ -157,45 +166,6 @@ namespace storm { template static std::string convertToString(ValueType const& value); }; - - template - TargetType ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful) { - std::istringstream stream(valueAsString); - TargetType t; - conversionSuccessful = (stream >> t) && (stream >> std::ws).eof(); - return t; - } - - template <> - bool ArgumentBase::convertFromString(std::string const& s, bool& ok) { - static const std::string lowerTrueString = "true"; - static const std::string lowerFalseString = "false"; - static const std::string lowerYesString = "yes"; - static const std::string lowerNoString = "no"; - - std::string lowerInput = boost::algorithm::to_lower_copy(s); - - if (s.compare(lowerTrueString) == 0 || s.compare(lowerYesString) == 0) { - ok = true; - return true; - } else if (s.compare(lowerFalseString) == 0 || s.compare(lowerNoString) == 0) { - ok = true; - return false; - } - - std::istringstream stream(s); - bool t; - ok = (stream >> t) && (stream >> std::ws).eof(); - return t; - } - - template - std::string ArgumentBase::convertToString(ValueType const& value) { - std::ostringstream stream; - stream << value; - return stream.str(); - } - } } diff --git a/src/settings/ArgumentType.cpp b/src/settings/ArgumentType.cpp new file mode 100644 index 000000000..7ab53fcf0 --- /dev/null +++ b/src/settings/ArgumentType.cpp @@ -0,0 +1,17 @@ +#include "src/settings/ArgumentType.h" + +namespace storm { + namespace settings { + std::ostream& operator<<(std::ostream& out, ArgumentType& argumentType) { + switch (argumentType) { + case ArgumentType::String: out << "string"; break; + case ArgumentType::Integer: out << "integer"; break; + case ArgumentType::UnsignedInteger: out << "unsigned integer"; break; + case ArgumentType::Double: out << "double"; break; + case ArgumentType::Boolean: out << "boolean"; break; + } + + return out; + } + } +} \ No newline at end of file diff --git a/src/settings/ArgumentType.h b/src/settings/ArgumentType.h index 00fa3c362..843bb10e6 100644 --- a/src/settings/ArgumentType.h +++ b/src/settings/ArgumentType.h @@ -15,17 +15,7 @@ namespace storm { String, Integer, UnsignedInteger, Double, Boolean }; - std::ostream& operator<<(std::ostream& out, ArgumentType& argumentType) { - switch (argumentType) { - case ArgumentType::String: out << "string"; break; - case ArgumentType::Integer: out << "integer"; break; - case ArgumentType::UnsignedInteger: out << "unsigned integer"; break; - case ArgumentType::Double: out << "double"; break; - case ArgumentType::Boolean: out << "boolean"; break; - } - - return out; - } + std::ostream& operator<<(std::ostream& out, ArgumentType& argumentType); } // namespace settings } // namespace storm diff --git a/src/settings/ArgumentTypeInferationHelper.cpp b/src/settings/ArgumentTypeInferationHelper.cpp index c278c7108..4cf9b1251 100644 --- a/src/settings/ArgumentTypeInferationHelper.cpp +++ b/src/settings/ArgumentTypeInferationHelper.cpp @@ -86,5 +86,42 @@ namespace storm { LOG_THROW(argumentType == ArgumentType::Boolean, storm::exceptions::InternalTypeErrorException, "Unable to infer boolean from non-boolean argument."); return value; } + + // Explicitly instantiate the templates. + template ArgumentType ArgumentTypeInferation::inferToEnumType(); + template ArgumentType ArgumentTypeInferation::inferToEnumType(); + template ArgumentType ArgumentTypeInferation::inferToEnumType(); + template ArgumentType ArgumentTypeInferation::inferToEnumType(); + template ArgumentType ArgumentTypeInferation::inferToEnumType(); + + template std::string const& ArgumentTypeInferation::inferToString(ArgumentType const& argumentType, std::string const& value); + template std::string const& ArgumentTypeInferation::inferToString(ArgumentType const& argumentType, int_fast64_t const& value); + template std::string const& ArgumentTypeInferation::inferToString(ArgumentType const& argumentType, uint_fast64_t const& value); + template std::string const& ArgumentTypeInferation::inferToString(ArgumentType const& argumentType, double const& value); + template std::string const& ArgumentTypeInferation::inferToString(ArgumentType const& argumentType, bool const& value); + + template int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType const& argumentType, std::string const& value); + template int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType const& argumentType, int_fast64_t const& value); + template int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType const& argumentType, uint_fast64_t const& value); + template int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType const& argumentType, double const& value); + template int_fast64_t ArgumentTypeInferation::inferToInteger(ArgumentType const& argumentType, bool const& value); + + template uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType const& argumentType, std::string const& value); + template uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType const& argumentType, int_fast64_t const& value); + template uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType const& argumentType, uint_fast64_t const& value); + template uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType const& argumentType, double const& value); + template uint_fast64_t ArgumentTypeInferation::inferToUnsignedInteger(ArgumentType const& argumentType, bool const& value); + + template double ArgumentTypeInferation::inferToDouble(ArgumentType const& argumentType, std::string const& value); + template double ArgumentTypeInferation::inferToDouble(ArgumentType const& argumentType, int_fast64_t const& value); + template double ArgumentTypeInferation::inferToDouble(ArgumentType const& argumentType, uint_fast64_t const& value); + template double ArgumentTypeInferation::inferToDouble(ArgumentType const& argumentType, double const& value); + template double ArgumentTypeInferation::inferToDouble(ArgumentType const& argumentType, bool const& value); + + template bool ArgumentTypeInferation::inferToBoolean(ArgumentType const& argumentType, std::string const& value); + template bool ArgumentTypeInferation::inferToBoolean(ArgumentType const& argumentType, int_fast64_t const& value); + template bool ArgumentTypeInferation::inferToBoolean(ArgumentType const& argumentType, uint_fast64_t const& value); + template bool ArgumentTypeInferation::inferToBoolean(ArgumentType const& argumentType, double const& value); + template bool ArgumentTypeInferation::inferToBoolean(ArgumentType const& argumentType, bool const& value); } } \ No newline at end of file diff --git a/src/settings/Option.cpp b/src/settings/Option.cpp new file mode 100644 index 000000000..384dc1c04 --- /dev/null +++ b/src/settings/Option.cpp @@ -0,0 +1,87 @@ +#include "src/settings/Option.h" + +#include + +namespace storm { + namespace settings { + uint_fast64_t Option::getPrintLength() const { + uint_fast64_t length = 2; + if (!this->getRequiresModulePrefix()) { + length += 2; + } + length += this->getModuleName().length() + 1; + length += this->getLongName().length(); + if (this->getHasShortName()) { + length += 4; + if (!this->getRequiresModulePrefix()) { + length += 2; + } + length += this->getModuleName().length() + 1; + length += this->getShortName().length(); + } + return length; + } + + std::vector> const& Option::getArguments() const { + return this->arguments; + } + + std::ostream& operator<<(std::ostream& out, Option const& option) { + std::streamsize width = out.width(); + + uint_fast64_t charactersPrinted = 0; + out << std::setw(0) << "--"; + charactersPrinted += 2; + if (!option.getRequiresModulePrefix()) { + out << "["; + ++charactersPrinted; + } + out << option.getModuleName() << ":"; + charactersPrinted += option.getModuleName().length() + 1; + if (!option.getRequiresModulePrefix()) { + out << "]"; + ++charactersPrinted; + } + out << option.getLongName(); + charactersPrinted += option.getLongName().length(); + if (option.getHasShortName()) { + out << " | -"; + charactersPrinted += 4; + if (!option.getRequiresModulePrefix()) { + out << "["; + ++charactersPrinted; + } + out << option.getModuleName() << ":"; + charactersPrinted += option.getModuleName().length() + 1; + if (!option.getRequiresModulePrefix()) { + out << "]"; + ++charactersPrinted; + } + out << option.getShortName(); + charactersPrinted += option.getShortName().length(); + } + + // Now fill the width. + for (uint_fast64_t i = charactersPrinted; i < width; ++i) { + out << out.fill(); + } + + out << "\t" << option.getDescription(); + + if (option.getArgumentCount() > 0) { + // Start by determining the longest print length of the arguments. + uint_fast64_t maxLength = 0; + for (auto const& argument : option.getArguments()) { + maxLength = std::max(maxLength, argument->getPrintLength()); + } + + for (auto const& argument : option.getArguments()) { + out << std::endl; + out << "\t* " << std::setw(maxLength) << std::left << *argument; + } + } + + return out; + } + } +} \ No newline at end of file diff --git a/src/settings/Option.h b/src/settings/Option.h index 2c2f5912f..3345175eb 100644 --- a/src/settings/Option.h +++ b/src/settings/Option.h @@ -74,6 +74,7 @@ namespace storm { * @return True iff the given argument is compatible with the current one. */ bool isCompatibleWith(Option const& other) { + std::cout << "unifying " << *this << " and " << other << std::endl; LOG_THROW(this->getArgumentCount() == other.getArgumentCount(), storm::exceptions::OptionUnificationException, "Unable to unify two options, because their argument count differs."); for(size_t i = 0; i != this->arguments.size(); i++) { @@ -206,7 +207,7 @@ namespace storm { * @return True iff the option requires the module name as a prefix. */ bool getRequiresModulePrefix() const { - return this->requiresModulePrefix; + return this->requireModulePrefix; } /*! @@ -218,6 +219,22 @@ namespace storm { return this->hasBeenSet; } + /*! + * Retrieves the arguments of the option. + * + * @return The arguments of the option. + */ + std::vector> const& getArguments() const; + + /*! + * Retrieves the (print) length of the option. + * + * @return The length of the option. + */ + uint_fast64_t getPrintLength() const; + + friend std::ostream& operator<<(std::ostream& out, Option const& option); + private: // The long name of the option. std::string longName; @@ -262,7 +279,7 @@ namespace storm { * module name. * @param optionArguments The arguments of the option. */ - Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, bool hasShortOptionName, std::string const& optionDescription, bool isOptionRequired, bool requireModulePrefix, std::vector> const& optionArguments = std::vector>()) : longName(longOptionName), hasShortName(hasShortOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), requireModulePrefix(requireModulePrefix), hasBeenSet(false), arguments(), argumentNameMap() { + Option(std::string const& moduleName, std::string const& longOptionName, std::string const& shortOptionName, bool hasShortOptionName, std::string const& optionDescription, bool isOptionRequired, bool requireModulePrefix, std::vector> const& optionArguments = std::vector>()) : longName(longOptionName), hasShortName(hasShortOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), requireModulePrefix(requireModulePrefix), hasBeenSet(false), arguments(optionArguments), argumentNameMap() { // First, do some sanity checks. LOG_THROW(!longName.empty(), storm::exceptions::IllegalArgumentException, "Unable to construct option with empty name."); diff --git a/src/settings/OptionBuilder.h b/src/settings/OptionBuilder.h index 0823d0e05..4217d3471 100644 --- a/src/settings/OptionBuilder.h +++ b/src/settings/OptionBuilder.h @@ -88,7 +88,11 @@ namespace storm { LOG_THROW(!this->isBuild, storm::exceptions::IllegalFunctionCallException, "Cannot rebuild an option with one builder.") this->isBuild = true; - return std::shared_ptr