Browse Source

Added transformation for 2-input-PAND and untested CONSTF and CONSTS

Former-commit-id: 478cc29fc5
tempestpy_adaptions
mdeutschen 8 years ago
committed by Sebastian Junges
parent
commit
170717a205
  1. 103
      src/transformations/dft/DftToGspnTransformator.cpp
  2. 17
      src/transformations/dft/DftToGspnTransformator.h

103
src/transformations/dft/DftToGspnTransformator.cpp

@ -65,10 +65,10 @@ namespace storm {
drawBE(std::static_pointer_cast<storm::storage::DFTBE<ValueType> const>(dftElement)); drawBE(std::static_pointer_cast<storm::storage::DFTBE<ValueType> const>(dftElement));
break; break;
case storm::storage::DFTElementType::CONSTF: case storm::storage::DFTElementType::CONSTF:
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a CONSTF is not yet implemented.");
drawCONSTF(dftElement);
break; break;
case storm::storage::DFTElementType::CONSTS: case storm::storage::DFTElementType::CONSTS:
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a CONSTS is not yet implemented.");
drawCONSTS(dftElement);
break; break;
case storm::storage::DFTElementType::PDEP: case storm::storage::DFTElementType::PDEP:
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a PDEP is not yet implemented."); STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a PDEP is not yet implemented.");
@ -88,7 +88,7 @@ namespace storm {
mGspn.addPlace(placeBEActivated); mGspn.addPlace(placeBEActivated);
storm::gspn::Place placeBEFailed; storm::gspn::Place placeBEFailed;
placeBEFailed.setName(dftBE->name() + "_failed");
placeBEFailed.setName(dftBE->name() + STR_FAILED);
placeBEFailed.setNumberOfInitialTokens(0); placeBEFailed.setNumberOfInitialTokens(0);
mGspn.addPlace(placeBEFailed); mGspn.addPlace(placeBEFailed);
@ -115,12 +115,12 @@ namespace storm {
template <typename ValueType> template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd) { void DftToGspnTransformator<ValueType>::drawAND(std::shared_ptr<storm::storage::DFTAnd<ValueType> const> dftAnd) {
storm::gspn::Place placeANDFailed; storm::gspn::Place placeANDFailed;
placeANDFailed.setName(dftAnd->name() + "_failed");
placeANDFailed.setName(dftAnd->name() + STR_FAILED);
placeANDFailed.setNumberOfInitialTokens(0); placeANDFailed.setNumberOfInitialTokens(0);
mGspn.addPlace(placeANDFailed); mGspn.addPlace(placeANDFailed);
storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionANDFailing; storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionANDFailing;
immediateTransitionANDFailing.setName(dftAnd->name() + "_failing");
immediateTransitionANDFailing.setName(dftAnd->name() + STR_FAILING);
immediateTransitionANDFailing.setPriority(1); immediateTransitionANDFailing.setPriority(1);
immediateTransitionANDFailing.setWeight(0.0); immediateTransitionANDFailing.setWeight(0.0);
immediateTransitionANDFailing.setInhibitionArcMultiplicity(placeANDFailed, 1); immediateTransitionANDFailing.setInhibitionArcMultiplicity(placeANDFailed, 1);
@ -131,14 +131,14 @@ namespace storm {
template <typename ValueType> template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawOR(std::shared_ptr<storm::storage::DFTOr<ValueType> const> dftOr) { void DftToGspnTransformator<ValueType>::drawOR(std::shared_ptr<storm::storage::DFTOr<ValueType> const> dftOr) {
storm::gspn::Place placeORFailed; storm::gspn::Place placeORFailed;
placeORFailed.setName(dftOr->name() + "_failed");
placeORFailed.setName(dftOr->name() + STR_FAILED);
placeORFailed.setNumberOfInitialTokens(0); placeORFailed.setNumberOfInitialTokens(0);
mGspn.addPlace(placeORFailed); mGspn.addPlace(placeORFailed);
auto children = dftOr->children(); auto children = dftOr->children();
for (std::size_t i = 0; i < dftOr->nrChildren(); i++) { for (std::size_t i = 0; i < dftOr->nrChildren(); i++) {
storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionORFailing; storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionORFailing;
immediateTransitionORFailing.setName(dftOr->name() + "_" + children[i]->name() + "_failing");
immediateTransitionORFailing.setName(dftOr->name() + "_" + children[i]->name() + STR_FAILING);
immediateTransitionORFailing.setPriority(1); immediateTransitionORFailing.setPriority(1);
immediateTransitionORFailing.setWeight(0.0); immediateTransitionORFailing.setWeight(0.0);
immediateTransitionORFailing.setInhibitionArcMultiplicity(placeORFailed, 1); immediateTransitionORFailing.setInhibitionArcMultiplicity(placeORFailed, 1);
@ -153,13 +153,41 @@ namespace storm {
} }
template <typename ValueType> template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawPAND(std::shared_ptr<storm::storage::DFTPand<ValueType> const> dftPand) {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a PAND is not yet implemented.");
void DftToGspnTransformator<ValueType>::drawPAND(std::shared_ptr<storm::storage::DFTPand<ValueType> const> dftPand) {
storm::gspn::Place placePANDFailed;
placePANDFailed.setName(dftPand->name() + STR_FAILED);
placePANDFailed.setNumberOfInitialTokens(0);
mGspn.addPlace(placePANDFailed);
storm::gspn::Place placePANDFailsave;
placePANDFailsave.setName(dftPand->name() + "_failsave");
placePANDFailsave.setNumberOfInitialTokens(0);
mGspn.addPlace(placePANDFailsave);
storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionPANDFailing;
immediateTransitionPANDFailing.setName(dftPand->name() + STR_FAILING);
immediateTransitionPANDFailing.setPriority(1);
immediateTransitionPANDFailing.setWeight(0.0);
immediateTransitionPANDFailing.setInhibitionArcMultiplicity(placePANDFailed, 1);
immediateTransitionPANDFailing.setInhibitionArcMultiplicity(placePANDFailsave, 1);
immediateTransitionPANDFailing.setOutputArcMultiplicity(placePANDFailed, 1);
mGspn.addImmediateTransition(immediateTransitionPANDFailing);
storm::gspn::ImmediateTransition<storm::gspn::GSPN::WeightType> immediateTransitionPANDFailsave;
immediateTransitionPANDFailsave.setName(dftPand->name() + "_failsaving");
immediateTransitionPANDFailsave.setPriority(1);
immediateTransitionPANDFailsave.setWeight(0.0);
immediateTransitionPANDFailsave.setInhibitionArcMultiplicity(placePANDFailsave, 1);
immediateTransitionPANDFailsave.setOutputArcMultiplicity(placePANDFailsave, 1);
mGspn.addImmediateTransition(immediateTransitionPANDFailsave);
// TODO: Are PANDs with more than two children possible?
} }
template <typename ValueType> template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawSPARE(std::shared_ptr<storm::storage::DFTSpare<ValueType> const> dftSpare) { void DftToGspnTransformator<ValueType>::drawSPARE(std::shared_ptr<storm::storage::DFTSpare<ValueType> const> dftSpare) {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a SPARE is not yet implemented."); STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a SPARE is not yet implemented.");
// TODO: What are the codewords for SPAREs in a *.dft file? hsp, wsp and csp?
} }
template <typename ValueType> template <typename ValueType>
@ -167,6 +195,25 @@ namespace storm {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a POR is not yet implemented."); STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "The transformation of a POR is not yet implemented.");
} }
template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF) {
storm::gspn::Place placeCONSTFFailed;
placeCONSTFFailed.setName(dftConstF->name() + STR_FAILED);
placeCONSTFFailed.setNumberOfInitialTokens(1);
mGspn.addPlace(placeCONSTFFailed);
// TODO: What is the codeword for CONSTF in a *.dft file?
}
template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawCONSTS(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstS) {
storm::gspn::Place placeCONSTSFailed;
placeCONSTSFailed.setName(dftConstS->name() + STR_FAILED);
placeCONSTSFailed.setNumberOfInitialTokens(0);
placeCONSTSFailed.setCapacity(0); // It cannot contain a token, because it cannot fail.
mGspn.addPlace(placeCONSTSFailed);
// TODO: What is the codeword for CONSTS in a *.dft file?
}
template <typename ValueType> template <typename ValueType>
void DftToGspnTransformator<ValueType>::drawGSPNConnections() { void DftToGspnTransformator<ValueType>::drawGSPNConnections() {
// Check for every element, if they have parents (all will have at least 1, except the top event). // Check for every element, if they have parents (all will have at least 1, except the top event).
@ -180,8 +227,8 @@ namespace storm {
switch (mDft.getElement(parents[j])->type()) { switch (mDft.getElement(parents[j])->type()) {
case storm::storage::DFTElementType::AND: case storm::storage::DFTElementType::AND:
{ {
auto andEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_failing");
auto childExit = mGspn.getPlace(child->name() + "_failed");
auto andEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
if (andEntry.first && childExit.first) { // Only add arcs if the objects have been found. if (andEntry.first && childExit.first) { // Only add arcs if the objects have been found.
andEntry.second->setInputArcMultiplicity(childExit.second, 1); andEntry.second->setInputArcMultiplicity(childExit.second, 1);
andEntry.second->setOutputArcMultiplicity(childExit.second, 1); andEntry.second->setOutputArcMultiplicity(childExit.second, 1);
@ -190,8 +237,8 @@ namespace storm {
} }
case storm::storage::DFTElementType::OR: case storm::storage::DFTElementType::OR:
{ {
auto orEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + "_failing");
auto childExit = mGspn.getPlace(child->name() + "_failed");
auto orEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_" + child->name() + STR_FAILING);
auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
if (orEntry.first && childExit.first) { // Only add arcs if the objects have been found. if (orEntry.first && childExit.first) { // Only add arcs if the objects have been found.
orEntry.second->setInputArcMultiplicity(childExit.second, 1); orEntry.second->setInputArcMultiplicity(childExit.second, 1);
orEntry.second->setOutputArcMultiplicity(childExit.second, 1); orEntry.second->setOutputArcMultiplicity(childExit.second, 1);
@ -201,7 +248,29 @@ namespace storm {
case storm::storage::DFTElementType::VOT: case storm::storage::DFTElementType::VOT:
break; break;
case storm::storage::DFTElementType::PAND: case storm::storage::DFTElementType::PAND:
{
auto children = std::static_pointer_cast<storm::storage::DFTPand<ValueType> const>(mDft.getElement(parents[j]))->children();
auto pandEntry = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + STR_FAILING);
auto pandEntry2 = mGspn.getImmediateTransition(mDft.getElement(parents[j])->name() + "_failsaving");
auto childExit = mGspn.getPlace(child->name() + STR_FAILED);
if (pandEntry.first && pandEntry2.first && childExit.first) { // Only add arcs if the objects have been found.
if (children[0] == child) { // Current element is primary child.
pandEntry.second->setInputArcMultiplicity(childExit.second, 1);
pandEntry.second->setOutputArcMultiplicity(childExit.second, 1);
pandEntry2.second->setInhibitionArcMultiplicity(childExit.second, 1);
}
else if (children[1] == child) { // Current element is secondary child.
pandEntry.second->setInputArcMultiplicity(childExit.second, 1);
pandEntry.second->setOutputArcMultiplicity(childExit.second, 1);
pandEntry2.second->setInputArcMultiplicity(childExit.second, 1);
pandEntry2.second->setOutputArcMultiplicity(childExit.second, 1);
}
}
break; break;
}
case storm::storage::DFTElementType::SPARE: case storm::storage::DFTElementType::SPARE:
break; break;
case storm::storage::DFTElementType::POR: case storm::storage::DFTElementType::POR:
@ -212,13 +281,19 @@ namespace storm {
break; break;
case storm::storage::DFTElementType::BE: case storm::storage::DFTElementType::BE:
{ {
// The parent is never a Basic Event.
// The parent is never a Basic Event (Except for SPAREs?).
break; break;
} }
case storm::storage::DFTElementType::CONSTF: case storm::storage::DFTElementType::CONSTF:
{
// The parent is never a Basic Event (Except for SPAREs?).
break; break;
}
case storm::storage::DFTElementType::CONSTS: case storm::storage::DFTElementType::CONSTS:
{
// The parent is never a Basic Event (Except for SPAREs?).
break; break;
}
case storm::storage::DFTElementType::PDEP: case storm::storage::DFTElementType::PDEP:
break; break;
default: default:

17
src/transformations/dft/DftToGspnTransformator.h

@ -31,6 +31,9 @@ namespace storm {
storm::storage::DFT<ValueType> const& mDft; storm::storage::DFT<ValueType> const& mDft;
storm::gspn::GSPN mGspn; storm::gspn::GSPN mGspn;
static constexpr const char* STR_FAILING = "_failing"; // Name standard for transitions that point towards a place, which in turn indicates the failure of a gate.
static constexpr const char* STR_FAILED = "_failed"; // Name standard for place which indicates the failure of a gate.
/*! /*!
* Write Gspn to file or console. * Write Gspn to file or console.
@ -98,6 +101,20 @@ namespace storm {
* @param dftPor The POR gate. * @param dftPor The POR gate.
*/ */
void drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor); void drawPOR(std::shared_ptr<storm::storage::DFTPor<ValueType> const> dftPor);
/*
* Draw a Petri net CONSTF (Constant Failure, a Basic Event that has already failed).
*
* @param dftPor The CONSTF Basic Event.
*/
void drawCONSTF(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstF);
/*
* Draw a Petri net CONSTS (Constant Save, a Basic Event that cannot fail).
*
* @param dftPor The CONSTS Basic Event.
*/
void drawCONSTS(std::shared_ptr<storm::storage::DFTElement<ValueType> const> dftConstS);
}; };
} }
} }

Loading…
Cancel
Save