Browse Source
sub part for parameters, working parsing for non parametric systems into a parametric system
sub part for parameters, working parsing for non parametric systems into a parametric system
Former-commit-id: 7714692e32
tempestpy_adaptions
sjunges
11 years ago
9 changed files with 279 additions and 86 deletions
-
3CMakeLists.txt
-
4src/adapters/ExplicitModelAdapter.h
-
74src/modelchecker/reachability/DirectEncoding.h
-
2src/models/Dtmc.h
-
86src/storage/expressions/ExpressionEvaluation.h
-
14src/storm.cpp
-
20src/stormParametric.cpp
-
32src/stormParametric.h
-
2src/utility/constants.h
@ -0,0 +1,74 @@ |
|||||
|
/** |
||||
|
* @file: DirectEncoding.h |
||||
|
* @author: Sebastian Junges |
||||
|
* |
||||
|
* @since April 8, 2014 |
||||
|
*/ |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#ifdef STORM_HAVE_CARL |
||||
|
#include <carl/io/WriteTosmt2Stream.h> |
||||
|
|
||||
|
namespace storm |
||||
|
{ |
||||
|
namespace modelchecker |
||||
|
{ |
||||
|
namespace reachability |
||||
|
{ |
||||
|
class DirectEncoding |
||||
|
{ |
||||
|
public: |
||||
|
template<typename T> |
||||
|
void encodeAsSmt2(const storm::models::Dtmc<T>& model, storm::storage::BitVector finalStates, T threshold, bool lessequal = true) |
||||
|
{ |
||||
|
carl::io::WriteTosmt2Stream smt2; |
||||
|
uint_fast64_t nrStates = model.getNumberOfStates(); |
||||
|
carl::VariablePool& vpool = carl::VariablePool::getInstance(); |
||||
|
std::vector<carl::Variable> stateVars; |
||||
|
for(uint_fast64_t state = 0; state < nrStates; ++state) |
||||
|
{ |
||||
|
carl::Variable stateVar = vpool.getFreshVariable("s_" + std::to_string(state)); |
||||
|
stateVars.push_back(stateVar); |
||||
|
smt2 << carl::io::smt2flag::ASSERT; |
||||
|
smt2 << carl::io::smt2node::AND; |
||||
|
smt2 << carl::Constraint<Polynomial>(Polynomial(stateVar), carl::CompareRelation::GE); |
||||
|
smt2 << carl::Constraint<Polynomial>(Polynomial(stateVar) - Polynomial(1), carl::CompareRelation::LE); |
||||
|
smt2 << carl::io::smt2node::CLOSENODE; |
||||
|
} |
||||
|
smt2 << carl::io::smt2flag::ASSERT; |
||||
|
smt2 << carl::io::smt2node::AND; |
||||
|
smt2.setAutomaticLineBreaks(true); |
||||
|
Polynomial finalStateReachSum; |
||||
|
for(uint_fast64_t state = 0; state < nrStates; ++state) |
||||
|
{ |
||||
|
if(finalStates[state]) |
||||
|
{ |
||||
|
smt2 << carl::Constraint<Polynomial>(Polynomial(stateVars[state]) - Polynomial(1), carl::CompareRelation::EQ); |
||||
|
finalStateReachSum += stateVars[state]; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Polynomial reachpropPol(0); |
||||
|
for(auto const& transition : model.getRows(state)) |
||||
|
{ |
||||
|
reachpropPol += stateVars[transition.first] * transition.second; |
||||
|
} |
||||
|
smt2 << carl::Constraint<Polynomial>(reachpropPol - stateVars[state], carl::CompareRelation::EQ); |
||||
|
} |
||||
|
} |
||||
|
smt2 << carl::io::smt2node::CLOSENODE; |
||||
|
smt2 << carl::io::smt2flag::ASSERT; |
||||
|
|
||||
|
carl::CompareRelation thresholdRelation = lessequal ? carl::CompareRelation::LE : carl::CompareRelation::GE; |
||||
|
smt2 << carl::Constraint<Polynomial>(finalStateReachSum - threshold, thresholdRelation); |
||||
|
smt2 << carl::io::smt2flag::CHECKSAT; |
||||
|
std::cout << smt2; |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endif |
@ -0,0 +1,20 @@ |
|||||
|
#include "stormParametric.h"
|
||||
|
#include "adapters/ExplicitModelAdapter.h"
|
||||
|
|
||||
|
namespace storm |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
void ParametricStormEntryPoint::createModel() |
||||
|
{ |
||||
|
std::shared_ptr<storm::models::AbstractModel < Polynomial>> model = storm::adapters::ExplicitModelAdapter<Polynomial>::translateProgram(mProgram, mConstants); |
||||
|
model->printModelInformationToStream(std::cout); |
||||
|
} |
||||
|
|
||||
|
void storm_parametric(const std::string& constants, const storm::prism::Program& program) |
||||
|
{ |
||||
|
ParametricStormEntryPoint entry(constants, program); |
||||
|
entry.createModel(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
#pragma once |
||||
|
#include "storage/prism/Program.h" |
||||
|
#include "models/AbstractModel.h" |
||||
|
#include "storage/parameters.h" |
||||
|
|
||||
|
namespace storm |
||||
|
{ |
||||
|
class ParametricStormEntryPoint |
||||
|
{ |
||||
|
private: |
||||
|
std::string const& mConstants; |
||||
|
storm::prism::Program const& mProgram; |
||||
|
std::shared_ptr<storm::models::AbstractModel<Polynomial>> mModel; |
||||
|
public: |
||||
|
ParametricStormEntryPoint(std::string const& constants, storm::prism::Program const& program) : |
||||
|
mConstants(constants), |
||||
|
mProgram(program) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void createModel(); |
||||
|
|
||||
|
virtual ~ParametricStormEntryPoint() {} |
||||
|
|
||||
|
}; |
||||
|
void storm_parametric(std::string const& constants, storm::prism::Program const&); |
||||
|
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue