Artifact submission for paper #45
Are Parametric Markov Chains Monotonic?
by Jip Spel, Sebastian Junges and Joost-Pieter Katoen

###############################################
Abstract
###############################################
This paper presents a simple algorithm to check whether reachability probabilities in parametric Markov chains are monotonic in (some of) the parameters. 
The idea is to construct---only using the graph structure of the Markov chain and local transition probabilities---a pre-order on the states. 
Our algorithm cheaply checks a sufficient condition for monotonicity. 
Experiments show that monotonicity in several benchmarks is automatically detected,
and monotonicity can speed up parameter synthesis up to orders of magnitude faster than a symbolic baseline.

This artifact contains an extension to storm and prophesy.
It can be used to check monotonicity (via storm) 
and to do parameter synthesis while exploiting monotonicity (via prophesy).


###############################################
Virtual machine
###############################################

1. Create a folder to be used as the shared folder, e.g. ~/artifact .

2. Copy the files that you wish to transfer to the created folder.

2. In VirtualBox, right-click on ubuntu18-ae VM -> Settings -> Shared Folders
   -> Add a new shared folder .

3. Set folder path to the created shared folder, e.g. ~/artifact and Folder
   name to "artifact"

4. Run the ubuntu18-ae virtual machine and execute 

   $ sudo mount -t vboxsf -o uid=1000,gid=1000  artifact  ~/Shared/artifact/


###############################################
0. Overview
###############################################


Make sure you have at least 4096 MB of base memory
You could use the install script for installation.
In line with the experiments in the paper, there are two parts.

For installation, copy the artifact to the Desktop, i.e.,

cp ~/Shared/artifact ~/Desktop -r

(wait for a bit) and then go there

cd ~/Desktop/artifact

and run

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Desktop/artifact/lib/

You are now all set for the first experiments (see 1).
For the second set of experiments, you need the much more involved (see 2). 
For convenience, running this script may help (on some instances it got stuck, single steps are outlined in 2).
./install

You are now all set for the second set of experiments (see 3)

###############################################
1. Running storm-pars
###############################################

Remark: To simplify the installation process, we ship storm in binary form (exploiting that we target a specific virtual machine configuration).
The sources are also included.

Results for monotonicity checking are written to monotonicity.txt
Results for monotonicity checking of the scripts are written to monotonicity-MODEL.txt
Timing results can be read from the terminal

You may run the following examples (substitute crowds.const accordlingly) or run the scripts directly (mon_*, func_*).
1. Monotonicity Checking
For crowds:
./storm/build/bin/storm-pars --prism ./models/crowds.pm --prop ./models/crowds.pctl --constants "see crowds.const" --monotonicity-analysis --bisimulation --mon-elim-scc

For other models:
./storm/build/bin/storm-pars --prism ./models/MODEL.pm --prop ./models/MODEL.pctl --constants "see MODEL.const" --monotonicity-analysis --bisimulation

You could also use the scripts (i.e. mon_MODEL, mon_all, mon_smallest)

2. Calculating Rational Function
For all models:
./storm/build/bin/storm-pars --prism ./models/MODEL.pm --prop ./models/MODEL.pctl --constants "see MODEL.const" --monotonicity-analysis --bisimulation

You could also use the scripts (i.e. func_MODEL, func_all, func_smallest)



# 3. Installation prophesy
These are quite some steps, and as python3/pip is missing we failed to simplify thus further. 

## Install pip3
cd ~/Desktop/artifact/packages-pip3
sudo dpkg -i *.deb
sudo dpkg -i *.deb
sudo dpkg -i *.deb

## Get Pytest
cd ~/Desktop/artifact/packages-pytest
sudo dpkg -i *.deb

## Get virtualenvpackages-virtualenv 
cd ~/Desktop/artifact/packages-virtualenv
sudo dpkg -i *.deb

## Create environment
virtualenv -p python3 env

## Use environment (if you open another terminal, repeat this step!)
source ~/Desktop/artifact/env/bin/activate

