Browse Source
Added functionality to replace identifiers in an expression with the values given in an valuation. State-variables now get replaced in probabilities specified by a parameterized model. Fixed and added some parameterized models.
Added functionality to replace identifiers in an expression with the values given in an valuation. State-variables now get replaced in probabilities specified by a parameterized model. Fixed and added some parameterized models.
Former-commit-id: a863a07261
main
19 changed files with 464 additions and 80 deletions
-
6examples/pdtmc/brp/brp_16_2.pm
-
137examples/pdtmc/brp/brp_32-4.pm
-
137examples/pdtmc/brp/brp_64-4.pm
-
8examples/pdtmc/nand/nand_10_1.pm
-
2src/adapters/ExplicitModelAdapter.h
-
7src/modelchecker/reachability/SparseSccModelChecker.cpp
-
11src/storage/expressions/Expression.cpp
-
10src/storage/expressions/Expression.h
-
8src/storage/expressions/ExpressionEvaluation.h
-
54src/storage/expressions/IdentifierSubstitutionVisitorBase.cpp
-
22src/storage/expressions/IdentifierSubstitutionVisitorBase.h
-
30src/storage/expressions/IdentifierSubstitutionWithMapVisitor.cpp
-
28src/storage/expressions/IdentifierSubstitutionWithMapVisitor.h
-
37src/storage/expressions/IdentifierSubstitutionWithValuationVisitor.cpp
-
27src/storage/expressions/IdentifierSubstitutionWithValuationVisitor.h
-
2src/storage/expressions/SimpleValuation.h
-
6src/storage/prism/Constant.cpp
-
4src/stormParametric.cpp
-
8src/utility/constants.h
@ -0,0 +1,137 @@ |
|||
// bounded retransmission protocol [D'AJJL01] |
|||
// gxn/dxp 23/05/2001 |
|||
|
|||
dtmc |
|||
|
|||
// number of chunks |
|||
const int N = 32; |
|||
// maximum number of retransmissions |
|||
const int MAX = 4; |
|||
|
|||
// reliability of channels |
|||
const double pL; |
|||
const double pK; |
|||
|
|||
module sender |
|||
|
|||
s : [0..6]; |
|||
// 0 idle |
|||
// 1 next_frame |
|||
// 2 wait_ack |
|||
// 3 retransmit |
|||
// 4 success |
|||
// 5 error |
|||
// 6 wait sync |
|||
srep : [0..3]; |
|||
// 0 bottom |
|||
// 1 not ok (nok) |
|||
// 2 do not know (dk) |
|||
// 3 ok (ok) |
|||
nrtr : [0..MAX]; |
|||
i : [0..N]; |
|||
bs : bool; |
|||
s_ab : bool; |
|||
fs : bool; |
|||
ls : bool; |
|||
|
|||
// idle |
|||
[NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); |
|||
// next_frame |
|||
[aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); |
|||
// wait_ack |
|||
[aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); |
|||
[TO_Msg] (s=2) -> (s'=3); |
|||
[TO_Ack] (s=2) -> (s'=3); |
|||
// retransmit |
|||
[aF] (s=3) & (nrtr<MAX) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); |
|||
[] (s=3) & (nrtr=MAX) & (i<N) -> (s'=5) & (srep'=1); |
|||
[] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); |
|||
// success |
|||
[] (s=4) & (i<N) -> (s'=1) & (i'=i+1); |
|||
[] (s=4) & (i=N) -> (s'=0) & (srep'=3); |
|||
// error |
|||
[SyncWait] (s=5) -> (s'=6); |
|||
// wait sync |
|||
[SyncWait] (s=6) -> (s'=0) & (s_ab'=false); |
|||
|
|||
endmodule |
|||
|
|||
module receiver |
|||
|
|||
r : [0..5]; |
|||
// 0 new_file |
|||
// 1 fst_safe |
|||
// 2 frame_received |
|||
// 3 frame_reported |
|||
// 4 idle |
|||
// 5 resync |
|||
rrep : [0..4]; |
|||
// 0 bottom |
|||
// 1 fst |
|||
// 2 inc |
|||
// 3 ok |
|||
// 4 nok |
|||
fr : bool; |
|||
lr : bool; |
|||
br : bool; |
|||
r_ab : bool; |
|||
recv : bool; |
|||
|
|||
|
|||
// new_file |
|||
[SyncWait] (r=0) -> (r'=0); |
|||
[aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); |
|||
// fst_safe_frame |
|||
[] (r=1) -> (r'=2) & (r_ab'=br); |
|||
// frame_received |
|||
[] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); |
|||
[] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); |
|||
[] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); |
|||
[aA] (r=2) & !(r_ab=br) -> (r'=4); |
|||
// frame_reported |
|||
[aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); |
|||
// idle |
|||
[aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); |
|||
[SyncWait] (r=4) & (ls=true) -> (r'=5); |
|||
[SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); |
|||
// resync |
|||
[SyncWait] (r=5) -> (r'=0) & (rrep'=0); |
|||
|
|||
endmodule |
|||
|
|||
// prevents more than one file being sent |
|||
module tester |
|||
|
|||
T : bool; |
|||
|
|||
[NewFile] (T=false) -> (T'=true); |
|||
|
|||
endmodule |
|||
|
|||
module channelK |
|||
|
|||
k : [0..2]; |
|||
|
|||
// idle |
|||
[aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); |
|||
// sending |
|||
[aG] (k=1) -> (k'=0); |
|||
// lost |
|||
[TO_Msg] (k=2) -> (k'=0); |
|||
|
|||
endmodule |
|||
|
|||
module channelL |
|||
|
|||
l : [0..2]; |
|||
|
|||
// idle |
|||
[aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); |
|||
// sending |
|||
[aB] (l=1) -> (l'=0); |
|||
// lost |
|||
[TO_Ack] (l=2) -> (l'=0); |
|||
|
|||
endmodule |
|||
|
|||
label "target" = s=5; |
@ -0,0 +1,137 @@ |
|||
// bounded retransmission protocol [D'AJJL01] |
|||
// gxn/dxp 23/05/2001 |
|||
|
|||
dtmc |
|||
|
|||
// number of chunks |
|||
const int N = 64; |
|||
// maximum number of retransmissions |
|||
const int MAX = 4; |
|||
|
|||
// reliability of channels |
|||
const double pL; |
|||
const double pK; |
|||
|
|||
module sender |
|||
|
|||
s : [0..6]; |
|||
// 0 idle |
|||
// 1 next_frame |
|||
// 2 wait_ack |
|||
// 3 retransmit |
|||
// 4 success |
|||
// 5 error |
|||
// 6 wait sync |
|||
srep : [0..3]; |
|||
// 0 bottom |
|||
// 1 not ok (nok) |
|||
// 2 do not know (dk) |
|||
// 3 ok (ok) |
|||
nrtr : [0..MAX]; |
|||
i : [0..N]; |
|||
bs : bool; |
|||
s_ab : bool; |
|||
fs : bool; |
|||
ls : bool; |
|||
|
|||
// idle |
|||
[NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0); |
|||
// next_frame |
|||
[aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0); |
|||
// wait_ack |
|||
[aB] (s=2) -> (s'=4) & (s_ab'=!s_ab); |
|||
[TO_Msg] (s=2) -> (s'=3); |
|||
[TO_Ack] (s=2) -> (s'=3); |
|||
// retransmit |
|||
[aF] (s=3) & (nrtr<MAX) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1); |
|||
[] (s=3) & (nrtr=MAX) & (i<N) -> (s'=5) & (srep'=1); |
|||
[] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2); |
|||
// success |
|||
[] (s=4) & (i<N) -> (s'=1) & (i'=i+1); |
|||
[] (s=4) & (i=N) -> (s'=0) & (srep'=3); |
|||
// error |
|||
[SyncWait] (s=5) -> (s'=6); |
|||
// wait sync |
|||
[SyncWait] (s=6) -> (s'=0) & (s_ab'=false); |
|||
|
|||
endmodule |
|||
|
|||
module receiver |
|||
|
|||
r : [0..5]; |
|||
// 0 new_file |
|||
// 1 fst_safe |
|||
// 2 frame_received |
|||
// 3 frame_reported |
|||
// 4 idle |
|||
// 5 resync |
|||
rrep : [0..4]; |
|||
// 0 bottom |
|||
// 1 fst |
|||
// 2 inc |
|||
// 3 ok |
|||
// 4 nok |
|||
fr : bool; |
|||
lr : bool; |
|||
br : bool; |
|||
r_ab : bool; |
|||
recv : bool; |
|||
|
|||
|
|||
// new_file |
|||
[SyncWait] (r=0) -> (r'=0); |
|||
[aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); |
|||
// fst_safe_frame |
|||
[] (r=1) -> (r'=2) & (r_ab'=br); |
|||
// frame_received |
|||
[] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1); |
|||
[] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2); |
|||
[] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3); |
|||
[aA] (r=2) & !(r_ab=br) -> (r'=4); |
|||
// frame_reported |
|||
[aA] (r=3) -> (r'=4) & (r_ab'=!r_ab); |
|||
// idle |
|||
[aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T); |
|||
[SyncWait] (r=4) & (ls=true) -> (r'=5); |
|||
[SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4); |
|||
// resync |
|||
[SyncWait] (r=5) -> (r'=0) & (rrep'=0); |
|||
|
|||
endmodule |
|||
|
|||
// prevents more than one file being sent |
|||
module tester |
|||
|
|||
T : bool; |
|||
|
|||
[NewFile] (T=false) -> (T'=true); |
|||
|
|||
endmodule |
|||
|
|||
module channelK |
|||
|
|||
k : [0..2]; |
|||
|
|||
// idle |
|||
[aF] (k=0) -> pK : (k'=1) + 1-pK : (k'=2); |
|||
// sending |
|||
[aG] (k=1) -> (k'=0); |
|||
// lost |
|||
[TO_Msg] (k=2) -> (k'=0); |
|||
|
|||
endmodule |
|||
|
|||
module channelL |
|||
|
|||
l : [0..2]; |
|||
|
|||
// idle |
|||
[aA] (l=0) -> pL : (l'=1) + 1-pL : (l'=2); |
|||
// sending |
|||
[aB] (l=1) -> (l'=0); |
|||
// lost |
|||
[TO_Ack] (l=2) -> (l'=0); |
|||
|
|||
endmodule |
|||
|
|||
label "target" = s=5; |
@ -0,0 +1,30 @@ |
|||
#include <map>
|
|||
#include <unordered_map>
|
|||
#include <string>
|
|||
|
|||
#include "src/storage/expressions/IdentifierSubstitutionWithMapVisitor.h"
|
|||
#include "src/storage/expressions/Expressions.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
template<typename MapType> |
|||
IdentifierSubstitutionWithMapVisitor<MapType>::IdentifierSubstitutionWithMapVisitor(MapType const& identifierToIdentifierMap) : identifierToIdentifierMap(identifierToIdentifierMap) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<typename MapType> |
|||
void IdentifierSubstitutionWithMapVisitor<MapType>::visit(VariableExpression const* expression) { |
|||
// If the variable is in the key set of the substitution, we need to replace it.
|
|||
auto const& namePair = this->identifierToIdentifierMap.find(expression->getVariableName()); |
|||
if (namePair != this->identifierToIdentifierMap.end()) { |
|||
this->expressionStack.push(std::shared_ptr<BaseExpression>(new VariableExpression(expression->getReturnType(), namePair->second))); |
|||
} else { |
|||
this->expressionStack.push(expression->getSharedPointer()); |
|||
} |
|||
} |
|||
|
|||
// Explicitly instantiate the class with map and unordered_map.
|
|||
template class IdentifierSubstitutionWithMapVisitor<std::map<std::string, std::string>>; |
|||
template class IdentifierSubstitutionWithMapVisitor<std::unordered_map<std::string, std::string>>; |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_IDENTIFIERSUBSTITUTIONWITHMAPVISITOR_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_IDENTIFIERSUBSTITUTIONWITHMAPVISITOR_H_ |
|||
|
|||
#include "src/storage/expressions/Expression.h" |
|||
#include "src/storage/expressions/IdentifierSubstitutionVisitorBase.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
template<typename MapType> |
|||
class IdentifierSubstitutionWithMapVisitor : public IdentifierSubstitutionVisitorBase { |
|||
public: |
|||
/*! |
|||
* Creates a new substitution visitor that uses the given map to replace identifiers. |
|||
* |
|||
* @param identifierToExpressionMap A mapping from identifiers to expressions. |
|||
*/ |
|||
IdentifierSubstitutionWithMapVisitor(MapType const& identifierToExpressionMap); |
|||
|
|||
virtual void visit(VariableExpression const* expression) override; |
|||
|
|||
private: |
|||
// A mapping of identifier names to expressions with which they shall be replaced. |
|||
MapType const& identifierToIdentifierMap; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_IDENTIFIERSUBSTITUTIONWITHMAPVISITOR_H_ */ |
@ -0,0 +1,37 @@ |
|||
#include <map>
|
|||
#include <unordered_map>
|
|||
#include <string>
|
|||
|
|||
#include "src/storage/expressions/IdentifierSubstitutionWithValuationVisitor.h"
|
|||
#include "src/storage/expressions/Expressions.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
IdentifierSubstitutionWithValuationVisitor::IdentifierSubstitutionWithValuationVisitor(Valuation const& valuation) : valuation(valuation) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
void IdentifierSubstitutionWithValuationVisitor::visit(VariableExpression const* expression) { |
|||
// If the variable is the valuation, we need to replace it.
|
|||
if (expression->getReturnType() == ExpressionReturnType::Bool) { |
|||
if (valuation.containsBooleanIdentifier(expression->getVariableName())) { |
|||
this->expressionStack.push(std::shared_ptr<BaseExpression>(new BooleanLiteralExpression(valuation.getBooleanValue(expression->getVariableName())))); |
|||
} else { |
|||
this->expressionStack.push(expression->getSharedPointer()); |
|||
} |
|||
} else if (expression->getReturnType() == ExpressionReturnType::Int) { |
|||
if (valuation.containsIntegerIdentifier(expression->getVariableName())) { |
|||
this->expressionStack.push(std::shared_ptr<BaseExpression>(new IntegerLiteralExpression(valuation.getIntegerValue(expression->getVariableName())))); |
|||
} else { |
|||
this->expressionStack.push(expression->getSharedPointer()); |
|||
} |
|||
} else if (expression->getReturnType() == ExpressionReturnType::Double) { |
|||
if (valuation.containsDoubleIdentifier(expression->getVariableName())) { |
|||
this->expressionStack.push(std::shared_ptr<BaseExpression>(new DoubleLiteralExpression(valuation.getDoubleValue(expression->getVariableName())))); |
|||
} else { |
|||
this->expressionStack.push(expression->getSharedPointer()); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_IDENTIFIERSUBSTITUTIONWITHVALUATIONVISITOR_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_IDENTIFIERSUBSTITUTIONWITHVALUATIONVISITOR_H_ |
|||
|
|||
#include "src/storage/expressions/Expression.h" |
|||
#include "src/storage/expressions/IdentifierSubstitutionVisitorBase.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class IdentifierSubstitutionWithValuationVisitor : public IdentifierSubstitutionVisitorBase { |
|||
public: |
|||
/*! |
|||
* Creates a new substitution visitor that uses the given map to replace identifiers. |
|||
* |
|||
* @param identifierToExpressionMap A mapping from identifiers to expressions. |
|||
*/ |
|||
IdentifierSubstitutionWithValuationVisitor(Valuation const& valuation); |
|||
|
|||
virtual void visit(VariableExpression const* expression) override; |
|||
|
|||
private: |
|||
// A mapping of identifier names to the values with which they shall be replaced. |
|||
Valuation const& valuation; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_IDENTIFIERSUBSTITUTIONWITHVALUATIONVISITOR_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue