Browse Source

Fixed compiling when hypro is not available

Former-commit-id: 402899c393
main
TimQu 9 years ago
parent
commit
a6359335cf
  1. 12
      src/storage/geometry/HyproPolytope.cpp
  2. 30
      src/storage/geometry/Polytope.cpp
  3. 7
      src/storage/geometry/Polytope.h
  4. 13
      src/utility/constants.cpp
  5. 10
      src/utility/constants.h

12
src/storage/geometry/HyproPolytope.cpp

@ -1,4 +1,6 @@
#include "src/storage/geometry/HyproPolytope.h"
#
#ifdef STORM_HAVE_HYPRO
#include "src/utility/macros.h"
#include "src/exceptions/InvalidArgumentException.h"
@ -114,13 +116,13 @@ namespace storm {
template <typename ValueType>
bool HyproPolytope<ValueType>::contains(std::shared_ptr<Polytope<ValueType>> const& other) const {
STORM_LOG_THROW(other->isHyproPolytope(), storm::exceptions::InvalidArgumentException, "Invoked operation between a HyproPolytope and a different polytope implementation. This is not supported");
return internPolytope.contains(other->asHyproPolytope().internPolytope);
return internPolytope.contains(dynamic_cast<HyproPolytope<ValueType> const&>(*other).internPolytope);
}
template <typename ValueType>
std::shared_ptr<Polytope<ValueType>> HyproPolytope<ValueType>::intersection(std::shared_ptr<Polytope<ValueType>> const& rhs) const{
STORM_LOG_THROW(rhs->isHyproPolytope(), storm::exceptions::InvalidArgumentException, "Invoked operation between a HyproPolytope and a different polytope implementation. This is not supported");
return std::make_shared<HyproPolytope<ValueType>>(internPolytope.intersect(rhs->asHyproPolytope().internPolytope));
return std::make_shared<HyproPolytope<ValueType>>(internPolytope.intersect(dynamic_cast<HyproPolytope<ValueType> const&>(*rhs).internPolytope));
}
template <typename ValueType>
@ -133,13 +135,13 @@ namespace storm {
template <typename ValueType>
std::shared_ptr<Polytope<ValueType>> HyproPolytope<ValueType>::convexUnion(std::shared_ptr<Polytope<ValueType>> const& rhs) const{
STORM_LOG_THROW(rhs->isHyproPolytope(), storm::exceptions::InvalidArgumentException, "Invoked operation between a HyproPolytope and a different polytope implementation. This is not supported");
return std::make_shared<HyproPolytope<ValueType>>(internPolytope.unite(rhs->asHyproPolytope().internPolytope));
return std::make_shared<HyproPolytope<ValueType>>(internPolytope.unite(dynamic_cast<HyproPolytope<ValueType> const&>(*rhs).internPolytope));
}
template <typename ValueType>
std::shared_ptr<Polytope<ValueType>> HyproPolytope<ValueType>::minkowskiSum(std::shared_ptr<Polytope<ValueType>> const& rhs) const{
STORM_LOG_THROW(rhs->isHyproPolytope(), storm::exceptions::InvalidArgumentException, "Invoked operation between a HyproPolytope and a different polytope implementation. This is not supported");
return std::make_shared<HyproPolytope<ValueType>>(internPolytope.minkowskiSum(rhs->asHyproPolytope().internPolytope));
return std::make_shared<HyproPolytope<ValueType>>(internPolytope.minkowskiSum(dynamic_cast<HyproPolytope<ValueType> const&>(*rhs).internPolytope));
}
template <typename ValueType>
@ -190,6 +192,8 @@ namespace storm {
#ifdef STORM_HAVE_CARL
template class HyproPolytope<storm::RationalNumber>;
#endif
// Note that hypro's polytopes only support exact arithmetic
}
}
}
#endif

30
src/storage/geometry/Polytope.cpp