## Prepare pycarl installation
cd ~/Desktop/artifact/packages-pycarl
sudo dpkg -i *.deb
pip3 install wcwidth-0.1.7-py2.py3-none-any.whl py-1.8.0-py2.py3-none-any.whl pluggy-0.12.0-py2.py3-none-any.whl pyparsing-2.4.0-py2.py3-none-any.whl packaging-19.0-py2.py3-none-any.whl atomicwrites-1.3.0-py2.py3-none-any.whl more_itertools-7.0.0-py3-none-any.whl zipp-0.5.1-py2.py3-none-any.whl importlib_metadata-0.18-py2.py3-none-any.whl six-1.12.0-py2.py3-none-any.whl attrs-19.1.0-py2.py3-none-any.whl pytest-4.6.3-py2.py3-none-any.whl 

## Install pycarl (This may take some time)
cd ~/Desktop/artifact/pycarl
python3 setup.py develop
You can test it through:
pytest tests/

cd ~/Desktop/artifact/packages-stormpy
sudo dpkg -i *.deb


## Install stormpy (This may take some time) 
cd ~/Desktop/artifact/stormpy
python3 setup.py develop

## Install prophesy
cd ~/Desktop/artifact/packages-prophesy
sudo dpkg -i *.deb
cd ~/Desktop/artifact/dependencies-prophesy
pip install *.whl 
pip install ./Prophesy-2.0.10.tar.gz  --no-deps

cd ~/Desktop/artifact/
prophesy_write_config.py 


# 3. Running Prophesy

We prepared a list of commands below. 
Observe that there is a lot of overhead currently in prophesy as it is not tuned for performance (and its applications have changed from initial development).
Therefore, we report on the timings of the actual model checking routines, as this seems to be the fairest comparison. With larger models, the overhead slowly vanishes.

To obtain the graphs as in the paper, we recommend to vary the 'threshold' option. 
In *.results, you can find the verified regions.
Running without --nolog gives some hints into what is actually happening.

## Zeroconf with monotonicity (mono)
parameter_synthesis.py --nolog --solver z3 --mc stormpy load-problem --constants n=10  ~/Desktop/artifact/models/zeroconf.pm ~/Desktop/artifact/models/zeroconf.pctl load-monotonicity precomputed/zeroconf.mono set-parameter-space --epsilon 0.1  set-threshold 0.001 parameter-space-partitioning --area 0.99 --export zeroconf-mono.results mono quads 
## Zeroconf without monotonicity (pla)
parameter_synthesis.py --nolog --solver z3 --mc stormpy load-problem --constants n=10  ~/Desktop/artifact/models/zeroconf.pm ~/Desktop/artifact/models/zeroconf.pctl load-monotonicity precomputed/zeroconf.mono set-parameter-space --epsilon 0.1  set-threshold 0.001 parameter-space-partitioning --area 0.99 --export zeroconf-pla.results pla quads 
## BRP with monotonicity (mono)
parameter_synthesis.py --nolog --solver z3 --mc stormpy load-problem --constants N=4,MAX=64  ~/Desktop/artifact/models/brp.pm ~/Desktop/artifact/models/brp.pctl load-monotonicity precomputed/brp.mono set-parameter-space --epsilon 0.1  set-threshold 0.001 parameter-space-partitioning --area 0.99 --export brp-mono.results mono quads
## BRP without monotonicity (pla)
parameter_synthesis.py --nolog --solver z3 --mc stormpy load-problem --constants N=4,MAX=64  ~/Desktop/artifact/models/brp.pm ~/Desktop/artifact/models/brp.pctl load-monotonicity precomputed/brp.mono set-parameter-space --epsilon 0.1  set-threshold 0.001 parameter-space-partitioning --area 0.99 --export brp-pla.results pla quads
## Crowds with monotonicity (mono)
parameter_synthesis.py --nolog --solver z3 --mc stormpy load-problem --constants "CrowdSize=5,TotalRuns=10"  ~/Desktop/artifact/models/crowds.pm ~/Desktop/artifact/models/crowds.pctl load-monotonicity precomputed/crowds.mono set-parameter-space --epsilon 0.01  set-threshold 0.05 parameter-space-partitioning --iterations -1 --area 0.99 --export crowds-mono.results  mono quads
## Crowds without monotonicity (pla)
parameter_synthesis.py --nolog --solver z3 --mc stormpy load-problem --constants "CrowdSize=5,TotalRuns=10"  ~/Desktop/artifact/models/crowds.pm ~/Desktop/artifact/models/crowds.pctl load-monotonicity precomputed/crowds.mono set-parameter-space --epsilon 0.01  set-threshold 0.05 parameter-space-partitioning --iterations -1 --area 0.99 --export crowds-pla.results  pla quads

