# Proseqo Experiments
 
This readme gives instructions on how to run our experiments for Proseqo.
There are two alternative ways to run the experiments. You can either set up
a Python environment yourself or you can use our Docker image.
 
## Run Experiments Without Docker
  
You will need a Python 3.7+ environment. Extract the proseqo.zip archive into
a folder of your choice. We will refer to this folder as $project_folder.
 
### Installing requirements
 
```
cd $project_folder
pip install -r deployment/proseqo_experiments/requirements.txt
```

If you want to run any experiments with Squish involved, you must compile it.
You will find the files in ${project_folder}/thirdparty/squish. 
run compile.sh to start compiling.

### Before experiments (Unix)

```
cd $project_folder
export PYTHONPATH=.
```

### Before experiments (Windows)

```
cd $project_folder
set PYTHONPATH=.
```

### Run the Sanity Check

The sanity check mentioned in the paper can be run by

```
python experiments/proseqo/comparison_on_just_noise.py
```

The script also can be started with different parameters. You can get a description 
for them using

```
python experiments/proseqo/comparison_on_just_noise.py -h
```

### Run Rediscovery Experiments on Artificial Data

The general scheme to run the experiments on artificial data is
```
python experiments/proseqo/reproducibility.py --noise_models [noise models] --noise_probabilities [noise probability] --nr_of_process_trees [nr_of_process_trees] --nr_of_traces [nr_of_traces]
```

You can get an explanation of all available parameters via:
```
python experiments/proseqo/reproducibility.py -h
```

"noise models" is a space separated list of noise models. The available options
are "remove", "add", "add_existing", "swap" and "remove_add_swapp".

"noise_probability" controls the amount of noise and is a float between 0.0 inclusive
and 1.0 exclusive. 0.0 means "no noise".

"nr_of_process_trees" is an integer and says how many artificial event logs 
should be generated. 

"nr_of_tracess" is a space separated list of integers and controls how many sequences
should be generated. 

Example: 

```
python experiments/proseqo/reproducibility.py --noise_models remove --noise_probabilities 0.05 --nr_of_process_trees 20 --nr_of_traces 100 200
```

The results of the experiments will be written to "experiments/proseqo/process_tree_reconstruction".

### Run Experiments on Real-World-Logs

The general scheme to run the experiments on the provided real-world-logs is

```
python experiments/proseqo/comparison/[script] --log [Log]
```

"script" is one of
- apply_dfg.py
- apply_split_miner.py
- apply_inductive_miner_infrequent.py
- apply_indulpet_miner.py
- apply_proseqo.py
- apply_prosimple.py

"log" is one of 
- Permits
- Loans
- Purchases
- RollingMill

All scripts can be executed with the "-h" parameter to show additional parameters, for example

```
python experiments/proseqo/comparison/apply_prosimple.py -h
```

Example experiment run:
 
```
python experiments/proseqo/comparison/apply_prosimple.py --log Purchases
```

The results of the experiments will be written to "experiments/proseqo/comparison/results".

#### Run Scalability Experiment

```
python experiments/proseqo/scalability.py
```

The results will be written to "experiments/proseqo/scalability".

#### Run Prosimple Hyperparameter Experiment

```
python experiments/proseqo/prosimple_hyperparameter.py --log Purchases --alpha 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0
```

The results will be written to "experiments/proseqo/prosimple_hyperparameter".

## Run Experiments Using Docker

Pull the "proseqo-experiments" image from the Dockerhub registry:

```
docker pull shsbwiegand/proseqo-experiments:latest
```

If you are not root, we have to make sure, that your user is allowed to access the
results direcotry: 

```
mkdir -p ~/proseqo-experiments/results/reconstruction
```

### Run the Sanity Check

```
docker run --user $(id -u):$(id -g) --rm --name=proseqo-experiments-sanity-check -it --entrypoint /bin/bash --volume ~/proseqo-experiments/results:/opt/prolothar-backend/experiments/proseqo/process_tree_reconstruction shsbwiegand/proseqo-experiments:latest -c 'Xvfb :99 & python ${PYTHONPATH}/experiments/proseqo/comparison_on_just_noise.py'
```

### Run Rediscovery Experiments on Artificial Data

The scheme of the parameters is the same as in the corresponding section above.
Therefore, the following example should suffice:

```
docker run -d --user $(id -u):$(id -g) -e PYTHONPATH=/opt/prolothar-backend --name=proseqo-experiments-remove-noise --volume ~/proseqo-experiments/results/reconstruction:/opt/prolothar-backend/experiments/proseqo/process_tree_reconstruction shsbwiegand/proseqo-experiments:latest --noise_models remove --noise_probabilities 0.05 --nr_of_process_trees 20 --nr_of_traces 100 250 500 750 1000
```

### Run Experiments on Real-World-Logs

The scheme of the parameters is the same as in the corresponding section above.
Therefore, the following example should suffice:

```
docker run --user $(id -u):$(id -g) --rm --name=proseqo-experiments-purchases-prosimple -it --entrypoint /bin/bash --volume ~/proseqo-experiments/results:/opt/prolothar-backend/experiments/proseqo/comparison/results shsbwiegand/proseqo-experiments:latest -c 'Xvfb :99 & python ${PYTHONPATH}/experiments/proseqo/comparison/apply_prosimple.py --log Purchases'
```

#### Run Scalability Experiment

```
docker run --user $(id -u):$(id -g) --rm --name=proseqo-experiments-scalability -it --entrypoint /bin/bash --volume ~/proseqo-experiments/results:/opt/prolothar-backend/experiments/proseqo/scalability shsbwiegand/proseqo-experiments:latest -c 'Xvfb :99 & python ${PYTHONPATH}/experiments/proseqo/scalability.py'
```

#### Run Prosimple Hyperparameter Experiment

```
docker run --user $(id -u):$(id -g) --rm --name=proseqo-experiments-prosimple-parameter -it --entrypoint /bin/bash --volume ~/proseqo-experiments/results:/opt/prolothar-backend/experiments/proseqo/prosimple_hyperparameter shsbwiegand/proseqo-experiments:latest -c 'Xvfb :99 & python ${PYTHONPATH}/experiments/proseqo/prosimple_hyperparameter.py --log Purchases --alpha 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0'
```

 


 
