@ -72,14 +72,14 @@ namespace {
// return env;
// }
// };
template < typename TestType >
class SchedulerGenerationMdpPrctlModelCheckerTest : public : : testing : : Test {
public :
typedef typename TestType : : ValueType ValueType ;
SchedulerGenerationMdpPrctlModelCheckerTest ( ) : _environment ( TestType : : createEnvironment ( ) ) { }
storm : : Environment const & env ( ) const { return _environment ; }
std : : pair < std : : shared_ptr < storm : : models : : sparse : : Mdp < ValueType > > , std : : vector < std : : shared_ptr < storm : : logic : : Formula const > > > buildModelFormulas ( std : : string const & pathToPrismFile , std : : string const & formulasAsString , std : : string const & constantDefinitionString = " " ) const {
std : : pair < std : : shared_ptr < storm : : models : : sparse : : Mdp < ValueType > > , std : : vector < std : : shared_ptr < storm : : logic : : Formula const > > > result ;
storm : : prism : : Program program = storm : : api : : parseProgram ( pathToPrismFile ) ;
@ -88,7 +88,7 @@ namespace {
result . first = storm : : api : : buildSparseModel < ValueType > ( program , result . second ) - > template as < storm : : models : : sparse : : Mdp < ValueType > > ( ) ;
return result ;
}
std : : vector < storm : : modelchecker : : CheckTask < storm : : logic : : Formula , ValueType > > getTasks ( std : : vector < std : : shared_ptr < storm : : logic : : Formula const > > const & formulas ) const {
std : : vector < storm : : modelchecker : : CheckTask < storm : : logic : : Formula , ValueType > > result ;
for ( auto const & f : formulas ) {
@ -97,13 +97,13 @@ namespace {
}
return result ;
}
ValueType parseNumber ( std : : string const & input ) const { return storm : : utility : : convertNumber < ValueType > ( input ) ; }
private :
storm : : Environment _environment ;
} ;
typedef : : testing : : Types <
DoubleViEnvironment ,
DoubleSoundViEnvironment ,
@ -111,10 +111,10 @@ namespace {
RationalPIEnvironment
//RationalRationalSearchEnvironment
> TestingTypes ;
TYPED_TEST_SUITE ( SchedulerGenerationMdpPrctlModelCheckerTest , TestingTypes , ) ;
TYPED_TEST ( SchedulerGenerationMdpPrctlModelCheckerTest , reachability ) {
typedef typename TestFixture : : ValueType ValueType ;
@ -126,9 +126,9 @@ namespace {
EXPECT_EQ ( 11ull , mdp - > getNumberOfTransitions ( ) ) ;
ASSERT_EQ ( mdp - > getType ( ) , storm : : models : : ModelType : : Mdp ) ;
EXPECT_EQ ( 7ull , mdp - > getNumberOfChoices ( ) ) ;
storm : : modelchecker : : SparseMdpPrctlModelChecker < storm : : models : : sparse : : Mdp < ValueType > > checker ( * mdp ) ;
auto result = checker . check ( this - > env ( ) , tasks [ 0 ] ) ;
ASSERT_TRUE ( result - > isExplicitQuantitativeCheckResult ( ) ) ;
ASSERT_TRUE ( result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) . hasScheduler ( ) ) ;
@ -137,7 +137,7 @@ namespace {
EXPECT_EQ ( 1ull , scheduler . getChoice ( 1 ) . getDeterministicChoice ( ) ) ;
EXPECT_EQ ( 0ull , scheduler . getChoice ( 2 ) . getDeterministicChoice ( ) ) ;
EXPECT_EQ ( 0ull , scheduler . getChoice ( 3 ) . getDeterministicChoice ( ) ) ;
result = checker . check ( tasks [ 1 ] ) ;
ASSERT_TRUE ( result - > isExplicitQuantitativeCheckResult ( ) ) ;
ASSERT_TRUE ( result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) . hasScheduler ( ) ) ;
@ -147,12 +147,12 @@ namespace {
EXPECT_EQ ( 0ull , scheduler2 . getChoice ( 2 ) . getDeterministicChoice ( ) ) ;
EXPECT_EQ ( 0ull , scheduler2 . getChoice ( 3 ) . getDeterministicChoice ( ) ) ;
}
TYPED_TEST ( SchedulerGenerationMdpPrctlModelCheckerTest , lra ) {
typedef typename TestFixture : : ValueType ValueType ;
std : : string formulasString = " R{ \" grants \" }max=? [ MP ]; R{ \" grants \" }min=? [ MP ]; " ;
auto modelFormulas = this - > buildModelFormulas ( STORM_TEST_RESOURCES_DIR " /mdp/cs_nfail3.nm " , formulasString ) ;
auto mdp = std : : move ( modelFormulas . first ) ;
auto tasks = this - > getTasks ( modelFormulas . second ) ;
@ -161,14 +161,14 @@ namespace {
EXPECT_EQ ( 439ul , mdp - > getNumberOfChoices ( ) ) ;
ASSERT_EQ ( mdp - > getType ( ) , storm : : models : : ModelType : : Mdp ) ;
storm : : modelchecker : : SparseMdpPrctlModelChecker < storm : : models : : sparse : : Mdp < ValueType > > checker ( * mdp ) ;
if ( ! std : : is_same < ValueType , double > : : value ) {
GTEST_SKIP ( ) < < " Lra scheduler extraction not supported for LP based method " ;
}
{
auto result = checker . check ( this - > env ( ) , tasks [ 0 ] ) ;
ASSERT_TRUE ( result - > isExplicitQuantitativeCheckResult ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 333/1000 " ) , result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 333/1000 " ) , result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , storm : : utility : : convertNumber < ValueType > ( this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ) ;
ASSERT_TRUE ( result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) . hasScheduler ( ) ) ;
storm : : storage : : Scheduler < ValueType > const & scheduler = result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) . getScheduler ( ) ;
EXPECT_TRUE ( scheduler . isDeterministicScheduler ( ) ) ;
@ -182,12 +182,12 @@ namespace {
storm : : modelchecker : : SparseMdpPrctlModelChecker < storm : : models : : sparse : : Mdp < ValueType > > inducedChecker ( * inducedMdp ) ;
auto inducedResult = inducedChecker . check ( this - > env ( ) , tasks [ 0 ] ) ;
ASSERT_TRUE ( inducedResult - > isExplicitQuantitativeCheckResult ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 333/1000 " ) , inducedResult - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 333/1000 " ) , inducedResult - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , storm : : utility : : convertNumber < ValueType > ( this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ) ;
}
{
auto result = checker . check ( this - > env ( ) , tasks [ 1 ] ) ;
ASSERT_TRUE ( result - > isExplicitQuantitativeCheckResult ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 0 " ) , result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 0 " ) , result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , storm : : utility : : convertNumber < ValueType > ( this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ) ;
ASSERT_TRUE ( result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) . hasScheduler ( ) ) ;
storm : : storage : : Scheduler < ValueType > const & scheduler = result - > template asExplicitQuantitativeCheckResult < ValueType > ( ) . getScheduler ( ) ;
EXPECT_TRUE ( scheduler . isDeterministicScheduler ( ) ) ;
@ -200,7 +200,7 @@ namespace {
storm : : modelchecker : : SparseMdpPrctlModelChecker < storm : : models : : sparse : : Mdp < ValueType > > inducedChecker ( * inducedMdp ) ;
auto inducedResult = inducedChecker . check ( this - > env ( ) , tasks [ 1 ] ) ;
ASSERT_TRUE ( inducedResult - > isExplicitQuantitativeCheckResult ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 0 " ) , inducedResult - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ;
EXPECT_NEAR ( this - > parseNumber ( " 0 " ) , inducedResult - > template asExplicitQuantitativeCheckResult < ValueType > ( ) [ * mdp - > getInitialStates ( ) . begin ( ) ] , storm : : utility : : convertNumber < ValueType > ( this - > env ( ) . solver ( ) . lra ( ) . getPrecision ( ) ) ) ;
}
}
@ -414,4 +414,4 @@ namespace {
}
}
}