-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exact solutions for both MDPs and DTMCs using linear programming. #1
base: master
Are you sure you want to change the base?
Exact solutions for both MDPs and DTMCs using linear programming. #1
Conversation
External GLPK library added for solving lp problems. The library GMP is used for providing arbitrary precision arithmetic.
Hi, this looks interesting! Some comments/suggestions/issues that I ran into when trying out the code:
I have a few other minor things that I'll add as comments inline to the commit. |
@@ -102,6 +103,7 @@ | |||
public static final String PRISM_SCC_METHOD = "prism.sccMethod"; | |||
public static final String PRISM_SYMM_RED_PARAMS = "prism.symmRedParams"; | |||
public static final String PRISM_EXACT_ENABLED = "prism.exact.enabled"; | |||
public static final String PRISM_EXACT_LP_ENABLED = "prism.exact.enabled"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should change the String here to "prism.exactlp.enabled" or similar.
Hi Joachim, thanks for this great feedback! Items 1 and 5. As I can't test this on a MAC, I didn't come up with this issues, but these could be fixed just by adding separated cases for OS X in the proper Makefiles with your suggestions. Item 2. Yes, definitely. This would change constantly so it's not right to have that defined. I'll discuss how to change this with Vojtech and get back to this. Items 3 and 4. Also, I had this problem of missing GMP in mind. This should be solved too, but I don't know whether we should include this as an external package or not. Item 6. My first approach was to put the whole Item 7. I thought this possibility but haven't discussed it yet. Do you suggest a Makefile option like Item 8. I added this jar because, if the user decide not to compile or it doesn't have the requirements for build glpk (this continues the installation of PRISM), the code that uses the external library glpk won't be able to compile. I tested this jar in both 32 and 64 bit Debian, but I don't know if this is the best approach to solve this. Item 11. Yes, I think this could be a nice feature as described here [1]. I'll get back to the missing answers as soon as I talk and clarify them with Vojtech or Dave. Thanks again! |
Hi Nico, thanks, your last commit looks good.
Well, for a configure style build system you'd have a switch
for example.
So, basically it's just a dummy jar that provides the Java interfaces that are used by DTMCModelChecker and MDPModelChecker, but that would raise an error if actually used? That makes sense. I checked on OS X by manually setting So, it would probably make sense if you'd detail how you have generated that dummy jar or provide a script, so it can be regenerated later on. Cheers, |
…racked class Removed sed
8896675
to
ced6475
Compare
Hi Joachim,
Nice, this option sounds good. Working on it to reorganize the code inside the Makefile.
Well, basically that Let me know if something is not clear, or if you have any suggestions to deal with this. Thanks! |
Hi Nico, ok, that makes sense. If that's not to much trouble having a Makefile target (for the maintainer) to regenerate the dummy glpk-java.jar would probably be a good idea. That way, if someone specifically triggers rebuilding the dummy jar (changed library version perhaps) they can then commit the newly generated jar to the repository. Likewise, perhaps you could rename the jar that it stored in the repository to something like For the flag, it might make sense to rename to BTW, if you still need a portable way to replace a string in a file (without using sed), you should be able to use:
Cheers, |
Fixes issue #1. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11760 bbc10eb1-c90d-0410-af57-cb519fbb1720
Hi @kleinj, Hi @nicodelpiano, Any updates on the status of this pull request? We'd like to use/extend this code a bit and were wondering whether there are any plans of merging it into the main repo. Cheers, |
Hi, we are currently looking how to schedule merging the various pending feature branches. For this PR, there remain some minor technical questions about the integration of the library in the build process. But it should be safe to build upon Nico's work and have that keep working later on when the PR is merged into the main branch. Cheers, |
Hi Joachim, Sounds great. We'll move ahead with it then. Cheers, |
Exact Solutions using Linear Programming
This PR implements the method described in [1] to provide exact solutions for both MDPs
and DTMCs models using exact arithmetic.
New methods
The method
computeReachProbsExactLinearProg
was added for bothDTMCModelChecker
andMDPModelChecker
classes to implement arbitrary precision arithmetic solutions. This implementation follows the algorithm portrayed in [1], which basically creates the linear programming problem, solves it, and prints out the solutions onto PRISM's log.Extended GLPK interface
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
andext/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:
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: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.
Installation
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.
Configuration and usage
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 beExact linear programming
. The same setting goes for DTMCs but the option isLinear 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 infunctionality/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)
Testing
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/
.Future work or extensions to this project
.dll
s of the external libraries and placing those files inside the project.