@ -70,6 +70,21 @@ public class PrismHybrid
/ / tidy up in jni ( free global references )
private static native void PH_FreeGlobalRefs ( ) ;
/ * *
* Check that number of reachable states is in a range that can be handled by
* the hybrid engine methods .
* @throws PrismNotSupportedException if that is not the case
* /
private static void checkNumStates ( ODDNode odd ) throws PrismNotSupportedException
{
/ / currently , the hybrid engine internally uses int ( signed 32bit ) index values
/ / so , if the number of states is larger than Integer . MAX_VALUE , there is a problem
long n = odd . getEOff ( ) + odd . getTOff ( ) ;
if ( n > = Integer . MAX_VALUE ) {
throw new PrismNotSupportedException ( "The hybrid engine can currently only handle up to " + Integer . MAX_VALUE + " reachable states, model has " + n + " states" ) ;
}
}
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / cudd manager
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -145,6 +160,8 @@ public class PrismHybrid
private static native long PH_ProbBoundedUntil ( long trans , long odd , long rv , int nrv , long cv , int ncv , long yes , long maybe , int bound ) ;
public static DoubleVector ProbBoundedUntil ( JDDNode trans , ODDNode odd , JDDVars rows , JDDVars cols , JDDNode yes , JDDNode maybe , int bound ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_ProbBoundedUntil ( trans . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , yes . ptr ( ) , maybe . ptr ( ) , bound ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -154,6 +171,8 @@ public class PrismHybrid
private static native long PH_ProbUntil ( long trans , long odd , long rv , int nrv , long cv , int ncv , long yes , long maybe ) ;
public static DoubleVector ProbUntil ( JDDNode trans , ODDNode odd , JDDVars rows , JDDVars cols , JDDNode yes , JDDNode maybe ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_ProbUntil ( trans . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , yes . ptr ( ) , maybe . ptr ( ) ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -163,6 +182,8 @@ public class PrismHybrid
private static native long PH_ProbCumulReward ( long trans , long sr , long trr , long odd , long rv , int nrv , long cv , int ncv , int bound ) ;
public static DoubleVector ProbCumulReward ( JDDNode trans , JDDNode sr , JDDNode trr , ODDNode odd , JDDVars rows , JDDVars cols , int bound ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_ProbCumulReward ( trans . ptr ( ) , sr . ptr ( ) , trr . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , bound ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -172,6 +193,8 @@ public class PrismHybrid
private static native long PH_ProbInstReward ( long trans , long sr , long odd , long rv , int nrv , long cv , int ncv , int time ) ;
public static DoubleVector ProbInstReward ( JDDNode trans , JDDNode sr , ODDNode odd , JDDVars rows , JDDVars cols , int time ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_ProbInstReward ( trans . ptr ( ) , sr . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , time ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -181,6 +204,8 @@ public class PrismHybrid
private static native long PH_ProbReachReward ( long trans , long sr , long trr , long odd , long rv , int nrv , long cv , int ncv , long goal , long inf , long maybe ) ;
public static DoubleVector ProbReachReward ( JDDNode trans , JDDNode sr , JDDNode trr , ODDNode odd , JDDVars rows , JDDVars cols , JDDNode goal , JDDNode inf , JDDNode maybe ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_ProbReachReward ( trans . ptr ( ) , sr . ptr ( ) , trr . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , goal . ptr ( ) , inf . ptr ( ) , maybe . ptr ( ) ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -190,6 +215,8 @@ public class PrismHybrid
private static native long PH_ProbTransient ( long trans , long odd , long init , long rv , int nrv , long cv , int ncv , int time ) ;
public static DoubleVector ProbTransient ( JDDNode trans , ODDNode odd , DoubleVector init , JDDVars rows , JDDVars cols , int time ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_ProbTransient ( trans . ptr ( ) , odd . ptr ( ) , init . getPtr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , time ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -203,6 +230,8 @@ public class PrismHybrid
private static native long PH_NondetBoundedUntil ( long trans , long odd , long rv , int nrv , long cv , int ncv , long ndv , int nndv , long yes , long maybe , int time , boolean minmax ) ;
public static DoubleVector NondetBoundedUntil ( JDDNode trans , ODDNode odd , JDDVars rows , JDDVars cols , JDDVars nondet , JDDNode yes , JDDNode maybe , int time , boolean minmax ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_NondetBoundedUntil ( trans . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , nondet . array ( ) , nondet . n ( ) , yes . ptr ( ) , maybe . ptr ( ) , time , minmax ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -212,6 +241,8 @@ public class PrismHybrid
private static native long PH_NondetUntil ( long trans , long odd , long rv , int nrv , long cv , int ncv , long ndv , int nndv , long yes , long maybe , boolean minmax ) ;
public static DoubleVector NondetUntil ( JDDNode trans , ODDNode odd , JDDVars rows , JDDVars cols , JDDVars nondet , JDDNode yes , JDDNode maybe , boolean minmax ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_NondetUntil ( trans . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , nondet . array ( ) , nondet . n ( ) , yes . ptr ( ) , maybe . ptr ( ) , minmax ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -221,6 +252,8 @@ public class PrismHybrid
private static native long PH_NondetReachReward ( long trans , long sr , long trr , long odd , long rv , int nrv , long cv , int ncv , long ndv , int nndv , long goal , long inf , long maybe , boolean minmax ) ;
public static DoubleVector NondetReachReward ( JDDNode trans , JDDNode sr , JDDNode trr , ODDNode odd , JDDVars rows , JDDVars cols , JDDVars nondet , JDDNode goal , JDDNode inf , JDDNode maybe , boolean minmax ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_NondetReachReward ( trans . ptr ( ) , sr . ptr ( ) , trr . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , nondet . array ( ) , nondet . n ( ) , goal . ptr ( ) , inf . ptr ( ) , maybe . ptr ( ) , minmax ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -234,6 +267,8 @@ public class PrismHybrid
private static native long PH_StochBoundedUntil ( long trans , long od , long rv , int nrv , long cv , int ncv , long yes , long maybe , double time , long mult ) ;
public static DoubleVector StochBoundedUntil ( JDDNode trans , ODDNode odd , JDDVars rows , JDDVars cols , JDDNode yes , JDDNode maybe , double time , DoubleVector multProbs ) throws PrismException
{
checkNumStates ( odd ) ;
long mult = ( multProbs = = null ) ? 0 : multProbs . getPtr ( ) ;
long ptr = PH_StochBoundedUntil ( trans . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , yes . ptr ( ) , maybe . ptr ( ) , time , mult ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
@ -244,6 +279,8 @@ public class PrismHybrid
private static native long PH_StochCumulReward ( long trans , long sr , long trr , long odd , long rv , int nrv , long cv , int ncv , double time ) ;
public static DoubleVector StochCumulReward ( JDDNode trans , JDDNode sr , JDDNode trr , ODDNode odd , JDDVars rows , JDDVars cols , double time ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_StochCumulReward ( trans . ptr ( ) , sr . ptr ( ) , trr . ptr ( ) , odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , time ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -253,6 +290,8 @@ public class PrismHybrid
private static native long PH_StochSteadyState ( long trans , long od , long init , long rv , int nrv , long cv , int ncv ) ;
public static DoubleVector StochSteadyState ( JDDNode trans , ODDNode odd , JDDNode init , JDDVars rows , JDDVars cols ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_StochSteadyState ( trans . ptr ( ) , odd . ptr ( ) , init . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -262,6 +301,8 @@ public class PrismHybrid
private static native long PH_StochTransient ( long trans , long odd , long init , long rv , int nrv , long cv , int ncv , double time ) ;
public static DoubleVector StochTransient ( JDDNode trans , ODDNode odd , DoubleVector init , JDDVars rows , JDDVars cols , double time ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_StochTransient ( trans . ptr ( ) , odd . ptr ( ) , init . getPtr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , time ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -275,6 +316,8 @@ public class PrismHybrid
private static native long PH_Power ( long odd , long rv , int nrv , long cv , int ncv , long a , long b , long init , boolean transpose ) ;
public static DoubleVector Power ( ODDNode odd , JDDVars rows , JDDVars cols , JDDNode a , JDDNode b , JDDNode init , boolean transpose ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_Power ( odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , a . ptr ( ) , b . ptr ( ) , init . ptr ( ) , transpose ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -284,6 +327,8 @@ public class PrismHybrid
private static native long PH_JOR ( long odd , long rv , int nrv , long cv , int ncv , long a , long b , long init , boolean transpose , boolean row_sums , double omega ) ;
public static DoubleVector JOR ( ODDNode odd , JDDVars rows , JDDVars cols , JDDNode a , JDDNode b , JDDNode init , boolean transpose , boolean row_sums , double omega ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_JOR ( odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , a . ptr ( ) , b . ptr ( ) , init . ptr ( ) , transpose , row_sums , omega ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -293,6 +338,8 @@ public class PrismHybrid
private static native long PH_SOR ( long odd , long rv , int nrv , long cv , int ncv , long a , long b , long init , boolean transpose , boolean row_sums , double omega , boolean backwards ) ;
public static DoubleVector SOR ( ODDNode odd , JDDVars rows , JDDVars cols , JDDNode a , JDDNode b , JDDNode init , boolean transpose , boolean row_sums , double omega , boolean backwards ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_SOR ( odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , a . ptr ( ) , b . ptr ( ) , init . ptr ( ) , transpose , row_sums , omega , backwards ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;
@ -302,6 +349,8 @@ public class PrismHybrid
private static native long PH_PSOR ( long odd , long rv , int nrv , long cv , int ncv , long a , long b , long init , boolean transpose , boolean row_sums , double omega , boolean backwards ) ;
public static DoubleVector PSOR ( ODDNode odd , JDDVars rows , JDDVars cols , JDDNode a , JDDNode b , JDDNode init , boolean transpose , boolean row_sums , double omega , boolean backwards ) throws PrismException
{
checkNumStates ( odd ) ;
long ptr = PH_PSOR ( odd . ptr ( ) , rows . array ( ) , rows . n ( ) , cols . array ( ) , cols . n ( ) , a . ptr ( ) , b . ptr ( ) , init . ptr ( ) , transpose , row_sums , omega , backwards ) ;
if ( ptr = = 0 ) throw new PrismException ( getErrorMessage ( ) ) ;
return new DoubleVector ( ptr , ( int ) ( odd . getEOff ( ) + odd . getTOff ( ) ) ) ;