This is a brief description for the final submission of the GSoC 2016 program. This project implements the method described in [1] for providing exact solutions for both MDPs and DTMCs models using exact arithmetic on PRISM probabilistic model checker.
- Project (
prism-svn
): prismmodelchecker/prism-svn#1 - Tests (
prism-tests
): prismmodelchecker/prism-tests#10
https://github.com/nicodelpiano/prism-svn/commit/7c56796ea2c3436614b268f1a18eef8d24e1974f
https://github.com/nicodelpiano/prism-tests/commits/exact_tests?author=nicodelpiano
exact_solutions_lp
: https://github.com/nicodelpiano/prism-svn/commits/exact_solutions_lp?author=nicodelpianowget_libs
: https://github.com/nicodelpiano/prism-svn/commits/wget_libs?author=nicodelpiano
arbitrary_precision
: https://github.com/nicodelpiano/prism/commits/arbitrary_precision?author=nicodelpianoprecision_parameter
: https://github.com/nicodelpiano/prism/commits/precision_parameter?author=nicodelpianomakefile_modif
: https://github.com/nicodelpiano/prism/commits/makefile_modifexplicit_lp_dtmc
: https://github.com/nicodelpiano/prism/commits/explicit_lp_dtmcexplicit_lp_mdp
: https://github.com/nicodelpiano/prism/commits/explicit_lp_mdpexternal_glpk
: https://github.com/nicodelpiano/prism/commits/external_glpk
less_verbose
: https://github.com/nicodelpiano/glpk/commits/less_verboseget_exact_values
: https://github.com/nicodelpiano/glpk/commits/get_exact_valuesexact_solver
: https://github.com/nicodelpiano/glpk/commits/exactsolver
glp_exact_sol
: https://github.com/nicodelpiano/libglpk-java/commits/glp_exact_solglp_prob_refactor
: https://github.com/nicodelpiano/libglpk-java/tree/glp_prob_refactor
The method computeReachProbsExactLinearProg
was added for both DTMCModelChecker
and MDPModelChecker
classes for implementing arbitrary precision arithmetic solutions. Its implementation follows the algorithm portrayed in [1], which basically creates the linear programming problem, solves it, and print out the solutions onto PRISM's log.
We needed to extend the GNU GLPK [2] library, which computes exact values using the GMP [3] arbitrary precision library, with an exact solutions interface to retrieve values directly from Java. The changes can be seen in the following two patches located in ext/glpk/glpk_exact_solutions.patch
and ext/glpk_java/libglpk_java_exact.patch
. Those patches are applied after a successful download of the two external libraries, and then they are built with the modifications.
This interface provides two types of exact solutions:
- In the form of
p/q
: exact rational arithmetic, that is,p
is the exact numerator andq
the exact denominator. Both numbers define the exact value. E.g.,2/3
is a way to state the infinite decimal expansion0.6666...
. This is easy to add in PRISM, just call to this function to obtain the arrays of numerators and denominators for each state like this:
GLPK.uint8Array_toString(GLPK.uint8ArrayArray_getitem(GLPK.glp_get_nums(lp), numState))
GLPK.uint8Array_toString(GLPK.uint8ArrayArray_getitem(GLPK.glp_get_dens(lp), numState))
These two methods provides the numerators and denominators for the exact solution of numState
.
-
In the form of fixed-precision. This is more user friendly (and is the one implemented currently in
computeReachProbsExactLinearProg
), as the user can specify the desired precision (in bits) both from the console or the GUI, and the result is calculated using this setting. -
Another approach that I implemented but then I removed, is to let the user the number of decimal digits desired. It is easy to extend the GLPK interface to provide this feature.
The installation of the PRISM library has been changed to check whether the tools required for the external libraries exist, then download the libraries from their repositories, and after that, patch them with the new interfaces and proceed with the making. This approach provides a portable solution while not increasing the weight of the project significantly.
From the GUI, the user who wants to compute exact solutions, should set from the options tab the following properties:
If the model is an MDP, the MDP Solution Method
chosen should be Exact linear programming
. The same setting goes for DTMCs but the option is Linear equations method
.
There is also a Floating point precision
option, which states the accuracy of the mantisa in bits. Recall that this is a minimum value as it is rounded up to a whole limb.
From the console, just add the flags -exact_lp
and -precision
. This is an example (extracted from the new regression tests I added in functionality/verify/dtmcs/exact-arithmetic/
):
prism ./two_dice_knuth.pm ./two_dice_knuth.pm.props -s -m -h -ex -exact-lp -precision 128 -test
which will return something like this: (this is only a small part of the results of the statement above)
128-bit results (non-zero only) for each state of the DTMC:
[0]: 0.08333333333333333333333333333333333333333
[2]: 0.1666666666666666666666666666666666666667
[6]: 0.3333333333333333333333333333333333333333
[10]: 0.5
[11]: 0.1666666666666666666666666666666666666667
[16]: 0.25
[17]: 0.08333333333333333333333333333333333333333
[22]: 0.5
[23]: 0.125
[24]: 0.04166666666666666666666666666666666666667
[29]: 0.25
[30]: 0.08333333333333333333333333333333333333333
[33]: 0.5
[42]: 1
As PRISM uses regression testing, two new directories for exact arithmetic tests in the test-suite were added. They can be found in /functionality/verify/mdps/exact-arithmetic/
and /functionality/verify/dtmcs/exact-arithmetic/
.
-
Currently it is needed an exact solution object that would be able to store exact values as real numbers (not just strings), using Java arbitrary-precision libraries such as Java BigNum, or something alike.
-
Also, this enhancement is not supported in Windows yet: it is only missing the building of the
.dll
s of the external libraries and placing those files inside the project.