|
@ -13,7 +13,8 @@ |
|
|
namespace storm { |
|
|
namespace storm { |
|
|
namespace storage { |
|
|
namespace storage { |
|
|
|
|
|
|
|
|
DFT DFTBuilder::build() { |
|
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
|
|
DFT DFTBuilder<ValueType>::build() { |
|
|
for(auto& elem : mChildNames) { |
|
|
for(auto& elem : mChildNames) { |
|
|
for(auto const& child : elem.second) { |
|
|
for(auto const& child : elem.second) { |
|
|
std::shared_ptr<DFTGate> gate = std::static_pointer_cast<DFTGate>(elem.first); |
|
|
std::shared_ptr<DFTGate> gate = std::static_pointer_cast<DFTGate>(elem.first); |
|
@ -37,7 +38,8 @@ namespace storm { |
|
|
return DFT(elems, mElements[topLevelIdentifier]); |
|
|
return DFT(elems, mElements[topLevelIdentifier]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
unsigned DFTBuilder::computeRank(std::shared_ptr<DFTElement> const& elem) { |
|
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
|
|
unsigned DFTBuilder<ValueType>::computeRank(std::shared_ptr<DFTElement> const& elem) { |
|
|
if(elem->rank() == -1) { |
|
|
if(elem->rank() == -1) { |
|
|
if(elem->nrChildren() == 0) { |
|
|
if(elem->nrChildren() == 0) { |
|
|
elem->setRank(0); |
|
|
elem->setRank(0); |
|
@ -59,7 +61,8 @@ namespace storm { |
|
|
return elem->rank(); |
|
|
return elem->rank(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool DFTBuilder::addStandardGate(std::string const& name, std::vector<std::string> const& children, DFTElementTypes tp) { |
|
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
|
|
bool DFTBuilder<ValueType>::addStandardGate(std::string const& name, std::vector<std::string> const& children, DFTElementTypes tp) { |
|
|
assert(children.size() > 0); |
|
|
assert(children.size() > 0); |
|
|
if(mElements.count(name) != 0) { |
|
|
if(mElements.count(name) != 0) { |
|
|
// Element with that name already exists.
|
|
|
// Element with that name already exists.
|
|
@ -98,8 +101,8 @@ namespace storm { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DFTBuilder::topoVisit(std::shared_ptr<DFTElement> const& n, std::map<std::shared_ptr<DFTElement>, topoSortColour>& visited, std::vector<std::shared_ptr<DFTElement>>& L) { |
|
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
|
|
void DFTBuilder<ValueType>::topoVisit(std::shared_ptr<DFTElement> const& n, std::map<std::shared_ptr<DFTElement>, topoSortColour>& visited, std::vector<std::shared_ptr<DFTElement>>& L) { |
|
|
if(visited[n] == topoSortColour::GREY) { |
|
|
if(visited[n] == topoSortColour::GREY) { |
|
|
throw storm::exceptions::WrongFormatException("DFT is cyclic"); |
|
|
throw storm::exceptions::WrongFormatException("DFT is cyclic"); |
|
|
} else if(visited[n] == topoSortColour::WHITE) { |
|
|
} else if(visited[n] == topoSortColour::WHITE) { |
|
@ -114,7 +117,8 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<DFTElement>> DFTBuilder::topoSort() { |
|
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
|
|
std::vector<std::shared_ptr<DFTElement>> DFTBuilder<ValueType>::topoSort() { |
|
|
std::map<std::shared_ptr<DFTElement>, topoSortColour> visited; |
|
|
std::map<std::shared_ptr<DFTElement>, topoSortColour> visited; |
|
|
for(auto const& e : mElements) { |
|
|
for(auto const& e : mElements) { |
|
|
visited.insert(std::make_pair(e.second, topoSortColour::WHITE)); |
|
|
visited.insert(std::make_pair(e.second, topoSortColour::WHITE)); |
|
@ -128,6 +132,13 @@ namespace storm { |
|
|
return L; |
|
|
return L; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Explicitly instantiate the class.
|
|
|
|
|
|
template class DFTBuilder<double>; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef STORM_HAVE_CARL
|
|
|
|
|
|
template class DFTBuilder<RationalFunction>; |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|