Browse Source

Added option for merging DC and Failed places

tempestpy_adaptions
Matthias Volk 7 years ago
parent
commit
0674f88cf5
  1. 4
      src/storm-dft/api/storm-dft.cpp
  2. 25
      src/storm-dft/transformations/DftToGspnTransformator.cpp
  3. 4
      src/storm-dft/transformations/DftToGspnTransformator.h

4
src/storm-dft/api/storm-dft.cpp

@ -29,7 +29,9 @@ namespace storm {
template<>
void transformToGSPN(storm::storage::DFT<double> const& dft) {
// TODO make choosable
bool smart = true;
bool mergeDCFailed = true;
// Set Don't Care elements
std::set<uint64_t> dontCareElements;
@ -43,7 +45,7 @@ namespace storm {
// Transform to GSPN
storm::transformations::dft::DftToGspnTransformator<double> gspnTransformator(dft);
gspnTransformator.transform(dontCareElements, smart);
gspnTransformator.transform(dontCareElements, smart, mergeDCFailed);
storm::gspn::GSPN* gspn = gspnTransformator.obtainGSPN();
uint64_t toplevelFailedPlace = gspnTransformator.toplevelFailedPlaceId();

25
src/storm-dft/transformations/DftToGspnTransformator.cpp

@ -16,9 +16,10 @@ namespace storm {
}
template<typename ValueType>
void DftToGspnTransformator<ValueType>::transform(std::set<uint64_t> const& dontCareElements, bool smart) {
void DftToGspnTransformator<ValueType>::transform(std::set<uint64_t> const &dontCareElements, bool smart, bool mergeDCFailed) {
this->dontCareElements = dontCareElements;
this->smart = smart;
this->mergedDCFailed = mergeDCFailed;
builder.setGspnName("DftToGspnTransformation");
// Translate all GSPN elements
@ -66,10 +67,12 @@ namespace storm {
translateVOT(std::static_pointer_cast<storm::storage::DFTVot<ValueType> const>(dftElement));
break;
case storm::storage::DFTElementType::PAND:
translatePAND(std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement), std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement)->isInclusive());
translatePAND(std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement),
std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(dftElement)->isInclusive());
break;
case storm::storage::DFTElementType::POR:
translatePOR(std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement), std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement)->isInclusive());
translatePOR(std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement),
std::static_pointer_cast<storm::storage::DFTPor<ValueType> const>(dftElement)->isInclusive());
break;
case storm::storage::DFTElementType::SPARE:
translateSPARE(std::static_pointer_cast<storm::storage::DFTSpare<ValueType> const>(dftElement));
@ -542,7 +545,9 @@ namespace storm {
}
template<typename ValueType>
uint64_t DftToGspnTransformator<ValueType>::addFailedPlace(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, storm::gspn::LayoutInfo const& layoutInfo, bool initialFailed) {
uint64_t
DftToGspnTransformator<ValueType>::addFailedPlace(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, storm::gspn::LayoutInfo const &layoutInfo,
bool initialFailed) {
uint64_t failedPlace = builder.addPlace(defaultCapacity, initialFailed ? 1 : 0, dftElement->name() + STR_FAILED);
assert(failedPlaces.size() == dftElement->id());
failedPlaces.push_back(failedPlace);
@ -552,7 +557,8 @@ namespace storm {
template<typename ValueType>
uint64_t DftToGspnTransformator<ValueType>::addUnavailablePlace(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement, storm::gspn::LayoutInfo const& layoutInfo, bool initialAvailable) {
uint64_t DftToGspnTransformator<ValueType>::addUnavailablePlace(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement,
storm::gspn::LayoutInfo const &layoutInfo, bool initialAvailable) {
uint64_t unavailablePlace = builder.addPlace(defaultCapacity, initialAvailable ? 0 : 1, dftElement->name() + "_unavail");
unavailablePlaces.emplace(dftElement->id(), unavailablePlace);
builder.setPlaceLayoutInfo(unavailablePlace, layoutInfo);
@ -560,7 +566,8 @@ namespace storm {
}
template<typename ValueType>
uint64_t DftToGspnTransformator<ValueType>::addDisabledPlace(std::shared_ptr<const storm::storage::DFTBE<ValueType> > dftBe, storm::gspn::LayoutInfo const& layoutInfo) {
uint64_t
DftToGspnTransformator<ValueType>::addDisabledPlace(std::shared_ptr<const storm::storage::DFTBE<ValueType> > dftBe, storm::gspn::LayoutInfo const &layoutInfo) {
uint64_t disabledPlace = builder.addPlace(dftBe->nrRestrictions(), dftBe->nrRestrictions(), dftBe->name() + "_dabled");
disabledPlaces.emplace(dftBe->id(), disabledPlace);
builder.setPlaceLayoutInfo(disabledPlace, layoutInfo);
@ -574,8 +581,7 @@ namespace storm {
}
template<typename ValueType>
uint64_t DftToGspnTransformator<ValueType>::getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement)
{
uint64_t DftToGspnTransformator<ValueType>::getFailPriority(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftElement) {
// Temporariliy use one priority for all
return defaultPriority;
//return mDft.maxRank() - dftElement->rank() + 2;
@ -583,7 +589,8 @@ namespace storm {
// Explicitly instantiate the class.
template class DftToGspnTransformator<double>;
template
class DftToGspnTransformator<double>;
#ifdef STORM_HAVE_CARL
// template class DftToGspnTransformator<storm::RationalFunction>;

4
src/storm-dft/transformations/DftToGspnTransformator.h

@ -28,8 +28,9 @@ namespace storm {
* @param dontCareElements Set of DFT elements which should have Don't Care propagation.
* @param smart Flag indicating if smart semantics should be used.
* Smart semantics will only generate necessary parts of the GSPNs.
* @param mergeDCFailed Flag indicating if Don't Care places and Failed places should be merged.
*/
void transform(std::set<uint64_t> const& dontCareElements, bool smart = true);
void transform(std::set<uint64_t> const& dontCareElements, bool smart = true, bool mergeDCFailed = true);
/*!
* Extract Gspn by building
@ -194,6 +195,7 @@ namespace storm {
// Options
bool smart;
bool mergedDCFailed;
std::set<uint64_t> dontCareElements;
// Interface places for DFT elements

Loading…
Cancel
Save