Browse Source

preparations for support of exclusive pand and por

tempestpy_adaptions
Sebastian Junges 8 years ago
parent
commit
0bf00ff7ac
  1. 4
      src/storm-dft/parser/DFTGalileoParser.h
  2. 4
      src/storm-dft/storage/dft/DFTBuilder.cpp
  3. 14
      src/storm-dft/storage/dft/DFTBuilder.h
  4. 15
      src/storm-dft/storage/dft/elements/DFTPand.h
  5. 17
      src/storm-dft/storage/dft/elements/DFTPor.h

4
src/storm-dft/parser/DFTGalileoParser.h

@ -26,7 +26,7 @@ namespace storm {
std::unordered_map<std::string, storm::expressions::Expression> identifierMapping;
public:
DFTGalileoParser() : manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
DFTGalileoParser(bool defaultInclusive = true) : builder(defaultInclusive), manager(new storm::expressions::ExpressionManager()), parser(*manager), evaluator(*manager) {
}
storm::storage::DFT<ValueType> parseDFT(std::string const& filename);
@ -38,6 +38,8 @@ namespace storm {
std::string parseNodeIdentifier(std::string const& name);
ValueType parseRationalExpression(std::string const& expr);
bool defaultInclusive;
};
}
}

4
src/storm-dft/storage/dft/DFTBuilder.cpp

@ -144,10 +144,10 @@ namespace storm {
element = std::make_shared<DFTOr<ValueType>>(mNextId++, name);
break;
case DFTElementType::PAND:
element = std::make_shared<DFTPand<ValueType>>(mNextId++, name);
element = std::make_shared<DFTPand<ValueType>>(mNextId++, name, pandDefaultInclusive);
break;
case DFTElementType::POR:
element = std::make_shared<DFTPor<ValueType>>(mNextId++, name);
element = std::make_shared<DFTPor<ValueType>>(mNextId++, name, porDefaultInclusive);
break;
case DFTElementType::SPARE:
element = std::make_shared<DFTSpare<ValueType>>(mNextId++, name);

14
src/storm-dft/storage/dft/DFTBuilder.h

@ -35,7 +35,7 @@ namespace storm {
std::vector<DFTRestrictionPointer> mRestrictions;
public:
DFTBuilder() {
DFTBuilder(bool defaultInclusive = true) : pandDefaultInclusive(defaultInclusive), porDefaultInclusive(defaultInclusive) {
}
@ -51,6 +51,13 @@ namespace storm {
return addStandardGate(name, children, DFTElementType::PAND);
}
bool addPandElement(std::string const& name, std::vector<std::string> const& children, bool inclusive) {
bool tmpDefault = pandDefaultInclusive;
bool result = addStandardGate(name, children, DFTElementType::PAND);
pandDefaultInclusive = tmpDefault;
return result;
}
bool addPorElement(std::string const& name, std::vector<std::string> const& children) {
return addStandardGate(name, children, DFTElementType::POR);
}
@ -187,6 +194,11 @@ namespace storm {
DFTElementVector topoSort();
// If true, the standard gate adders make a pand inclusive, and exclusive otherwise.
bool pandDefaultInclusive;
// If true, the standard gate adders make a pand inclusive, and exclusive otherwise.
bool porDefaultInclusive;
};
}
}

15
src/storm-dft/storage/dft/elements/DFTPand.h

@ -7,11 +7,13 @@ namespace storm {
class DFTPand : public DFTGate<ValueType> {
public:
DFTPand(size_t id, std::string const& name, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
DFTGate<ValueType>(id, name, children)
DFTPand(size_t id, std::string const& name, bool inclusive, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
DFTGate<ValueType>(id, name, children),
inclusive(inclusive)
{}
void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
assert(inclusive);
if(state.isOperational(this->mId)) {
bool childOperationalBefore = false;
for(auto const& child : this->mChildren)
@ -31,6 +33,7 @@ namespace storm {
}
void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
bool(inclusive);
STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child.");
if(state.isOperational(this->mId)) {
this->failsafe(state, queues);
@ -42,9 +45,15 @@ namespace storm {
return DFTElementType::PAND;
}
bool isInclusive() const {
return inclusive;
}
std::string typestring() const override {
return "PAND";
return "PAND" + inclusive ? "" : "-ex";
}
protected:
bool inclusive;
};
template<typename ValueType>

17
src/storm-dft/storage/dft/elements/DFTPor.h

@ -6,12 +6,14 @@ namespace storm {
template<typename ValueType>
class DFTPor : public DFTGate<ValueType> {
public:
DFTPor(size_t id, std::string const& name, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
DFTGate<ValueType>(id, name, children)
DFTPor(size_t id, std::string const& name, bool inclusive, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {}) :
DFTGate<ValueType>(id, name, children),
inclusive(inclusive)
{}
void checkFails(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
if(state.isOperational(this->mId)) {
assert(inclusive);
if(state.isOperational(this->mId)) {
if (state.hasFailed(this->mChildren.front()->id())) {
// First child has failed before others
this->fail(state, queues);
@ -28,6 +30,7 @@ namespace storm {
}
void checkFailsafe(storm::storage::DFTState<ValueType>& state, DFTStateSpaceGenerationQueues<ValueType>& queues) const override {
assert(inclusive);
if (state.isFailsafe(this->mChildren.front()->id())) {
this->failsafe(state, queues);
this->childrenDontCare(state, queues);
@ -39,8 +42,14 @@ namespace storm {
}
std::string typestring() const override {
return "POR";
return "POR" + inclusive ? "" : "-ex";
}
bool isInclusive() {
return inclusive;
}
protected:
bool inclusive;
};
template<typename ValueType>

Loading…
Cancel
Save