Browse Source

cleaned up some utility functions

tempestpy_adaptions
TimQu 8 years ago
parent
commit
cf340bed52
  1. 4
      src/storm/utility/ModelInstantiator.cpp
  2. 11
      src/storm/utility/constants.cpp
  3. 5
      src/storm/utility/parametric.cpp
  4. 6
      src/storm/utility/parametric.h

4
src/storm/utility/ModelInstantiator.cpp

@ -93,7 +93,7 @@ namespace storm {
STORM_LOG_ASSERT(parametricEntryIt->getColumn() == constantEntryIt->getColumn(), "Entries of parametric and constant matrix are not at the same position"); STORM_LOG_ASSERT(parametricEntryIt->getColumn() == constantEntryIt->getColumn(), "Entries of parametric and constant matrix are not at the same position");
if(storm::utility::isConstant(parametricEntryIt->getValue())){ if(storm::utility::isConstant(parametricEntryIt->getValue())){
//Constant entries can be inserted directly //Constant entries can be inserted directly
constantEntryIt->setValue(storm::utility::convertNumber<ConstantType>(storm::utility::parametric::getConstantPart(parametricEntryIt->getValue())));
constantEntryIt->setValue(storm::utility::convertNumber<ConstantType>(parametricEntryIt->getValue()));
} else { } else {
//insert the new function and store that the current constantMatrix entry needs to be set to the value of this function //insert the new function and store that the current constantMatrix entry needs to be set to the value of this function
auto functionsIt = functions.insert(std::make_pair(parametricEntryIt->getValue(), dummyValue)).first; auto functionsIt = functions.insert(std::make_pair(parametricEntryIt->getValue(), dummyValue)).first;
@ -118,7 +118,7 @@ namespace storm {
while(parametricEntryIt != parametricVector.end()){ while(parametricEntryIt != parametricVector.end()){
if(storm::utility::isConstant(storm::utility::simplify(*parametricEntryIt))){ if(storm::utility::isConstant(storm::utility::simplify(*parametricEntryIt))){
//Constant entries can be inserted directly //Constant entries can be inserted directly
*constantEntryIt = storm::utility::convertNumber<ConstantType>(storm::utility::parametric::getConstantPart(*parametricEntryIt));
*constantEntryIt = storm::utility::convertNumber<ConstantType>(*parametricEntryIt);
} else { } else {
//insert the new function and store that the current constantVector entry needs to be set to the value of this function //insert the new function and store that the current constantVector entry needs to be set to the value of this function
auto functionsIt = functions.insert(std::make_pair(*parametricEntryIt, dummyValue)).first; auto functionsIt = functions.insert(std::make_pair(*parametricEntryIt, dummyValue)).first;

11
src/storm/utility/constants.cpp

@ -476,11 +476,6 @@ namespace storm {
return a.isOne(); return a.isOne();
} }
template<>
double convertNumber(RationalFunction const& number){
return carl::toDouble(number.constantPart());
}
template<> template<>
bool isOne(storm::Polynomial const& a) { bool isOne(storm::Polynomial const& a) {
return a.isOne(); return a.isOne();
@ -496,12 +491,6 @@ namespace storm {
return a.isZero(); return a.isZero();
} }
template<>
RationalNumber convertNumber(RationalFunction const& number) {
STORM_LOG_ASSERT(isConstant(number), "Tried to convert a non-constant number to a constant type.");
return number.constantPart();
}
template<> template<>
bool isConstant(storm::RationalFunction const& a) { bool isConstant(storm::RationalFunction const& a) {
return a.isConstant(); return a.isConstant();

5
src/storm/utility/parametric.cpp

@ -22,11 +22,6 @@ namespace storm {
return function.evaluate(valuation); return function.evaluate(valuation);
} }
template<>
typename CoefficientType<storm::RationalFunction>::type getConstantPart<storm::RationalFunction>(storm::RationalFunction const& function){
return function.constantPart();
}
template<> template<>
void gatherOccurringVariables<storm::RationalFunction>(storm::RationalFunction const& function, std::set<typename VariableType<storm::RationalFunction>::type>& variableSet){ void gatherOccurringVariables<storm::RationalFunction>(storm::RationalFunction const& function, std::set<typename VariableType<storm::RationalFunction>::type>& variableSet){
function.gatherVariables(variableSet); function.gatherVariables(variableSet);

6
src/storm/utility/parametric.h

@ -36,12 +36,6 @@ namespace storm {
template<typename FunctionType> template<typename FunctionType>
typename CoefficientType<FunctionType>::type evaluate(FunctionType const& function, Valuation<FunctionType> const& valuation); typename CoefficientType<FunctionType>::type evaluate(FunctionType const& function, Valuation<FunctionType> const& valuation);
/*!
* Retrieves the constant part of the given function.
*/
template<typename FunctionType>
typename CoefficientType<FunctionType>::type getConstantPart(FunctionType const& function);
/*! /*!
* Add all variables that occur in the given function to the the given set * Add all variables that occur in the given function to the the given set
*/ */

Loading…
Cancel
Save