@ -2,6 +2,7 @@
#include <iostream>
#include "src/adapters/CarlAdapter.h"
#include "src/adapters/HyproAdapter.h"
#include "src/storage/geometry/HyproPolytope.h"
#include "src/utility/macros.h"
@ -21,17 +22,26 @@ namespace storm {
return create(boost::none, points);
}
template <typename ValueType>
std::shared_ptr<Polytope<ValueType>> Polytope<ValueType>::create(boost::optional<std::vector<Halfspace<ValueType>>> const& halfspaces,
#ifdef STORM_HAVE_CARL
template <>
std::shared_ptr<Polytope<storm::RationalNumber>> Polytope<storm::RationalNumber>::create(boost::optional<std::vector<Halfspace<storm::RationalNumber>>> const& halfspaces,
boost::optional<std::vector<Point>> const& points) {
#ifdef STORM_HAVE_HYPRO
return HyproPolytope<ValueType>::create(halfspaces, points);
return HyproPolytope<storm::RationalNumber>::create(halfspaces, points);
#endif
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "No polytope implementation specified.");
return nullptr;
}
#endif
template <typename ValueType>
std::shared_ptr<Polytope<ValueType>> Polytope<ValueType>::create(boost::optional<std::vector<Halfspace<ValueType>>> const& halfspaces,
boost::optional<std::vector<Point>> const& points) {
//Note: hypro polytopes (currently) do not work with non-exact arithmetic (e.g., double)
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "No polytope implementation specified.");
return nullptr;
}
//Protected default constructor
template <typename ValueType>
Polytope<ValueType>::Polytope() {
// Intentionally left empty
@ -124,19 +134,11 @@ namespace storm {
return false;
}
template <typename ValueType>
HyproPolytope<ValueType> const& Polytope<ValueType>::asHyproPolytope() const {
return dynamic_cast<HyproPolytope<ValueType> const&>(*this);
}
template <typename ValueType>
HyproPolytope<ValueType>& Polytope<ValueType>::asHyproPolytope() {
return dynamic_cast<HyproPolytope<ValueType>&>(*this);
}
#ifdef STORM_HAVE_CARL
template class Polytope<storm::RationalNumber>;
#endif
template class Polytope<double>;
// Note that HyproPolytopes only support exact arithmetic
}
}
}

7
src/storage/geometry/Polytope.h

@ -11,10 +11,6 @@ namespace storm {
namespace storage {
namespace geometry {
// Forward declaration
template <typename ValueType>
class HyproPolytope;
template <typename ValueType>
class Polytope {
public:
@ -101,9 +97,6 @@ namespace storm {
virtual bool isHyproPolytope() const;
HyproPolytope<ValueType>& asHyproPolytope();
HyproPolytope<ValueType> const& asHyproPolytope() const;
protected:
Polytope();

13
src/utility/constants.cpp

@ -132,16 +132,6 @@ namespace storm {
return std::move(value);
}
template<>
double convertNumber(RationalNumber const& number){
return carl::toDouble(number);
}
template<>
RationalNumber convertNumber(double const& number){
return carl::rationalize<RationalNumber>(number);
}
#endif
template<typename IndexType, typename ValueType>
@ -255,9 +245,6 @@ namespace storm {
template RationalNumber one();
template RationalNumber zero();
template double convertNumber(RationalNumber const& number);
template RationalNumber convertNumber(double const& number);
template bool isOne(Interval const& value);
template bool isZero(Interval const& value);
template bool isConstant(Interval const& value);

10
src/utility/constants.h

@ -12,6 +12,8 @@
#include <limits>
#include <cstdint>
#include "src/adapters/CarlAdapter.h"
namespace storm {
// Forward-declare MatrixEntry class.
@ -52,7 +54,13 @@ namespace storm {
storm::storage::MatrixEntry<IndexType, ValueType>&& simplify(storm::storage::MatrixEntry<IndexType, ValueType>&& matrixEntry);
template<typename TargetType, typename SourceType>
TargetType convertNumber(SourceType const& number);
TargetType convertNumber(SourceType const& number) {
#ifdef STORM_HAVE_CARL
return carl::convert<SourceType, TargetType>(number);
#else
return static_cast<TargetType>(number);
#endif
}
}
}
Loading…
Cancel
Save