|
|
@ -12,11 +12,9 @@ namespace storm { |
|
|
|
class IsMaximum : public DFTConstraint { |
|
|
|
public: |
|
|
|
IsMaximum(uint64_t varIndex, std::vector<uint64_t> const& varIndices) : varIndex(varIndex), varIndices(varIndices) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
virtual ~IsMaximum() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -34,26 +32,23 @@ namespace storm { |
|
|
|
sstr << ")"; // end of the or
|
|
|
|
sstr << ")"; // end outer and.
|
|
|
|
return sstr.str(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
uint64_t varIndex; |
|
|
|
std::vector<uint64_t> varIndices; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First is the minimum of the others |
|
|
|
*/ |
|
|
|
class IsMinimum : public DFTConstraint { |
|
|
|
public: |
|
|
|
IsMinimum(uint64_t varIndex, std::vector<uint64_t> const& varIndices) : varIndex(varIndex), varIndices(varIndices) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
virtual ~IsMinimum() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -71,22 +66,19 @@ namespace storm { |
|
|
|
sstr << ")"; // end of the or
|
|
|
|
sstr << ")"; // end outer and.
|
|
|
|
return sstr.str(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
uint64_t varIndex; |
|
|
|
std::vector<uint64_t> varIndices; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class BetweenValues : public DFTConstraint { |
|
|
|
public: |
|
|
|
BetweenValues(uint64_t varIndex, uint64_t lower, uint64_t upper) : varIndex(varIndex), upperBound(upper) , lowerBound(lower) { |
|
|
|
|
|
|
|
} |
|
|
|
virtual ~BetweenValues() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -104,12 +96,11 @@ namespace storm { |
|
|
|
uint64_t lowerBound; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class And : public DFTConstraint { |
|
|
|
public: |
|
|
|
And(std::vector<std::shared_ptr<DFTConstraint>> const& constraints) : constraints(constraints) {} |
|
|
|
|
|
|
|
virtual ~And() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -121,18 +112,18 @@ namespace storm { |
|
|
|
sstr << ")"; |
|
|
|
return sstr.str(); |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
std::vector<std::shared_ptr<DFTConstraint>> constraints; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class Iff : public DFTConstraint { |
|
|
|
public: |
|
|
|
Iff(std::shared_ptr<DFTConstraint> l, std::shared_ptr<DFTConstraint> r) : lhs(l), rhs(r) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
|
std::stringstream sstr; |
|
|
|
sstr << "(= " << lhs->toSmtlib2(varNames) << " " << rhs->toSmtlib2(varNames) << ")"; |
|
|
@ -144,14 +135,13 @@ namespace storm { |
|
|
|
std::shared_ptr<DFTConstraint> rhs; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class IsConstantValue : public DFTConstraint { |
|
|
|
public: |
|
|
|
IsConstantValue(uint64_t varIndex, uint64_t val) : varIndex(varIndex), value(val) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
virtual ~IsConstantValue() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -166,14 +156,13 @@ namespace storm { |
|
|
|
uint64_t value; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class IsEqual : public DFTConstraint { |
|
|
|
public: |
|
|
|
IsEqual(uint64_t varIndex1, uint64_t varIndex2) :var1Index(varIndex1), var2Index(varIndex2) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
virtual ~IsEqual() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -185,14 +174,13 @@ namespace storm { |
|
|
|
uint64_t var2Index; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class IsLEqual : public DFTConstraint { |
|
|
|
public: |
|
|
|
IsLEqual(uint64_t varIndex1, uint64_t varIndex2) :var1Index(varIndex1), var2Index(varIndex2) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
virtual ~IsLEqual() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -204,13 +192,12 @@ namespace storm { |
|
|
|
uint64_t var2Index; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class PairwiseDifferent : public DFTConstraint { |
|
|
|
public: |
|
|
|
PairwiseDifferent(std::vector<uint64_t> const& indices) : varIndices(indices) { |
|
|
|
|
|
|
|
} |
|
|
|
virtual ~PairwiseDifferent() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -232,14 +219,13 @@ namespace storm { |
|
|
|
std::vector<uint64_t> varIndices; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class Sorted : public DFTConstraint { |
|
|
|
public: |
|
|
|
Sorted(std::vector<uint64_t> varIndices) : varIndices(varIndices) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
virtual ~Sorted() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -252,15 +238,14 @@ namespace storm { |
|
|
|
return sstr.str(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
std::vector<uint64_t> varIndices; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class IfThenElse : public DFTConstraint { |
|
|
|
public: |
|
|
|
IfThenElse(std::shared_ptr<DFTConstraint> ifC, std::shared_ptr<DFTConstraint> thenC, std::shared_ptr<DFTConstraint> elseC) : ifConstraint(ifC), thenConstraint(thenC), elseConstraint(elseC) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string toSmtlib2(std::vector<std::string> const& varNames) const override { |
|
|
@ -285,7 +270,6 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
void DFTASFChecker::convert() { |
|
|
|
|
|
|
|
std::vector<uint64_t> beVariables; |
|
|
|
// Convert all elements
|
|
|
|
for (size_t i = 0; i < dft.nrElements(); ++i) { |
|
|
@ -313,7 +297,7 @@ namespace storm { |
|
|
|
// BE
|
|
|
|
constraints.push_back(std::make_shared<PairwiseDifferent>(beVariables)); |
|
|
|
constraints.back()->setDescription("No two BEs fail at the same time"); |
|
|
|
for( auto const& beV : beVariables) { |
|
|
|
for (auto const& beV : beVariables) { |
|
|
|
constraints.push_back(std::make_shared<BetweenValues>(beV, 1, dft.nrBasicElements())); |
|
|
|
} |
|
|
|
|
|
|
@ -333,7 +317,6 @@ namespace storm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < dft.nrElements(); ++i) { |
|
|
|
std::vector<uint64_t> childVarIndices; |
|
|
|
if (dft.isGate(i)) { |
|
|
@ -365,7 +348,7 @@ namespace storm { |
|
|
|
constraints.back()->setDescription("Last child & claimed -> spare fails"); |
|
|
|
|
|
|
|
std::shared_ptr<DFTConstraint> elseCase = nullptr; |
|
|
|
for( uint64_t j = 0; j < children.size(); ++j) { |
|
|
|
for (uint64_t j = 0; j < children.size(); ++j) { |
|
|
|
uint64_t currChild = children.size() - 2 - j; |
|
|
|
std::vector<std::shared_ptr<DFTConstraint>> ifcs; |
|
|
|
uint64_t xv = childVarIndices.at(currChild); // if v is the child, xv is the time x fails.
|
|
|
@ -375,8 +358,8 @@ namespace storm { |
|
|
|
elseCase = std::make_shared<IsEqual>(timePointVariables.at(i), xv); |
|
|
|
} |
|
|
|
ifcs.push_back(std::make_shared<IsLEqual>(xv, xn)); |
|
|
|
for(auto const& otherSpare : children.at(currChild+1)->parents()) { |
|
|
|
if(otherSpare->id() == i) { continue; }// not a OTHER spare.
|
|
|
|
for (auto const& otherSpare : children.at(currChild+1)->parents()) { |
|
|
|
if (otherSpare->id() == i) { continue; }// not a OTHER spare.
|
|
|
|
ifcs.push_back(std::make_shared<IsConstantValue>(getClaimVariableIndex(otherSpare->id(), children.at(currChild+1)->id()), dft.nrBasicElements()+1)); |
|
|
|
} |
|
|
|
std::shared_ptr<DFTConstraint> ite = std::make_shared<IfThenElse>(std::make_shared<And>(ifcs), std::make_shared<IsEqual>(csn, xv), elseCase); |
|
|
@ -390,7 +373,6 @@ namespace storm { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
constraints.push_back(std::make_shared<IsConstantValue>(dft.getTopLevelIndex(), dft.nrBasicElements()+1)); |
|
|
|
} |
|
|
|
|
|
|
|