diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f569e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +/outputs +/tests/__pycache__ +/benchmarks/plots/* +/tests/__pycache__ +/benchmarks/slurm* +*/__pycache__/* +/benchmarks/runscripts/runscript_*__*.xml +/benchmarks/benchmark-tool/output* +/benchmarks/cluster_script__* +/.vscode +.DS_Store +*.DS_Store +.vscode +./benchmarks/results/*/*/*.ods +*.ods \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d3e6413 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "benchmarks/benchmark-tool"] + path = benchmarks/benchmark-tool + url = https://github.com/potassco/benchmark-tool + branch = master +[submodule "benchmarks/asprilo/asprilo-abstraction-encodings"] + path = benchmarks/asprilo/asprilo-abstraction-encodings + url = https://github.com/krr-up/asprilo-abstraction-encodings.git + branch = torsten/sandbox +[submodule "benchmarks/telingo"] + path = benchmarks/telingo + url = https://github.com/susuhahnml/telingo.git + branch = get-program diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e26e10 --- /dev/null +++ b/README.md @@ -0,0 +1,222 @@ +# Automata for dynamic answer set solving (*atlingo*) + +This framework implements temporal constraints expressed in an extension of Answer Set Programming (ASP) with language constructs from dynamic logic. +It transforms dynamic constraints into an automaton expressed in terms of a logic program that enforces the satisfaction of the original constraint. +## Setup + +- Install dependencies using [conda](https://anaconda.org) with the [environment.yml](environment.yml) file + +```shell +conda env create -f environment.yml +``` + +- Install manually `MONA` from [this](https://www.brics.dk/mona/download.html) instructions + +- Update git-submodules. +```shell +git submodule update --init --recursive +``` + +- Check the installation by running the tests + +``` +make tests -B +``` + +------- +## Benchmarks + +More [information](./benchmarks/README.md) on how to run benchmarks + +------- + +## Domain Specific Knowledge + +All domain specific knowledge can be found in the directory [./dom](./dom). Each sub-directory has the name of the domain `$DOM` + +Each these folders has the following elements: +- `instances\` folder with all instances +- `temporal_constraints\` folder with all temporal constraints +- `glue.lp` File mapping all predicates used in the constraint to predicate `trace/2`. Used in automata approaches and must be handcrafted. +- `telingo_choices.lp` Adds a choice for every predicate used in the constraint. Used by the telingo approach. + +To integrate the a new domain with the make file add parameter `RUN_DOM_FILES_$DOM` with the paths to the encodings of the problem. We recommend storing those encodings inside the domain folder. + +------- + +## Dynamic Constraints + +The accepted dynamic constraints have the form: +``` +:- not &del{}, . +``` +**Example** [dom/test/temporal_constraints/example.lp](./dom/test/temporal_constraints/example.lp) + + The syntax for the LDLf formulas is defined in [encodings/translations/grammar.lp](./encodings/translations/grammar.lp) + +------- + +## Translate + +#### `make translate` + +``` +make translate DOM=$DOM APP=$APP CONSTRAINT=$CNAME INSTANCE=$INSTANCEPATH HORIZON=$H +``` + +- `$DOM` Name of the domain (folder inside `./dom`) +- `$APP` Approach name + - `awf` Translates to an alternating automata using meta-programming + - `dfa-mso` Translates to a deterministic automata using MONA and the mso translation from ldlf + - `dfa-stm` Translates to a deterministic automata using MONA and the stm translation from ldlf + - `nfa` Translates to a non-deterministic by first computing the afw and then calling python + - `nfa-awf` Translates to a non-deterministic by first computing the afw and then using an asp encoding + - `telingo` Translates to a logic program using adaptation of telingo + - `nc` The constraint is not considered +- `$CNAME` Constraint name `./dom/$DOM/temporal_constraints/$CNAME.lp` +- `$INSTANCEPATH` Path to the instance +- `$H` Horizon (Number of time steps) only needed for `telingo` approach +- `$H` Horizon (Number of time steps) only needed for `telingo` approach + +All output files can be found in the `outputs` directory + +##### Example +``` +make translate DOM=test APP=afw CONSTRAINT=delex INSTANCE=dom/test/instances/delex_sat.lp +``` +``` +Translating APP=afw DOM=test CONSTRAINT=delex INSTANCE=delex_sat + +Reifying constraint... +gringo encodings/translations/grammar.lp dom/test/temporal_constraints/delex.lp dom/test/instances/delex_sat.lp --output=reify > ./outputs/test/afw/delex/delex_sat/reified.lp +Reification successfull +Translating.... +clingo ./outputs/test/afw/delex/delex_sat/reified.lp ./encodings/translations/ldlf2afw.lp -n 0 --outf=0 -V0 --out-atomf=%s. --warn=none | head -n1 | tr ". " ".\n" > ./outputs/test/afw/delex/delex_sat/afw_automata.lp +Translation to afw successfull. +Output saved in ./outputs/test/afw/delex/delex_sat/afw_automata.lp +``` + +------- + +## Filter traces + +#### `make run` + +A translation has to be performed before using this command. By running the command `make translate-run` instead, the translation will be made before only if the isn't one already saved. + + +``` +make run DOM=$DOM APP=$APP CONSTRAINT=$CNAME INSTANCE=$INSTANCEPATH HORIZON=$H MODELS=$M RUN_FILES=$RUN_FILES +``` +- `$H` Horizon (Number of time steps) +- `$M` Number of models (`0` for all, `1` for the first model) +- `$RUN_FILES` Any additional files or parameters that will be passed to clingo as a string + +##### Example (SAT) +``` +make run APP=afw CONSTRAINT=delex DOM=test INSTANCE=dom/test/instances/delex_sat.lp HORIZON=3 RUN_FILES="--warn=none" +``` + +``` +Running APP=afw DOM=test CONSTRAINT=delexINSTANCE=delex_sat HORIZON=3 +clingo ./outputs/test/afw/delex/delex_sat/afw_automata.lp dom/test/instances/delex_sat.lp encodings/automata_run/run.lp dom/test/glue.lp --warn=none -c horizon=3 -n 1 | tee ./outputs/test/afw/delex/delex_sat/plan_h-3_n-1.txt +clingo version 5.4.0 +Reading from ...st/afw/delex/delex_sat/afw_automata.lp ... +Solving... +Answer: 1 +a(1) b(0) b(1) b(2) b(3) +SATISFIABLE + +Models : 1 +Calls : 1 +Time : 0.005s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) +CPU Time : 0.005s +``` + +##### Example (UNSAT) +``` +make run APP=afw CONSTRAINT=delex DOM=test INSTANCE=dom/test/instances/delex_unsat.lp HORIZON=3 RUN_FILES="--warn=none" +``` + +``` +Running APP=afw DOM=test CONSTRAINT=delexINSTANCE=delex_unsat HORIZON=3 +clingo ./outputs/test/afw/delex/delex_unsat/afw_automata.lp dom/test/instances/delex_unsat.lp encodings/automata_run/run.lp dom/test/glue.lp --warn=none -c horizon=3 -n 1 | tee ./outputs/test/afw/delex/delex_unsat/plan_h-3_n-1.txt +clingo version 5.4.0 +Reading from .../afw/delex/delex_unsat/afw_automata.lp ... +Solving... +UNSATISFIABLE + +Models : 0 +Calls : 1 +Time : 0.004s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) +CPU Time : 0.004s +``` + + + +#### Generate traces + +To compute all possible traces for an automata-based approach it is enough to include file [trace_generator.lp](./encodings/automata_run/trace_generator.lp). + +##### Example +``` +make run APP=dfa-mso CONSTRAINT=delex DOM=test INSTANCE=dom/test/instances/delex_unsat.lp HORIZON=3 RUN_FILES="--warn=none ./encodings/automata_run/trace_generator.lp" MODELS=0 +``` +``` +Running APP=dfa-mso DOM=test CONSTRAINT=delexINSTANCE=delex_unsat HORIZON=3 +clingo ./outputs/test/dfa-mso/delex/delex_unsat/dfa-mso_automata.lp dom/test/instances/delex_unsat.lp encodings/automata_run/run.lp --warn=none ./encodings/automata_run/trace_generator.lp -c horizon=3 -n 0 | tee ./outputs/test/dfa-mso/delex/delex_unsat/plan_h-3_n-0.txt +clingo version 5.4.0 +Reading from .../delex/delex_unsat/dfa-mso_automata.lp ... +Solving... +Answer: 1 +a(1) b(0) b(2) b(3) +Answer: 2 +a(1) b(0) b(2) b(3) +Answer: 3 +a(1) b(0) b(2) b(3) +Answer: 4 +a(1) b(0) b(2) b(3) +Answer: 5 +a(1) b(0) b(2) b(3) +Answer: 6 +a(1) b(0) b(2) b(3) +Answer: 7 +a(1) b(0) b(2) b(3) +Answer: 8 +a(1) b(0) b(2) b(3) +SATISFIABLE + +Models : 8 +Calls : 1 +Time : 0.003s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) +CPU Time : 0.003s +``` +------- + +## Visualize + +Visualize an automata + +##### `make viz-png` and `make viz-tex` + +``` +APP=afw CONSTRAINT=delex DOM=test INSTANCE=dom/test/instances/delex_unsat.lp + +``` + +##### Example (afw in png) +``` +make viz-png APP=afw CONSTRAINT=delex DOM=test INSTANCE=dom/test/instances/delex_sat.lp +``` +![](./img/img_afw.png) + +##### Example (dfa-mso in pdf) +``` +make viz-tex APP=dfa-mso CONSTRAINT=delex DOM=test INSTANCE=dom/test/instances/delex_sat.lp +``` +![](./img/img_dfa.png) + +------- + +## Workflow +![](./img/workflow.png) diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 0000000..925c546 --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,82 @@ +# Benchmarks + +For the benchmarking we use the benchmarking tool as a submodule installed. We provide a set of useful commands and scripts. + +The files found in [./benchmarks/programs](../benchmarks/programs) correspond to our particular approach and are copied to the submodule folder to be used by the tool. A especial treatment of the scripts was needed to account for the preprocessing of each instance. + +We use the following scripts to automatize the jobs for the benchmarks. + +##### [./run_bm.sh](./run_bm.sh) +- Generates specialized run scripts by duplicating the provided [template for the domain](./runscripts/runscript_asprilo-abc.xml) and replacing special parameters: (Horizon, number of models, and additional). +- Calls `./bgen` to generate benchmarking scripts from the benchmarking tool. +- Runs the start files for each instance. + By default, these files will make a call to slurm for adding a process to the queue with `sbatch`. If you wish to use python change variable `mode` to `1`. +- Checks output for errors. +- Calls `./beval` to scrap the stats to a xml file +- Checks output for errors, if an error was found then shows the output with the internal error. +- Cleans output +- All results are saved in [./results](./results) inside the folder corresponding to the environment + +##### [./batch_all_$DOM.sh](./batch_all.sh) +- Cleans environment. +- Makes a series of calls to `./run_bm.sh` with different parameters. +- Gathers result summary +- Sends email to notify that evaluation finished. + +##### [./compute_all_ods.sh](./compute_all_ods.sh) +- Computes all the `.ods` files from the results + + +## Plots + +A python plot script was created matching the patterns from our personalized benchmarks. +This script takes the precalculated `.ods` results and generates images, tables and tikz files. + +``` +Plot obs files from benchmark tool + +optional arguments: + -h, --help show this help message and exit + --stat STAT Status: choices,conflicts,cons,csolve,ctime,error,mem, + memout,models,ngadded,optimal,restarts,status,time,tim + eout,vars,ptime (default: None) + --approach APPROACH Approach to be plotted awf, asp, nc or dfa. Can pass + multiple (default: None) + --dom DOM Name of domain (default: asprilo) + --constraint CONSTRAINT + Contraint to be plotted, if non is passed all + constraints will be plotted. Can pass multiple + (default: None) + --horizon HORIZON Horizon to be plotted. Can pass multiple (default: + None) + --models MODELS Number of models computed in the benchmark with clingo + -n (default: 1) + --prefix PREFIX Prefix for output files (default: ) + --csv When this flag is passed, the table is also saved in + csv format (default: False) + --plotmodels When this flag is passed, the number of models in + plotted (default: False) + --use-lambda When this flag is passed, horizons are transform to + lambda with +1 (default: False) + --use-gmean When this flag is passed, computes gmean of all + horizons (default: False) + --type TYPE Bar or table (default: bar) + --instance INSTANCE The name of a single instance (default: None) + --ignore_prefix IGNORE_PREFIX + Prefix to ignore in the instances (default: None) + --ignore_any IGNORE_ANY + Any to ignore in the instances (default: None) + --y Y Name for the y axis (default: None) + --x X Name for the x axis (default: Horizon) + ``` + +## *asprilo* Benchmarks from paper + +1. Setup path to atlingo in folder in [./run_bm.sh](./run_bm.sh) + +1. Run all benchmarks from script `./batch_all_asprilo-abc.sh` + +2. Compute ods files `./compute_all_ods.sh` + +3. Plot results `./plot_script_asprilo-abc.sh` + diff --git a/benchmarks/asprilo/asprilo-abstraction-encodings b/benchmarks/asprilo/asprilo-abstraction-encodings new file mode 160000 index 0000000..e73b26f --- /dev/null +++ b/benchmarks/asprilo/asprilo-abstraction-encodings @@ -0,0 +1 @@ +Subproject commit e73b26f00b3d49078565017492f91be7af32b2ad diff --git a/benchmarks/batch_all_asprilo-abc.sh b/benchmarks/batch_all_asprilo-abc.sh new file mode 100755 index 0000000..8cbf5ef --- /dev/null +++ b/benchmarks/batch_all_asprilo-abc.sh @@ -0,0 +1,59 @@ +#!/bin/bash +#Activate conda env +# source /usr/local/apps/anaconda3/etc/profile.d/conda.sh +# conda activate temporal-automata +make copy-programs +cd .. +make clean -s +cd benchmarks + +make asprilo-clean-instances +make asprilo-abc-robots-instance + +./run_bm.sh asprilo-abc afw 24 1 +# ./run_bm.sh asprilo-abc afw 25 1 +# ./run_bm.sh asprilo-abc afw 26 1 +# ./run_bm.sh asprilo-abc afw 27 1 +# ./run_bm.sh asprilo-abc afw 28 1 +# ./run_bm.sh asprilo-abc afw 29 1 +# ./run_bm.sh asprilo-abc afw 30 1 + +# ./run_bm.sh asprilo-abc telingo 24 1 +# ./run_bm.sh asprilo-abc telingo 25 1 +# ./run_bm.sh asprilo-abc telingo 26 1 +# ./run_bm.sh asprilo-abc telingo 27 1 +# ./run_bm.sh asprilo-abc telingo 28 1 +# ./run_bm.sh asprilo-abc telingo 29 1 +# ./run_bm.sh asprilo-abc telingo 30 1 + +# ./run_bm.sh asprilo-abc dfa-mso 24 1 +# ./run_bm.sh asprilo-abc dfa-mso 25 1 +# ./run_bm.sh asprilo-abc dfa-mso 26 1 +# ./run_bm.sh asprilo-abc dfa-mso 27 1 +# ./run_bm.sh asprilo-abc dfa-mso 28 1 +# ./run_bm.sh asprilo-abc dfa-mso 29 1 +# ./run_bm.sh asprilo-abc dfa-mso 30 1 + +# ./run_bm.sh asprilo-abc dfa-stm 24 1 +# ./run_bm.sh asprilo-abc dfa-stm 25 1 +# ./run_bm.sh asprilo-abc dfa-stm 26 1 +# ./run_bm.sh asprilo-abc dfa-stm 27 1 +# ./run_bm.sh asprilo-abc dfa-stm 28 1 +# ./run_bm.sh asprilo-abc dfa-stm 29 1 +# ./run_bm.sh asprilo-abc dfa-stm 30 1 + +# ./run_bm.sh asprilo-abc nc 24 1 +# ./run_bm.sh asprilo-abc nc 25 1 +# ./run_bm.sh asprilo-abc nc 26 1 +# ./run_bm.sh asprilo-abc nc 27 1 +# ./run_bm.sh asprilo-abc nc 28 1 +# ./run_bm.sh asprilo-abc nc 29 1 +# ./run_bm.sh asprilo-abc nc 30 1 + + +python size-table.py + +# make clean -s + +# cd .. +# make clean -s diff --git a/benchmarks/batch_all_asprilo-md.sh b/benchmarks/batch_all_asprilo-md.sh new file mode 100755 index 0000000..572bf35 --- /dev/null +++ b/benchmarks/batch_all_asprilo-md.sh @@ -0,0 +1,94 @@ +#!/bin/bash +#Activate conda env +source /usr/local/apps/anaconda3/etc/profile.d/conda.sh +conda activate temporal-automata +make copy-programs +make clean -s + +make asprilo-clean-instances +make asprilo-small-instances +###### ALL MODELS + +./run_bm.sh asprilo afw 6 0 +./run_bm.sh asprilo afw 7 0 +#./run_bm.sh asprilo afw 8 0 + +./run_bm.sh asprilo telingo 6 0 +./run_bm.sh asprilo telingo 7 0 +#./run_bm.sh asprilo telingo 8 0 + +./run_bm.sh asprilo dfa-mso 6 0 +./run_bm.sh asprilo dfa-mso 7 0 + +./run_bm.sh asprilo dfa-stm 7 0 +./run_bm.sh asprilo dfa-stm 6 0 + +#./run_bm.sh asprilo nc 6 0 +#./run_bm.sh asprilo nc 7 0 +#./run_bm.sh asprilo nc 6 0 +#./run_bm.sh asprilo nc 7 0 +#./run_bm.sh asprilo nc 8 0 + + +# make asprilo-clean-instances +# make asprilo-all-grid +###### ALL MODELS GRID + +# ./run_bm.sh asprilo afw 5 0 grid- + +#./run_bm.sh asprilo afw_del 5 0 grid- + +#./run_bm.sh asprilo asp 5 0 grid- + +#./run_bm.sh asprilo nc 5 0 grid- + +# ./run_bm.sh asprilo afw 6 0 grid- + +# ./run_bm.sh asprilo afw_del 6 0 grid- + +# ./run_bm.sh asprilo asp 6 0 grid- + +# ./run_bm.sh asprilo nc 6 0 grid- + +# ./run_bm.sh asprilo afw_del 20 1 grid- +# ./run_bm.sh asprilo afw_del 25 1 grid- +# ./run_bm.sh asprilo afw_del 30 1 grid- +# ./run_bm.sh asprilo afw_del 35 1 grid- + +# ./run_bm.sh asprilo afw 20 1 grid- +# ./run_bm.sh asprilo afw 25 1 grid- +# ./run_bm.sh asprilo afw 30 1 grid- +# ./run_bm.sh asprilo afw 35 1 grid- + +# ./run_bm.sh asprilo nc 20 1 grid- +# ./run_bm.sh asprilo nc 25 1 grid- +# ./run_bm.sh asprilo nc 30 1 grid- +# ./run_bm.sh asprilo nc 35 1 grid- + +# ./run_bm.sh asprilo asp 20 1 grid- +# ./run_bm.sh asprilo asp 25 1 grid- +# ./run_bm.sh asprilo asp 30 1 grid- +# ./run_bm.sh asprilo asp 35 1 grid- + +###### PROJECTED MODELS TO VERIFY CORRECTENESS +# make asprilo-clean-instances +# make asprilo-small-instances +./run_bm.sh asprilo afw 7 0 proj- --project=show +#./run_bm.sh asprilo afw 7 0 proj- '--project=show' + +./run_bm.sh asprilo telingo 7 0 proj- --project=show +#./run_bm.sh asprilo afw_del 7 0 proj- '--project=show' + +./run_bm.sh asprilo dfa-stm 7 0 proj- --project=show + +./run_bm.sh asprilo dfa-mso 7 0 proj- --project=show + + +make clean -s + +python size-table.py + +./print_summary.sh asprilo + +cd .. +make clean -s diff --git a/benchmarks/batch_all_elevator.sh b/benchmarks/batch_all_elevator.sh new file mode 100755 index 0000000..abd4f1c --- /dev/null +++ b/benchmarks/batch_all_elevator.sh @@ -0,0 +1,118 @@ +#!/bin/bash +#Activate conda env +source /usr/local/apps/anaconda3/etc/profile.d/conda.sh +conda activate temporal-automata +make copy-programs + +###### ALL MODELS + +make clean + +./run_bm.sh elevator afw 8 0 +./run_bm.sh elevator afw 9 0 +./run_bm.sh elevator afw 10 0 +./run_bm.sh elevator afw 11 0 +./run_bm.sh elevator afw 12 0 +./run_bm.sh elevator afw 13 0 +./run_bm.sh elevator afw 14 0 +./run_bm.sh elevator afw 15 0 +./run_bm.sh elevator afw 16 0 +./run_bm.sh elevator afw 17 0 +./run_bm.sh elevator afw 18 0 +./run_bm.sh elevator afw 19 0 +./run_bm.sh elevator afw 20 0 +./run_bm.sh elevator afw 21 0 + +make clean + +./run_bm.sh elevator telingo 8 0 +./run_bm.sh elevator telingo 9 0 +./run_bm.sh elevator telingo 10 0 +./run_bm.sh elevator telingo 11 0 +./run_bm.sh elevator telingo 12 0 +./run_bm.sh elevator telingo 13 0 +./run_bm.sh elevator telingo 14 0 +./run_bm.sh elevator telingo 15 0 +./run_bm.sh elevator telingo 16 0 +./run_bm.sh elevator telingo 17 0 +./run_bm.sh elevator telingo 18 0 +./run_bm.sh elevator telingo 19 0 +./run_bm.sh elevator telingo 20 0 +./run_bm.sh elevator telingo 21 0 + +make clean + +./run_bm.sh elevator dfa-mso 8 0 +./run_bm.sh elevator dfa-mso 9 0 +./run_bm.sh elevator dfa-mso 10 0 +./run_bm.sh elevator dfa-mso 11 0 +./run_bm.sh elevator dfa-mso 12 0 +./run_bm.sh elevator dfa-mso 13 0 +./run_bm.sh elevator dfa-mso 14 0 +./run_bm.sh elevator dfa-mso 15 0 +./run_bm.sh elevator dfa-mso 16 0 +./run_bm.sh elevator dfa-mso 17 0 +./run_bm.sh elevator dfa-mso 18 0 +./run_bm.sh elevator dfa-mso 19 0 +./run_bm.sh elevator dfa-mso 20 0 +./run_bm.sh elevator dfa-mso 21 0 + +make clean + +./run_bm.sh elevator dfa-stm 8 0 +./run_bm.sh elevator dfa-stm 9 0 +./run_bm.sh elevator dfa-stm 10 0 +./run_bm.sh elevator dfa-stm 11 0 +./run_bm.sh elevator dfa-stm 12 0 +./run_bm.sh elevator dfa-stm 13 0 +./run_bm.sh elevator dfa-stm 14 0 +./run_bm.sh elevator dfa-stm 15 0 +./run_bm.sh elevator dfa-stm 16 0 +./run_bm.sh elevator dfa-stm 17 0 +./run_bm.sh elevator dfa-stm 18 0 +./run_bm.sh elevator dfa-stm 19 0 +./run_bm.sh elevator dfa-stm 20 0 +./run_bm.sh elevator dfa-stm 21 0 + +make clean + +./run_bm.sh elevator nfa 8 0 +./run_bm.sh elevator nfa 9 0 +./run_bm.sh elevator nfa 10 0 +./run_bm.sh elevator nfa 11 0 +./run_bm.sh elevator nfa 12 0 +./run_bm.sh elevator nfa 13 0 +./run_bm.sh elevator nfa 14 0 +./run_bm.sh elevator nfa 15 0 +./run_bm.sh elevator nfa 16 0 +./run_bm.sh elevator nfa 17 0 +./run_bm.sh elevator nfa 18 0 +./run_bm.sh elevator nfa 19 0 +./run_bm.sh elevator nfa 20 0 +./run_bm.sh elevator nfa 21 0 + +make clean +./run_bm.sh elevator nc 8 0 +./run_bm.sh elevator nc 9 0 +./run_bm.sh elevator nc 10 0 +./run_bm.sh elevator nc 11 0 +./run_bm.sh elevator nc 12 0 +# ./run_bm.sh elevator nc 13 0 +# ./run_bm.sh elevator nc 14 0 +# ./run_bm.sh elevator nc 15 0 +# ./run_bm.sh elevator nc 16 0 +# ./run_bm.sh elevator nc 17 0 +#./run_bm.sh elevator nc 18 0 +#./run_bm.sh elevator nc 19 0 +#./run_bm.sh elevator nc 20 0 +#./run_bm.sh elevator nc 21 0 +# + + + +python size-table.py + +./print_summary.sh elevator + +cd .. +make clean -s diff --git a/benchmarks/batch_all_hanoi.sh b/benchmarks/batch_all_hanoi.sh new file mode 100755 index 0000000..f95620f --- /dev/null +++ b/benchmarks/batch_all_hanoi.sh @@ -0,0 +1,145 @@ +#!/bin/bash +#Activate conda env +source /usr/local/apps/anaconda3/etc/profile.d/conda.sh +conda activate temporal-automata +make copy-programs +cd .. +make clean -s +cd benchmarks + +make hanoi-clean-instances + +make hanoi-small-instance + +./run_bm.sh hanoi nc 14 0 +./run_bm.sh hanoi nc 15 0 +./run_bm.sh hanoi nc 16 0 +./run_bm.sh hanoi nc 17 0 +./run_bm.sh hanoi nc 18 0 + +./run_bm.sh hanoi afw 14 0 +./run_bm.sh hanoi afw 15 0 +./run_bm.sh hanoi afw 16 0 +./run_bm.sh hanoi afw 17 0 +./run_bm.sh hanoi afw 18 0 + +./run_bm.sh hanoi nfa-afw 14 0 +./run_bm.sh hanoi nfa-afw 15 0 +./run_bm.sh hanoi nfa-afw 16 0 +./run_bm.sh hanoi nfa-afw 17 0 +./run_bm.sh hanoi nfa-afw 18 0 + +./run_bm.sh hanoi nfa 14 0 +./run_bm.sh hanoi nfa 15 0 +./run_bm.sh hanoi nfa 16 0 +./run_bm.sh hanoi nfa 17 0 +./run_bm.sh hanoi nfa 18 0 + +./run_bm.sh hanoi dfa-mso 14 0 +./run_bm.sh hanoi dfa-mso 15 0 +./run_bm.sh hanoi dfa-mso 16 0 +./run_bm.sh hanoi dfa-mso 17 0 +./run_bm.sh hanoi dfa-mso 18 0 + +./run_bm.sh hanoi dfa-stm 14 0 +./run_bm.sh hanoi dfa-stm 15 0 +./run_bm.sh hanoi dfa-stm 16 0 +./run_bm.sh hanoi dfa-stm 17 0 +./run_bm.sh hanoi dfa-stm 18 0 + + +###### PROJECTED MODELS TO VERIFY CORRECTENESS proj- --project=show + +./run_bm.sh hanoi nc 17 0 proj- --project=show +./run_bm.sh hanoi afw 17 0 proj- --project=show +./run_bm.sh hanoi nfa-afw 17 0 proj- --project=show +./run_bm.sh hanoi nfa 17 0 proj- --project=show +./run_bm.sh hanoi dfa-mso 17 0 proj --project=show +./run_bm.sh hanoi dfa-stm 17 0 proj --project=show + +make hanoi-clean-instances +make hanoi-medium-instance + +./run_bm.sh hanoi nc 30 0 +./run_bm.sh hanoi nc 31 0 +./run_bm.sh hanoi nc 32 0 +./run_bm.sh hanoi nc 33 0 +./run_bm.sh hanoi nc 34 0 + +./run_bm.sh hanoi afw 30 0 +./run_bm.sh hanoi afw 31 0 +./run_bm.sh hanoi afw 32 0 +./run_bm.sh hanoi afw 33 0 +./run_bm.sh hanoi afw 34 0 + +./run_bm.sh hanoi nfa-afw 30 0 +./run_bm.sh hanoi nfa-afw 31 0 +./run_bm.sh hanoi nfa-afw 32 0 +./run_bm.sh hanoi nfa-afw 33 0 +./run_bm.sh hanoi nfa-afw 34 0 + +./run_bm.sh hanoi nfa 30 0 +./run_bm.sh hanoi nfa 31 0 +./run_bm.sh hanoi nfa 32 0 +./run_bm.sh hanoi nfa 33 0 +./run_bm.sh hanoi nfa 34 0 + +./run_bm.sh hanoi dfa-mso 30 0 +./run_bm.sh hanoi dfa-mso 31 0 +./run_bm.sh hanoi dfa-mso 32 0 +./run_bm.sh hanoi dfa-mso 33 0 +./run_bm.sh hanoi dfa-mso 34 0 + +./run_bm.sh hanoi dfa-stm 30 0 +./run_bm.sh hanoi dfa-stm 31 0 +./run_bm.sh hanoi dfa-stm 32 0 +./run_bm.sh hanoi dfa-stm 33 0 +./run_bm.sh hanoi dfa-stm 34 0 + +make hanoi-clean-instances +make hanoi-big-instance + +./run_bm.sh hanoi nc 62 0 +./run_bm.sh hanoi nc 63 0 +./run_bm.sh hanoi nc 64 0 +./run_bm.sh hanoi nc 65 0 +./run_bm.sh hanoi nc 66 0 + +./run_bm.sh hanoi afw 62 0 +./run_bm.sh hanoi afw 63 0 +./run_bm.sh hanoi afw 64 0 +./run_bm.sh hanoi afw 65 0 +./run_bm.sh hanoi afw 66 0 + +./run_bm.sh hanoi nfa-afw 62 0 +./run_bm.sh hanoi nfa-afw 63 0 +./run_bm.sh hanoi nfa-afw 64 0 +./run_bm.sh hanoi nfa-afw 65 0 +./run_bm.sh hanoi nfa-afw 66 0 + +./run_bm.sh hanoi nfa 62 0 +./run_bm.sh hanoi nfa 63 0 +./run_bm.sh hanoi nfa 64 0 +./run_bm.sh hanoi nfa 65 0 +./run_bm.sh hanoi nfa 66 0 + +./run_bm.sh hanoi dfa-mso 62 0 +./run_bm.sh hanoi dfa-mso 63 0 +./run_bm.sh hanoi dfa-mso 64 0 +./run_bm.sh hanoi dfa-mso 65 0 +./run_bm.sh hanoi dfa-mso 66 0 + +./run_bm.sh hanoi dfa-stm 62 0 +./run_bm.sh hanoi dfa-stm 63 0 +./run_bm.sh hanoi dfa-stm 64 0 +./run_bm.sh hanoi dfa-stm 65 0 +./run_bm.sh hanoi dfa-stm 66 0 + +python size-table.py + +# make clean -s + +./print_summary.sh hanoi + +cd .. +make clean -s diff --git a/benchmarks/benchmark-tool b/benchmarks/benchmark-tool new file mode 160000 index 0000000..0f99eec --- /dev/null +++ b/benchmarks/benchmark-tool @@ -0,0 +1 @@ +Subproject commit 0f99eecfb2abaf93b735467c73bdf6bb23e2db49 diff --git a/benchmarks/compute_all_ods.sh b/benchmarks/compute_all_ods.sh new file mode 100755 index 0000000..1473127 --- /dev/null +++ b/benchmarks/compute_all_ods.sh @@ -0,0 +1,26 @@ +#!/bin/bash +R=`tput setaf 1` +G=`tput setaf 2` +Y=`tput setaf 3` +B=`tput setaf 5` +C=`tput setaf 6` +NC=`tput sgr0` +cd benchmark-tool +for f in $(find ../results -type f -name "*.beval"); +do +NAME=$(basename -- $f .beval) +DIR=$(dirname -- $f) +rm -f $DIR/*.ods +echo "$Y Computing .ods... for $f $NC" +if [ -s $f ]; then + mv $DIR/$NAME.beval $DIR/$NAME.bevaltmp + cat $DIR/$NAME.bevaltmp | sed 's/measure name="status" type="float" val="2"\/>/measure name="status" type="float" val="2"\/>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/g' > $DIR/$NAME.beval + ./bconv -m time,ctime,csolve,ground0,groundN,models,timeout,restarts,conflicts,choices,domain,vars,cons,mem,error,memout,status,atoms,rules,roriginal,bodies,equiv,rchoices,ptime $f > $DIR/$NAME.ods 2> $DIR/$NAME.error + cat $DIR/$NAME.error + rm $DIR/$NAME.bevaltmp + + +else + echo "$R.beval is empty$NC" +fi +done \ No newline at end of file diff --git a/benchmarks/gen_asprilo_instances.sh b/benchmarks/gen_asprilo_instances.sh new file mode 100644 index 0000000..8426add --- /dev/null +++ b/benchmarks/gen_asprilo_instances.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +#u=p=s and --spr 1 --prs 1 to make more needs of moves +gen -d dom/asprilo-abc/instances -x 7 -y 7 -s 4 -p 2 -r 2 -H -P 4 -u 4 -o 4 --spr 1 --prs 1 + +gen -d dom/asprilo-abc/instances -x 6 -y 7 -s 4 -p 1 -r 2 -H -P 4 -u 4 -o 4 --spr 1 --prs 1 diff --git a/benchmarks/instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp b/benchmarks/instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp new file mode 100644 index 0000000..d72020e --- /dev/null +++ b/benchmarks/instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp @@ -0,0 +1,129 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% = Command-line Arguments ================================= +% -x 7 -y 7 -s 4 -p 2 -r 2 -H -P 4 -u 4 -o 4 -d dom/asprilo-abc/instances --spr 1 --prs 1 +% +% = Instance Statistics ==================================== +% Grid Size X: 7 +% Grid Size Y: 7 +% Number of Nodes: 49 +% Number of Highway Nodes: 37 +% Number of Robots: 2 +% Number of Shelves: 4 +% Number of Picking Stations: 2 +% Number of Products: 4 +% Number of Product Units in Total: 4 +% Number of Orders: 4 +% Number of Orders Lines: 4 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#program base. + +% init +init(object(highway,1),value(at,(1,1))). +init(object(highway,2),value(at,(2,1))). +init(object(highway,4),value(at,(4,1))). +init(object(highway,5),value(at,(5,1))). +init(object(highway,7),value(at,(7,1))). +init(object(highway,8),value(at,(1,2))). +init(object(highway,9),value(at,(2,2))). +init(object(highway,10),value(at,(3,2))). +init(object(highway,11),value(at,(4,2))). +init(object(highway,12),value(at,(5,2))). +init(object(highway,13),value(at,(6,2))). +init(object(highway,14),value(at,(7,2))). +init(object(highway,15),value(at,(1,3))). +init(object(highway,18),value(at,(4,3))). +init(object(highway,21),value(at,(7,3))). +init(object(highway,22),value(at,(1,4))). +init(object(highway,25),value(at,(4,4))). +init(object(highway,28),value(at,(7,4))). +init(object(highway,29),value(at,(1,5))). +init(object(highway,30),value(at,(2,5))). +init(object(highway,31),value(at,(3,5))). +init(object(highway,32),value(at,(4,5))). +init(object(highway,33),value(at,(5,5))). +init(object(highway,34),value(at,(6,5))). +init(object(highway,35),value(at,(7,5))). +init(object(highway,36),value(at,(1,6))). +init(object(highway,37),value(at,(2,6))). +init(object(highway,38),value(at,(3,6))). +init(object(highway,39),value(at,(4,6))). +init(object(highway,40),value(at,(5,6))). +init(object(highway,41),value(at,(6,6))). +init(object(highway,42),value(at,(7,6))). +init(object(highway,45),value(at,(3,7))). +init(object(highway,46),value(at,(4,7))). +init(object(highway,47),value(at,(5,7))). +init(object(highway,48),value(at,(6,7))). +init(object(highway,49),value(at,(7,7))). +init(object(node,1),value(at,(1,1))). +init(object(node,2),value(at,(2,1))). +init(object(node,3),value(at,(3,1))). +init(object(node,4),value(at,(4,1))). +init(object(node,5),value(at,(5,1))). +init(object(node,6),value(at,(6,1))). +init(object(node,7),value(at,(7,1))). +init(object(node,8),value(at,(1,2))). +init(object(node,9),value(at,(2,2))). +init(object(node,10),value(at,(3,2))). +init(object(node,11),value(at,(4,2))). +init(object(node,12),value(at,(5,2))). +init(object(node,13),value(at,(6,2))). +init(object(node,14),value(at,(7,2))). +init(object(node,15),value(at,(1,3))). +init(object(node,16),value(at,(2,3))). +init(object(node,17),value(at,(3,3))). +init(object(node,18),value(at,(4,3))). +init(object(node,19),value(at,(5,3))). +init(object(node,20),value(at,(6,3))). +init(object(node,21),value(at,(7,3))). +init(object(node,22),value(at,(1,4))). +init(object(node,23),value(at,(2,4))). +init(object(node,24),value(at,(3,4))). +init(object(node,25),value(at,(4,4))). +init(object(node,26),value(at,(5,4))). +init(object(node,27),value(at,(6,4))). +init(object(node,28),value(at,(7,4))). +init(object(node,29),value(at,(1,5))). +init(object(node,30),value(at,(2,5))). +init(object(node,31),value(at,(3,5))). +init(object(node,32),value(at,(4,5))). +init(object(node,33),value(at,(5,5))). +init(object(node,34),value(at,(6,5))). +init(object(node,35),value(at,(7,5))). +init(object(node,36),value(at,(1,6))). +init(object(node,37),value(at,(2,6))). +init(object(node,38),value(at,(3,6))). +init(object(node,39),value(at,(4,6))). +init(object(node,40),value(at,(5,6))). +init(object(node,41),value(at,(6,6))). +init(object(node,42),value(at,(7,6))). +init(object(node,43),value(at,(1,7))). +init(object(node,44),value(at,(2,7))). +init(object(node,45),value(at,(3,7))). +init(object(node,46),value(at,(4,7))). +init(object(node,47),value(at,(5,7))). +init(object(node,48),value(at,(6,7))). +init(object(node,49),value(at,(7,7))). +init(object(order,1),value(line,(3,1))). +init(object(order,1),value(pickingStation,1)). +init(object(order,2),value(line,(2,1))). +init(object(order,2),value(pickingStation,2)). +init(object(order,3),value(line,(1,1))). +init(object(order,3),value(pickingStation,2)). +init(object(order,4),value(line,(4,1))). +init(object(order,4),value(pickingStation,1)). +init(object(pickingStation,1),value(at,(3,1))). +init(object(pickingStation,2),value(at,(6,1))). +init(object(product,1),value(on,(3,1))). +init(object(product,2),value(on,(4,1))). +init(object(product,3),value(on,(1,1))). +init(object(product,4),value(on,(2,1))). +init(object(robot,1),value(at,(1,7))). +init(object(robot,2),value(at,(2,7))). +init(object(shelf,1),value(at,(3,3))). +init(object(shelf,2),value(at,(2,4))). +init(object(shelf,3),value(at,(3,4))). +init(object(shelf,4),value(at,(5,4))). diff --git a/benchmarks/instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp b/benchmarks/instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp new file mode 100644 index 0000000..0c32f73 --- /dev/null +++ b/benchmarks/instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp @@ -0,0 +1,137 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% = Command-line Arguments ================================= +% -d dom/asprilo-abc/instances -x 7 -y 7 -s 6 -p 3 -r 3 -H -P 6 -u 6 -o 6 --spr 1 --prs 1 +% +% = Instance Statistics ==================================== +% Grid Size X: 7 +% Grid Size Y: 7 +% Number of Nodes: 49 +% Number of Highway Nodes: 35 +% Number of Robots: 3 +% Number of Shelves: 6 +% Number of Picking Stations: 3 +% Number of Products: 6 +% Number of Product Units in Total: 6 +% Number of Orders: 6 +% Number of Orders Lines: 6 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#program base. + +% init +init(object(highway,1),value(at,(1,1))). +init(object(highway,3),value(at,(3,1))). +init(object(highway,5),value(at,(5,1))). +init(object(highway,7),value(at,(7,1))). +init(object(highway,8),value(at,(1,2))). +init(object(highway,9),value(at,(2,2))). +init(object(highway,10),value(at,(3,2))). +init(object(highway,11),value(at,(4,2))). +init(object(highway,12),value(at,(5,2))). +init(object(highway,13),value(at,(6,2))). +init(object(highway,14),value(at,(7,2))). +init(object(highway,15),value(at,(1,3))). +init(object(highway,18),value(at,(4,3))). +init(object(highway,21),value(at,(7,3))). +init(object(highway,22),value(at,(1,4))). +init(object(highway,25),value(at,(4,4))). +init(object(highway,28),value(at,(7,4))). +init(object(highway,29),value(at,(1,5))). +init(object(highway,30),value(at,(2,5))). +init(object(highway,31),value(at,(3,5))). +init(object(highway,32),value(at,(4,5))). +init(object(highway,33),value(at,(5,5))). +init(object(highway,34),value(at,(6,5))). +init(object(highway,35),value(at,(7,5))). +init(object(highway,36),value(at,(1,6))). +init(object(highway,37),value(at,(2,6))). +init(object(highway,38),value(at,(3,6))). +init(object(highway,39),value(at,(4,6))). +init(object(highway,40),value(at,(5,6))). +init(object(highway,41),value(at,(6,6))). +init(object(highway,42),value(at,(7,6))). +init(object(highway,46),value(at,(4,7))). +init(object(highway,47),value(at,(5,7))). +init(object(highway,48),value(at,(6,7))). +init(object(highway,49),value(at,(7,7))). +init(object(node,1),value(at,(1,1))). +init(object(node,2),value(at,(2,1))). +init(object(node,3),value(at,(3,1))). +init(object(node,4),value(at,(4,1))). +init(object(node,5),value(at,(5,1))). +init(object(node,6),value(at,(6,1))). +init(object(node,7),value(at,(7,1))). +init(object(node,8),value(at,(1,2))). +init(object(node,9),value(at,(2,2))). +init(object(node,10),value(at,(3,2))). +init(object(node,11),value(at,(4,2))). +init(object(node,12),value(at,(5,2))). +init(object(node,13),value(at,(6,2))). +init(object(node,14),value(at,(7,2))). +init(object(node,15),value(at,(1,3))). +init(object(node,16),value(at,(2,3))). +init(object(node,17),value(at,(3,3))). +init(object(node,18),value(at,(4,3))). +init(object(node,19),value(at,(5,3))). +init(object(node,20),value(at,(6,3))). +init(object(node,21),value(at,(7,3))). +init(object(node,22),value(at,(1,4))). +init(object(node,23),value(at,(2,4))). +init(object(node,24),value(at,(3,4))). +init(object(node,25),value(at,(4,4))). +init(object(node,26),value(at,(5,4))). +init(object(node,27),value(at,(6,4))). +init(object(node,28),value(at,(7,4))). +init(object(node,29),value(at,(1,5))). +init(object(node,30),value(at,(2,5))). +init(object(node,31),value(at,(3,5))). +init(object(node,32),value(at,(4,5))). +init(object(node,33),value(at,(5,5))). +init(object(node,34),value(at,(6,5))). +init(object(node,35),value(at,(7,5))). +init(object(node,36),value(at,(1,6))). +init(object(node,37),value(at,(2,6))). +init(object(node,38),value(at,(3,6))). +init(object(node,39),value(at,(4,6))). +init(object(node,40),value(at,(5,6))). +init(object(node,41),value(at,(6,6))). +init(object(node,42),value(at,(7,6))). +init(object(node,43),value(at,(1,7))). +init(object(node,44),value(at,(2,7))). +init(object(node,45),value(at,(3,7))). +init(object(node,46),value(at,(4,7))). +init(object(node,47),value(at,(5,7))). +init(object(node,48),value(at,(6,7))). +init(object(node,49),value(at,(7,7))). +init(object(order,1),value(line,(2,1))). +init(object(order,1),value(pickingStation,1)). +init(object(order,2),value(line,(1,1))). +init(object(order,2),value(pickingStation,1)). +init(object(order,3),value(line,(4,1))). +init(object(order,3),value(pickingStation,1)). +init(object(order,4),value(line,(5,1))). +init(object(order,4),value(pickingStation,1)). +init(object(order,5),value(line,(3,1))). +init(object(order,5),value(pickingStation,1)). +init(object(order,6),value(line,(6,1))). +init(object(order,6),value(pickingStation,1)). +init(object(pickingStation,1),value(at,(2,1))). +init(object(pickingStation,2),value(at,(4,1))). +init(object(pickingStation,3),value(at,(6,1))). +init(object(product,1),value(on,(5,1))). +init(object(product,2),value(on,(3,1))). +init(object(product,3),value(on,(6,1))). +init(object(product,4),value(on,(2,1))). +init(object(product,5),value(on,(1,1))). +init(object(product,6),value(on,(4,1))). +init(object(robot,1),value(at,(1,7))). +init(object(robot,2),value(at,(2,7))). +init(object(robot,3),value(at,(3,7))). +init(object(shelf,1),value(at,(2,3))). +init(object(shelf,2),value(at,(3,3))). +init(object(shelf,3),value(at,(5,3))). +init(object(shelf,4),value(at,(6,3))). +init(object(shelf,5),value(at,(2,4))). +init(object(shelf,6),value(at,(3,4))). diff --git a/benchmarks/instances/elevator/11_floors.lp b/benchmarks/instances/elevator/11_floors.lp new file mode 100644 index 0000000..cbdac5d --- /dev/null +++ b/benchmarks/instances/elevator/11_floors.lp @@ -0,0 +1,6 @@ +#const floors=11. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/benchmarks/instances/elevator/5_floors.lp b/benchmarks/instances/elevator/5_floors.lp new file mode 100644 index 0000000..e03ba47 --- /dev/null +++ b/benchmarks/instances/elevator/5_floors.lp @@ -0,0 +1,6 @@ +#const floors=5. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/benchmarks/instances/elevator/7_floors.lp b/benchmarks/instances/elevator/7_floors.lp new file mode 100644 index 0000000..ad78d8b --- /dev/null +++ b/benchmarks/instances/elevator/7_floors.lp @@ -0,0 +1,6 @@ +#const floors=7. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/benchmarks/instances/elevator/9_floors.lp b/benchmarks/instances/elevator/9_floors.lp new file mode 100644 index 0000000..ad124a5 --- /dev/null +++ b/benchmarks/instances/elevator/9_floors.lp @@ -0,0 +1,6 @@ +#const floors=9. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/benchmarks/instances/hanoi/6_disks.lp b/benchmarks/instances/hanoi/6_disks.lp new file mode 100644 index 0000000..70f6ade --- /dev/null +++ b/benchmarks/instances/hanoi/6_disks.lp @@ -0,0 +1,4 @@ +peg(a;b;c). +disk(1..6). +init_on(1..6,a). +goal_on(1..6,c). \ No newline at end of file diff --git a/benchmarks/join_csv.py b/benchmarks/join_csv.py new file mode 100644 index 0000000..503a4fb --- /dev/null +++ b/benchmarks/join_csv.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# libraries and data +import os +import math +import sys +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +import itertools +import seaborn as sns +from pandas_ods_reader import read_ods +import scipy +from scipy import stats + +import tikzplotlib + +import argparse +from plot import csv2textable + +parser = argparse.ArgumentParser(description='Join csv files ',formatter_class=argparse.ArgumentDefaultsHelpFormatter) +parser.add_argument("--dom",type=str, default='asprilo', + help="Name of domain" ) +parser.add_argument("--constraint", type=str, action='append', + help="Contraint to be plotted, if non is passed all constraints will be plotted. Can pass multiple") +parser.add_argument("--prefix-in", type=str, default="", + help="Prefix for input files" ) +parser.add_argument("--prefix", type=str, default="", + help="Prefix for output files" ) +parser.add_argument("--use-lambda", default=False, action='store_true', + help="When this flag is passed, horizons are transform to lambda with +1") +parser.add_argument("--use-gmean", default=False, action='store_true', + help="When this flag is passed, computes gmean of all horizons") +parser.add_argument("--instance",type=str, action='append', + help="The name of a single instance" ) +args = parser.parse_args() + +#PARAMS +# handle_timeout = not args.ignore_timeout +# zero_timeout = args.zero_timeout + +# Env +dom = args.dom + +use_lambda = args.use_lambda +# use_gmean = args.use_gmean + +# Statistics +constraints = args.constraint + +prefix_in = args.prefix_in +prefix = args.prefix +# plot_n_models = args.plotmodels + +# Instances +instances = args.instance + + +summary = f""" +JOIN CSV + DOM: {dom} + CONSTRAINTS: {constraints} +""" +print(summary) + +dfs = [] +for cons in constraints: + for ins in instances: + file = f'plots/tables/{dom}/{prefix_in}-{cons}-{ins}.csv' + df = pd.read_csv(file) + df["ins"]=ins + df["cons"]=cons + dfs.append(df) +df = pd.concat(dfs,ignore_index=True) +main_cols = ["Stat","cons","ins"] +stats = df['Stat'].unique() +approaches = [c for c in df.columns if c not in main_cols] +cols = main_cols+approaches +df = df[cols] +df = df.sort_values(by=['Stat','cons','ins']) +spetial_words={s:'stats' for s in stats} +spetial_words.update({i:'ins' for i in instances}) +spetial_words.update({c:'cons' for c in constraints}) +tex_table = csv2textable(df,"All","All",approaches,True, + spetial_words=spetial_words, + base_headers=["\\textbf{Stat}","\\textbf{cons}","\\textbf{ins}"], + caption="Statistics with the geometric mean of all horizons.") + +file_name_csv = f'plots/tables/{dom}/{prefix}.csv' +file_name_tex_csv = file_name_csv[:-3]+"tex" + +f = open(file_name_tex_csv, "w") +f.write(tex_table) +f.close() +print("Saved {}".format(file_name_tex_csv)) \ No newline at end of file diff --git a/benchmarks/makefile b/benchmarks/makefile new file mode 100644 index 0000000..7042bde --- /dev/null +++ b/benchmarks/makefile @@ -0,0 +1,82 @@ +copy-programs: + cp -r programs/* benchmark-tool/programs + cp -r programs/runsolver-3.4.0 benchmark-tool + cp programs/clingo.py benchmark-tool/src/benchmarktool/resultparser +clean-results: + rm -rf ./results/* + mkdir ./results/tables +clean-ods: + rm -rf ./results/elevator/*.ods +clean-plots: + rm -rf ./plots/img/* + rm -rf ./plots/tables/* + rm -rf ./plots/tikz/* +clean-runscripts: + rm -rf ./cluster_script__*.sh + rm -rf ./runscripts/runscript_*_*__* +clean-output: + rm -rf benchmark-tool/output/* +clean: + rm -rf fault_runsolver.txt + make clean-plots + make clean-runscripts + make clean-output +plots: + python plot.py $(ARGS) +ods: + ./compute_all_ods.sh + + +# ASPRILO +asprilo-md-clean-instances: + rm -rf ./instances/asprilo/md/structured/* + rm -rf ./instances/asprilo/md/gridworld/* +asprilo-md-small-instances: + mkdir -p ./instances/asprilo/md/structured + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/structured/x7_y6_r4 ./instances/asprilo/md/structured +asprilo-md-medium-instances: + mkdir -p ./instances/asprilo/md/structured + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/structured/x10_y6_r10 ./instances/asprilo/md/structured +asprilo-md-large-instances: + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/structured/x10_y9_r20 ./instances/asprilo/md/structured + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/structured/x10_y10_r20 ./instances/asprilo/md/structured + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/structured/x10_y12_r20 ./instances/asprilo/md/structured +asprilo-md-all-instances: + make medium-instances + make small-instances + make large-instances +asprilo-md-all-grid: + mkdir -p ./instances/asprilo/md/gridworld + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/gridworld/x4_y4_n12_r4 ./instances/asprilo/md/gridworld + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/gridworld/x4_y4_n16_r4 ./instances/asprilo/md/gridworld + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/gridworld/x5_y5_n20_r5 ./instances/asprilo/md/gridworld + cp -r ../benchmarks/asprilo/asprilo-abstraction-encodings/instances/md/gridworld/x5_y5_n25_r5 ./instances/asprilo/md/gridworld + + + +asprilo-clean-instances: + rm -rf ./instances/asprilo/* +asprilo-abc-small-instance: + mkdir -p ./instances/asprilo/abc/small + cp -r ../dom/asprilo-abc/instances/small/* ./instances/asprilo/abc/small/ +asprilo-abc-robots-instance: + mkdir -p ./instances/asprilo/abc/robots + cp -r ../dom/asprilo-abc/instances/robots/* ./instances/asprilo/abc/robots/ +asprilo-abc-all-instance: + mkdir -p ./instances/asprilo/abc + cp -r ../dom/asprilo-abc/instances/* ./instances/asprilo/abc/ + + +# HANOI +hanoi-clean-instances: + rm -rf ./instances/hanoi/* + rm -rf ./instances/hanoi/* +hanoi-small-instance: + mkdir -p ./instances/hanoi + cp -r ../dom/hanoi/instances/4_disks.lp ./instances/hanoi +hanoi-medium-instance: + mkdir -p ./instances/hanoi + cp -r ../dom/hanoi/instances/5_disks.lp ./instances/hanoi +hanoi-big-instance: + mkdir -p ./instances/hanoi + cp -r ../dom/hanoi/instances/6_disks.lp ./instances/hanoi \ No newline at end of file diff --git a/benchmarks/out.txt b/benchmarks/out.txt new file mode 100644 index 0000000..54175a0 --- /dev/null +++ b/benchmarks/out.txt @@ -0,0 +1,1092 @@ +cp -r programs/* benchmark-tool/programs +cp -r programs/runsolver-3.4.0 benchmark-tool +cp programs/clingo.py benchmark-tool/src/benchmarktool/resultparser +rm -rf ./instances/asprilo/* +mkdir -p ./instances/asprilo/abc/robots +cp -r ../dom/asprilo-abc/instances/robots/* ./instances/asprilo/abc/robots/ + + --------------------------- + Starting benchmarks for afw__h-24__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-24__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-24__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776063 +Submitted batch job 776064 +Submitted batch job 776065 +Submitted batch job 776066 +Submitted batch job 776067 +Submitted batch job 776068 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-24__n-1/afw__h-24__n-1.beval + Done afw__h-24__n-1 + + --------------------------- + Starting benchmarks for afw__h-25__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-25__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-25__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776069 +Submitted batch job 776070 +Submitted batch job 776071 +Submitted batch job 776072 +Submitted batch job 776073 +Submitted batch job 776074 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-25__n-1/afw__h-25__n-1.beval + Done afw__h-25__n-1 + + --------------------------- + Starting benchmarks for afw__h-26__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-26__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-26__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776075 +Submitted batch job 776076 +Submitted batch job 776077 +Submitted batch job 776078 +Submitted batch job 776079 +Submitted batch job 776080 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-26__n-1/afw__h-26__n-1.beval + Done afw__h-26__n-1 + + --------------------------- + Starting benchmarks for afw__h-27__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-27__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-27__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776081 +Submitted batch job 776082 +Submitted batch job 776083 +Submitted batch job 776084 +Submitted batch job 776085 +Submitted batch job 776086 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-27__n-1/afw__h-27__n-1.beval + Done afw__h-27__n-1 + + --------------------------- + Starting benchmarks for afw__h-28__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-28__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-28__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776087 +Submitted batch job 776088 +Submitted batch job 776089 +Submitted batch job 776090 +Submitted batch job 776091 +Submitted batch job 776092 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-28__n-1/afw__h-28__n-1.beval + Done afw__h-28__n-1 + + --------------------------- + Starting benchmarks for afw__h-29__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-29__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-29__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776093 +Submitted batch job 776094 +Submitted batch job 776095 +Submitted batch job 776096 +Submitted batch job 776097 +Submitted batch job 776098 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-29__n-1/afw__h-29__n-1.beval + Done afw__h-29__n-1 + + --------------------------- + Starting benchmarks for afw__h-30__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_afw__h-30__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/afw__h-30__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776099 +Submitted batch job 776100 +Submitted batch job 776101 +Submitted batch job 776102 +Submitted batch job 776103 +Submitted batch job 776104 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/afw__h-30__n-1/afw__h-30__n-1.beval + Done afw__h-30__n-1 + + --------------------------- + Starting benchmarks for telingo__h-24__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-24__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-24__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776105 +Submitted batch job 776106 +Submitted batch job 776107 +Submitted batch job 776108 +Submitted batch job 776109 +Submitted batch job 776110 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-24__n-1/telingo__h-24__n-1.beval + Done telingo__h-24__n-1 + + --------------------------- + Starting benchmarks for telingo__h-25__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-25__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-25__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776111 +Submitted batch job 776112 +Submitted batch job 776113 +Submitted batch job 776114 +Submitted batch job 776115 +Submitted batch job 776116 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-25__n-1/telingo__h-25__n-1.beval + Done telingo__h-25__n-1 + + --------------------------- + Starting benchmarks for telingo__h-26__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-26__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-26__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776117 +Submitted batch job 776118 +Submitted batch job 776119 +Submitted batch job 776120 +Submitted batch job 776121 +Submitted batch job 776122 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-26__n-1/telingo__h-26__n-1.beval + Done telingo__h-26__n-1 + + --------------------------- + Starting benchmarks for telingo__h-27__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-27__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-27__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776123 +Submitted batch job 776124 +Submitted batch job 776125 +Submitted batch job 776126 +Submitted batch job 776127 +Submitted batch job 776128 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-27__n-1/telingo__h-27__n-1.beval + Done telingo__h-27__n-1 + + --------------------------- + Starting benchmarks for telingo__h-28__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-28__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-28__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776129 +Submitted batch job 776130 +Submitted batch job 776131 +Submitted batch job 776132 +Submitted batch job 776133 +Submitted batch job 776134 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-28__n-1/telingo__h-28__n-1.beval + Done telingo__h-28__n-1 + + --------------------------- + Starting benchmarks for telingo__h-29__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-29__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-29__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776135 +Submitted batch job 776136 +Submitted batch job 776137 +Submitted batch job 776138 +Submitted batch job 776139 +Submitted batch job 776140 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-29__n-1/telingo__h-29__n-1.beval + Done telingo__h-29__n-1 + + --------------------------- + Starting benchmarks for telingo__h-30__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_telingo__h-30__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/telingo__h-30__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776141 +Submitted batch job 776142 +Submitted batch job 776143 +Submitted batch job 776144 +Submitted batch job 776145 +Submitted batch job 776146 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/telingo__h-30__n-1/telingo__h-30__n-1.beval + Done telingo__h-30__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-24__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-24__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-24__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776147 +Submitted batch job 776148 +Submitted batch job 776149 +Submitted batch job 776150 +Submitted batch job 776151 +Submitted batch job 776152 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-24__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp CONSTRAINT=d3 HORIZON=24 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 HORIZON=24  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.beval + Done dfa-mso__h-24__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-25__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-25__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-25__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776153 +Submitted batch job 776154 +Submitted batch job 776155 +Submitted batch job 776156 +Submitted batch job 776157 +Submitted batch job 776158 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-25__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp CONSTRAINT=d3 HORIZON=25 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001 HORIZON=25  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.beval + Done dfa-mso__h-25__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-26__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-26__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-26__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776159 +Submitted batch job 776160 +Submitted batch job 776161 +Submitted batch job 776162 +Submitted batch job 776163 +Submitted batch job 776164 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-26__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp CONSTRAINT=d3 HORIZON=26 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 HORIZON=26  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.beval + Done dfa-mso__h-26__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-27__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-27__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-27__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776165 +Submitted batch job 776166 +Submitted batch job 776167 +Submitted batch job 776168 +Submitted batch job 776169 +Submitted batch job 776170 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-27__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp CONSTRAINT=d3 HORIZON=27 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 HORIZON=27  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.beval + Done dfa-mso__h-27__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-28__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-28__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-28__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776171 +Submitted batch job 776172 +Submitted batch job 776173 +Submitted batch job 776174 +Submitted batch job 776175 +Submitted batch job 776176 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-28__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp CONSTRAINT=d3 HORIZON=28 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 HORIZON=28  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.beval + Done dfa-mso__h-28__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-29__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-29__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-29__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776177 +Submitted batch job 776178 +Submitted batch job 776179 +Submitted batch job 776180 +Submitted batch job 776181 +Submitted batch job 776182 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-29__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp CONSTRAINT=d3 HORIZON=29 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001 HORIZON=29  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.beval + Done dfa-mso__h-29__n-1 + + --------------------------- + Starting benchmarks for dfa-mso__h-30__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-mso__h-30__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-mso__h-30__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776183 +Submitted batch job 776184 +Submitted batch job 776185 +Submitted batch job 776186 +Submitted batch job 776187 +Submitted batch job 776188 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Found error inside output of runsolver +output/asprilo-abc/dfa-mso__h-30__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver +-q +( cd ../../../../../../../../../../../ ; cd ../../ ; make translate-run DOM=asprilo-abc APP=dfa-mso INSTANCE=benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp CONSTRAINT=d3 HORIZON=30 MODELS=1 RUN_FILES='-q ' FORCE_TRANSLATE=0) +Making translation since file is missing +make[1]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +Translating APP=dfa-mso DOM=asprilo-abc CONSTRAINT=d3INSTANCE=x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 HORIZON=30  +make[2]: Entering directory '/home/hahnmartinlu/temporal-automata/atlingo' +python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=./outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/dfa-mso_automata.lp --in-files='./dom/asprilo-abc/temporal_constraints/d3.lp dom/asprilo/asprilo-abstraction-encodings/asprilo-encodings/input.lp benchmarks/benchmark-tool/../instances/asprilo/abc/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp' +Error in mona: +BDD too large (>16777216 nodes) +Traceback (most recent call last): + File "./scripts/translater.py", line 49, in + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/ldlf.py", line 254, in dfa + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + File "/home/hahnmartinlu/temporal-automata/atlingo/pystructures/automata.py", line 252, in from_mona + raise TimeoutError(mona) +TimeoutError: BDD too large (>16777216 nodes) +makefile:209: recipe for target 'translate-dfa-mso' failed +make[2]: *** [translate-dfa-mso] Error 1 +make[2]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:98: recipe for target 'translate' failed +make[1]: *** [translate] Error 2 +make[1]: Leaving directory '/home/hahnmartinlu/temporal-automata/atlingo' +makefile:129: recipe for target 'translate-run' failed +make: *** [translate-run] Error 2 + + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.beval + Done dfa-mso__h-30__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-24__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-24__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-24__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776189 +Submitted batch job 776190 +Submitted batch job 776191 +Submitted batch job 776192 +Submitted batch job 776193 +Submitted batch job 776194 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-24__n-1/dfa-stm__h-24__n-1.beval + Done dfa-stm__h-24__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-25__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-25__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-25__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776195 +Submitted batch job 776196 +Submitted batch job 776197 +Submitted batch job 776198 +Submitted batch job 776199 +Submitted batch job 776200 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-25__n-1/dfa-stm__h-25__n-1.beval + Done dfa-stm__h-25__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-26__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-26__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-26__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776201 +Submitted batch job 776202 +Submitted batch job 776203 +Submitted batch job 776204 +Submitted batch job 776205 +Submitted batch job 776206 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-26__n-1/dfa-stm__h-26__n-1.beval + Done dfa-stm__h-26__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-27__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-27__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-27__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776207 +Submitted batch job 776208 +Submitted batch job 776209 +Submitted batch job 776210 +Submitted batch job 776211 +Submitted batch job 776212 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-27__n-1/dfa-stm__h-27__n-1.beval + Done dfa-stm__h-27__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-28__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-28__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-28__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776213 +Submitted batch job 776214 +Submitted batch job 776215 +Submitted batch job 776216 +Submitted batch job 776217 +Submitted batch job 776218 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-28__n-1/dfa-stm__h-28__n-1.beval + Done dfa-stm__h-28__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-29__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-29__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-29__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776219 +Submitted batch job 776220 +Submitted batch job 776221 +Submitted batch job 776222 +Submitted batch job 776223 +Submitted batch job 776224 + Waiting for all slurm process to finish... + Slurm queue is now empty  + TIMEOUT: ./output/asprilo-abc/dfa-stm__h-29__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-29__n-1/dfa-stm__h-29__n-1.beval + Done dfa-stm__h-29__n-1 + + --------------------------- + Starting benchmarks for dfa-stm__h-30__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_dfa-stm__h-30__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/dfa-stm__h-30__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776225 +Submitted batch job 776226 +Submitted batch job 776227 +Submitted batch job 776228 +Submitted batch job 776229 +Submitted batch job 776230 + Waiting for all slurm process to finish... + Slurm queue is now empty  + TIMEOUT: ./output/asprilo-abc/dfa-stm__h-30__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1/runsolver.solver + TIMEOUT: ./output/asprilo-abc/dfa-stm__h-30__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1/runsolver.solver + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/dfa-stm__h-30__n-1/dfa-stm__h-30__n-1.beval + Done dfa-stm__h-30__n-1 + + --------------------------- + Starting benchmarks for nc__h-24__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-24__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-24__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776231 +Submitted batch job 776232 +Submitted batch job 776233 +Submitted batch job 776234 +Submitted batch job 776235 +Submitted batch job 776236 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-24__n-1/nc__h-24__n-1.beval + Done nc__h-24__n-1 + + --------------------------- + Starting benchmarks for nc__h-25__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-25__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-25__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776237 +Submitted batch job 776238 +Submitted batch job 776239 +Submitted batch job 776240 +Submitted batch job 776241 +Submitted batch job 776242 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-25__n-1/nc__h-25__n-1.beval + Done nc__h-25__n-1 + + --------------------------- + Starting benchmarks for nc__h-26__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-26__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-26__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776243 +Submitted batch job 776244 +Submitted batch job 776245 +Submitted batch job 776246 +Submitted batch job 776247 +Submitted batch job 776248 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-26__n-1/nc__h-26__n-1.beval + Done nc__h-26__n-1 + + --------------------------- + Starting benchmarks for nc__h-27__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-27__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-27__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776249 +Submitted batch job 776250 +Submitted batch job 776251 +Submitted batch job 776252 +Submitted batch job 776253 +Submitted batch job 776254 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-27__n-1/nc__h-27__n-1.beval + Done nc__h-27__n-1 + + --------------------------- + Starting benchmarks for nc__h-28__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-28__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-28__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776255 +Submitted batch job 776256 +Submitted batch job 776257 +Submitted batch job 776258 +Submitted batch job 776259 +Submitted batch job 776260 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-28__n-1/nc__h-28__n-1.beval + Done nc__h-28__n-1 + + --------------------------- + Starting benchmarks for nc__h-29__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-29__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-29__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776261 +Submitted batch job 776262 +Submitted batch job 776263 +Submitted batch job 776264 +Submitted batch job 776265 +Submitted batch job 776266 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-29__n-1/nc__h-29__n-1.beval + Done nc__h-29__n-1 + + --------------------------- + Starting benchmarks for nc__h-30__n-1 + --------------------------- + Creating runscript in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/runscripts/runscript_asprilo-abc_nc__h-30__n-1.xml  + Removing old result directory  + Moving to benchmarks-tool directory + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool  + Calling ./bgen + Running sh start file + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/benchmark-tool/output/asprilo-abc/nc__h-30__n-1/temporal-automata/komputer/start.sh  +Submitted batch job 776267 +Submitted batch job 776268 +Submitted batch job 776269 +Submitted batch job 776270 +Submitted batch job 776271 +Submitted batch job 776272 + Waiting for all slurm process to finish... + Slurm queue is now empty  + beval... + Evaluation results saved in + /home/hahnmartinlu/temporal-automata/atlingo/benchmarks/results/asprilo-abc/nc__h-30__n-1/nc__h-30__n-1.beval + Done nc__h-30__n-1 +No automata file for ../outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001 +No automata file for ../outputs/asprilo-abc/dfa-mso/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 +No automata file for ../outputs/asprilo-abc/nc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 +No automata file for ../outputs/asprilo-abc/nc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001 +No automata file for ../outputs/asprilo-abc/nc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 +No automata file for ../outputs/asprilo-abc/nc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001 +No automata file for ../outputs/asprilo-abc/nc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001 +No automata file for ../outputs/asprilo-abc/nc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001 +Saved results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv +Saved results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex +Saved results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv +Saved results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex +Saved results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv +Saved results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex +Saved results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv +Saved results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex +Saved results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv +Saved results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex +Saved results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv +Saved results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex +-------------------- +Summary +-------------------- +Successful: + all-afw__h-13__n-0 + all-dfa-mso__h-13__n-0 + all-dfa-mso__h-12__n-0 + all-dfa-stm__h-14__n-0 + all-telingo__h-13__n-0 + all-dfa-stm__h-12__n-0 + all-telingo__h-14__n-0 + all-telingo__h-12__n-0 + all-nc__h-12__n-0 + all-afw__h-14__n-0 + all-nc__h-13__n-0 + all-dfa-mso__h-14__n-0 + all-dfa-stm__h-13__n-0 + all-nc__h-14__n-0 + all-afw__h-12__n-0 +Error: + dfa-mso__h-28__n-1 + dfa-mso__h-24__n-1 + dfa-mso__h-25__n-1 + dfa-mso__h-30__n-1 + dfa-mso__h-26__n-1 + dfa-mso__h-29__n-1 + dfa-mso__h-27__n-1 diff --git a/benchmarks/plot.py b/benchmarks/plot.py new file mode 100644 index 0000000..eaf1faa --- /dev/null +++ b/benchmarks/plot.py @@ -0,0 +1,388 @@ +#!/usr/bin/env python +# libraries and data +import os +import math +import sys +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +import itertools +import seaborn as sns +from pandas_ods_reader import read_ods +import scipy +from scipy import stats +import re +import tikzplotlib + +import argparse + +# ------ Clean ods +def clean_df(df): + + all_stats = set(df.iloc[0][:]) + all_stats.remove('') + all_stats=list(all_stats) + n_all_stats = len(all_stats) + #Drop min max median + df.drop(df.columns[-3*n_all_stats:], axis=1, inplace=True) + + #Rename columns + all_constraints = df.columns[1:] + all_constraints = [c.split("/")[-1] for i,c in enumerate(all_constraints) if i%n_all_stats==0] + all_stats = df.iloc[0][1:n_all_stats+1] + + new_cols = ["{}--{}".format(c,p) for c,p in list(itertools.product(all_constraints, all_stats))] + new_cols = ["instance-name"] + new_cols + df.drop(df.index[0], inplace=True) #Remove unused out values + df.drop(df.tail(9).index,inplace=True) #Remove last computed values + df.columns = new_cols + if args.constraint is None: + constraints = all_constraints + else: + constraints = args.constraint + + required_colums = ["instance-name"] + [f"{c}--{s}" for c in constraints for s in stats] + + df = df.loc[:,df.columns.intersection(required_colums)] + # Convert all to floats + for i in range(1,len(df.columns)): + df.iloc[:,i] = pd.to_numeric(df.iloc[:,i], downcast="float") + + + ###### Handle rows (INSTANCES) + + #Choose selected instances + all_instances = df['instance-name'] + if single_instance: + instances_to_drop = [i for i,c in enumerate(all_instances) if c.find(instance)==-1 ] + df.drop(df.index[instances_to_drop], inplace=True) + else: + instances_to_drop = [i for i,c in enumerate(all_instances) if any([ c.find(i)==0 for i in ignore_prefix])] + df.drop(df.index[instances_to_drop], inplace=True) + instances_to_drop = [i for i,c in enumerate(all_instances) if any([ c.find(i)!=-1 for i in ignore_any])] + df.drop(df.index[instances_to_drop], inplace=True) + + #Rename + def rename(i): + return i.split("/")[1].split("_")[3] + # def rename(i): + # return i.split("/")[1].split("_")[0] + # def rename(i): + # return i[:-3] + df['instance-name']=df['instance-name'].apply(rename) + + # print(df) + return df + + +# ------- Aux for tex output +def csv2textable(df,cons,ins,approaches,use_gmean,spetial_words,base_headers = [""],use_lambda=True,models=0,caption=None,limitter='stats'): + n_base_headers = len(base_headers) + non_mc_approaches = [x for x in approaches if x!='nc'] + used_words = {} + formats={ + 'stats':'textbf', + 'ins':'texttt', + 'cons':'texttt' + } + def f_tex(x): + if isinstance(x, np.floating): + if np.isnan(x): + return "\\color{red}{-}" + return str(f'{int(x):,}') + if x in spetial_words: + to_ret ="" + word_type = spetial_words[x] + if word_type in used_words: + if used_words[word_type]!=x: + to_ret= f'\\{formats[word_type]}'+'{' +x+ '}' + if word_type==limitter: + to_ret = '\\hline' + to_ret + else: + to_ret= f'\\{formats[word_type]}'+'{' +x+ '}' + if word_type==limitter: + to_ret = '\\hline' + to_ret + used_words[word_type]=x + + return to_ret + if type(x) is str and x[-1]== '~': + return '\\sout{'+x[:-1]+'}' + if type(x) is str and x[-1]== '*': + val = str(f'{int(x[:-1]):,}') + return "\\textbf{"+val+"}" + if type(x) is int: + return str(f'{x:,}') + if x == "NaN": + return "\\color{red}{-}" + return str(f'{int(x):,}') + + cons_name = "\\texttt{"+cons.replace('_',' ')+"}" + ins_name = "\\texttt{"+ins.replace('_',' ')+"}" + app_names = df.columns[n_base_headers:] if use_gmean else df.columns[n_base_headers+1:] + if use_lambda: + approaches_map = { + "afw":"\\WFA", + "dfa-mso":"\\WFMm", + "dfa-stm":"\\WFMs", + "telingo":"\\WFT", + "nc":"\\WFNC" + } + headers = base_headers+["$\\lambda$"] + ["$"+approaches_map[str(c)]+"$" for c in app_names] + else: + headers = base_headers+["","H"] + ["\\textbf{"+str(c)+"}" for c in app_names] + + if use_gmean: + headers=headers[0:n_base_headers]+headers[n_base_headers+1:] + + models_str = f"getting {'one model' if models==1 else 'all_models'}" + column_format = f'|{"l"*n_base_headers}{"" if use_gmean else "l"}|{"r"*len(non_mc_approaches)}{"|r" if "nc" in approaches else ""}|' + if caption is None: + caption = f"Statistics for constraint {cons_name} and instance {ins_name} {models_str}. Crossed out lambdas are those for which the instance was UNSAT with the constraint. Best performance excluding NC (No Constraint) is found in bold." + tex_table = df.to_latex( + index=False, + caption=caption, + formatters=[f_tex]*len(df.columns), + escape=False, + header=headers, + label=f"tbl:eval:{cons}:{ins}", + column_format=column_format, + na_rep="\\color{red}{-}") + return tex_table + +if __name__ == "__main__": + + parser = argparse.ArgumentParser(description='Plot obs files from benchmark tool',formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("--stat", type=str, action='append', + help="Status: choices,conflicts,cons,csolve,ctime,error,mem,memout,models,ngadded,optimal,restarts,status,time,timeout,vars,ptime" ) + parser.add_argument("--approach", type=str, action='append', + help="Approach to be plotted awf, asp, nc or dfa. Can pass multiple",required=True) + parser.add_argument("--dom",type=str, default='asprilo', + help="Name of domain" ) + parser.add_argument("--constraint", type=str, action='append', + help="Contraint to be plotted, if non is passed all constraints will be plotted. Can pass multiple") + parser.add_argument("--horizon", type=int, action='append', + help="Horizon to be plotted. Can pass multiple",required=True) + parser.add_argument("--models", type=int, default=1, + help="Number of models computed in the benchmark with clingo -n" ) + parser.add_argument("--prefix", type=str, default="", + help="Prefix for output files" ) + parser.add_argument("--csv", default=False, action='store_true', + help="When this flag is passed, the table is also saved in csv format") + parser.add_argument("--plotmodels", default=False, action='store_true', + help="When this flag is passed, the number of models in plotted") + parser.add_argument("--use-lambda", default=False, action='store_true', + help="When this flag is passed, horizons are transform to lambda with +1") + parser.add_argument("--use-gmean", default=False, action='store_true', + help="When this flag is passed, computes gmean of all horizons") + parser.add_argument("--type", type=str, default="bar", + help="Bar or table" ) + parser.add_argument("--instance", type=str, default=None, + help="The name of a single instance" ) + parser.add_argument("--ignore_prefix",type=str, action='append', + help="Prefix to ignore in the instances" ) + parser.add_argument("--ignore_any",type=str, action='append', + help="Any to ignore in the instances" ) + parser.add_argument("--y", type=str, default=None, + help="Name for the y axis" ) + parser.add_argument("--x", type=str, default="Horizon", + help="Name for the x axis" ) + args = parser.parse_args() + + #PARAMS + # handle_timeout = not args.ignore_timeout + # zero_timeout = args.zero_timeout + + # Env + dom = args.dom + + # Approaches + approaches = args.approach + n_approaches = len(args.approach) + approaches.sort() + if "nc" in approaches: + approaches.remove("nc") + approaches.append("nc") + + # Horizon + horizons = args.horizon + horizons.sort() + h2idx = {h:i for i,h in enumerate(horizons)} + use_lambda = args.use_lambda + use_gmean = args.use_gmean + + models = args.models + + # Statistics + stats = args.stat + ["status"] + constraints = args.constraint + + prefix = args.prefix + # plot_n_models = args.plotmodels + + # Instances + single_instance = False + if args.instance: + single_instance = True + instance = args.instance + else: + ignore_prefix = [] if args.ignore_prefix is None else args.ignore_prefix + ignore_any = [] if args.ignore_any is None else args.ignore_any + + summary = f""" + PLOT + DOM: {dom} + APPROACHES: {approaches} + HORIZONS : {horizons} + STATS: {stats} + CONSTRAINTS: {"ALL" if constraints is None else constraints} + """ + + if single_instance: + summary +=f" ONLY INSTANCE: {instance}\n" + else: + summary +=f" IGNORE INSTANCE: {ignore_any} {ignore_prefix}\n" + + print(summary) + + + # -------- Read DFS + dfs = {} + last_df = None + for a in approaches: + for h in horizons: + path = f"results/{dom}/{a}__h-{h}__n-{models}/{a}__h-{h}__n-{models}.ods" + try: + print(f"Reading path {path}") + df = read_ods(path,1) + df = clean_df(df) + dfs.setdefault(a,{})[h]=df + + last_df = df + except e: + print("Error reading file {}".format(path)) + + sys.exit(1) + + + # -------- Reorder dfs + + fin_colums = last_df.columns + constraints = list(set([s.split('--')[0] for s in fin_colums[1:]])) + constraints.sort() + stats = list(set([s.split('--')[1] for s in fin_colums[1:]])) + stats.sort() + instances = last_df['instance-name'] + dfs_per_cons = {} + for cons in constraints: + for instance in instances: + rows = [] + for s in stats: + + for h in horizons: + if use_lambda: + row = [s,h+1] + else: + row = [s,h] + for a in approaches: + current_df = dfs[a][h] + current_row = current_df.loc[df['instance-name'] == instance] + current_col = f'{cons}--{s}' + row.append(current_row[current_col].item()) + + rows.append(row) + df_row = pd.DataFrame(rows, columns=["Stat","Horizon"]+approaches) + + #Edit horizon if unsat + df_stat = df_row.loc[df_row['Stat'] == 'status'] + unsat_horizons = df_stat[df_stat[df_stat.columns[2]]==0]['Horizon'].tolist() + df_row['Horizon'] = np.where(df_row['Horizon'].isin(unsat_horizons),df_row['Horizon'].astype(str)+"~",df_row['Horizon']) + + df_row = df_row[df_row['Stat'] != "status"] + + #times to milli seconds + is_time = df_row["Stat"].str.contains('time', regex=False) + df_row.loc[is_time,approaches]=df_row.loc[is_time,approaches]*1000 + + dfs_per_cons.setdefault(cons,{})[instance]= df_row + + + if args.type == "table": + # -------- Save CVS + for cons, v in dfs_per_cons.items(): + for ins, df in v.items(): + file_name_csv = f'plots/tables/{dom}/{prefix}-{cons}-{ins}.csv' + file_name_tex_csv = file_name_csv[:-3]+"tex" + dir_name = os.path.dirname(file_name_csv) + if not os.path.exists(dir_name): os.makedirs(dir_name) + + # Compute gmean + if use_gmean: + mx_gmeans = [] + for s in [y for y in stats if y!='status']: + df_s = df[df['Stat']==s] + gmeans = [] + for app in approaches: + arr_app = df_s[app].to_numpy() + arr_app = [arr_app[~np.isnan(arr_app)]] + gmean = list(scipy.stats.gmean(arr_app,axis=1)) + if len(gmean)==0: + gmean= [np.NaN] + gmeans.append(gmean[0]) + row_list=[s]+gmeans + mx_gmeans.append(row_list) + df = pd.DataFrame(mx_gmeans, columns=["Stat"]+approaches) + + # Add mark to minimum value + non_mc_approaches = [x for x in approaches if x!='nc'] + mins = df[non_mc_approaches].min(axis=1) + min_mx=df[non_mc_approaches].astype(float).eq(mins,axis=0) + for c in min_mx.columns: + for row in df.index: + str_value = "NaN" if math.isnan(df.loc[row,c]) else str(int(df.loc[row,c])) + # str_value = "\\color{red}{-}" if math.isnan(df.loc[row,c]) else str(f'{int(df.loc[row,c]):,}') + df.loc[row,c]= str_value+"*" if min_mx.loc[row,c] else str_value + if args.csv: + df.to_csv(file_name_csv,float_format='%.0f',index=False) + + tex_table = csv2textable(df,cons,ins,approaches,use_gmean,spetial_words={s:'stats' for s in stats},use_lambda=use_lambda,models=models) + + f = open(file_name_tex_csv, "w") + f.write(tex_table) + f.close() + print("Saved {}".format(file_name_csv)) + print("Saved {}".format(file_name_tex_csv)) + + elif args.type == "bar": + approaches_colors = { + "nc":"#C8F69B", + "afw":"#FFB1AF", + "dfa-mso":"#D6D4FF", + "dfa-stm":"#B3EEFF", + "nfa":"#FFCBA5", + "nfa-afw":"#FFE2A5", + "telingo":"#FFEEA5" + } + colors = [approaches_colors[a] for a in approaches] + # -------- Plot + for cons, v in dfs_per_cons.items(): + for ins, df in v.items(): + file_name_img = f'plots/img/{dom}/{prefix}-{cons}-{ins}.png' + dir_name = os.path.dirname(file_name_img) + if not os.path.exists(dir_name): os.makedirs(dir_name) + plotting_stats = [s for s in stats if s !="status"] + for i, s in enumerate(plotting_stats): + stats_row = df.loc[df['Stat'] == s] + stats_row.plot(x="Horizon", y=approaches, kind="bar", color=colors) + # stats_row.plot(x="Horizon", y=approaches, kind="bar", colormap="Set3") + + plt.title(f"{cons} ({ins})", fontsize=12, fontweight=0) + plt.xlabel(args.x) + plt.xticks(rotation='horizontal') + plt.ylabel(args.y) + plt.ylim(bottom=0) + + + plt.savefig(file_name_img,dpi=300,bbox_inches='tight') + print("Saved {}".format(file_name_img)) + plt.clf() + \ No newline at end of file diff --git a/benchmarks/plot_script_asprilo-abc.sh b/benchmarks/plot_script_asprilo-abc.sh new file mode 100755 index 0000000..c3f1c5d --- /dev/null +++ b/benchmarks/plot_script_asprilo-abc.sh @@ -0,0 +1,36 @@ +HORIZON_R2='--horizon 24 --horizon 25 --horizon 26 --horizon 27 --horizon 28' +# HORIZON_R2='--horizon 26 --horizon 27 --horizon 28 --horizon 29 --horizon 30' +HORIZON_R3='--horizon 26 --horizon 27 --horizon 28 --horizon 29 --horizon 30' +HORIZON_ALL='--horizon 24 --horizon 25 --horizon 26 --horizon 27 --horizon 28 --horizon 29 --horizon 30' +CLINGO_APP='--approach telingo --approach afw' +AUTOMATA_APP='--approach telingo --approach afw --approach dfa-stm --approach dfa-mso' +ALL_APP='--approach nc '${AUTOMATA_APP} +BASE='--x #horizon --dom asprilo-abc ' +R2='--instance _r2_' +R3='--instance _r3_' + +############ Full tables with horizon windows +python plot.py ${BASE} ${ALL_APP} ${R2} ${HORIZON_ALL} --type table --stat cons --stat ptime --stat ctime --stat choices --stat conflicts --stat rules --prefix="one-" --models 1 --use-lambda +python plot.py ${BASE} ${ALL_APP} ${R3} ${HORIZON_ALL} --type table --stat cons --stat ptime --stat ctime --stat choices --stat conflicts --stat rules --prefix="one-" --models 1 --use-lambda + +############ Ptime table +python plot.py ${BASE} ${ALL_APP} ${HORIZON_ALL} --type table --stat ptime --prefix="ptime-" --models 1 --use-lambda + +############ Tables with mean to join +python plot.py ${BASE} ${ALL_APP} ${R2} ${HORIZON_ALL} --type table --stat cons --stat ctime --stat choices --stat conflicts --stat rules --prefix="for-join" --models 1 --use-lambda --use-gmean --csv +python plot.py ${BASE} ${ALL_APP} ${R3} ${HORIZON_ALL} --type table --stat cons --stat ctime --stat choices --stat conflicts --stat rules --prefix="for-join" --models 1 --use-lambda --use-gmean --csv +python plot.py ${BASE} ${ALL_APP} ${R3} ${HORIZON_ALL} --type table --stat cons --stat ctime --stat choices --stat conflicts --stat rules --prefix="for-join" --models 1 --use-lambda --use-gmean --csv +############ Join means +python join_csv.py --dom=asprilo-abc --constraint=d1 --constraint=d2 --constraint=d3 --instance=r2 --instance=r3 --prefix-in="for-join" --prefix="all" + + + + + +for f in $(find ./plots/tables -type f -name "*.tex"); +do +sed -i '' 's/\\midrule//g' $f +sed -i '' 's/\\bottomrule/\\hline/g' $f +sed -i '' 's/\\toprule/\\hline/g' $f +sed -i '' 's/,/\\,/g' $f +done \ No newline at end of file diff --git a/benchmarks/plot_script_elevator.sh b/benchmarks/plot_script_elevator.sh new file mode 100755 index 0000000..b86b572 --- /dev/null +++ b/benchmarks/plot_script_elevator.sh @@ -0,0 +1,35 @@ +HORIZON_F5='--horizon 8 --horizon 9 --horizon 10 --horizon 11 --horizon 12' +HORIZON_F7='--horizon 11 --horizon 12 --horizon 13 --horizon 14 --horizon 15' +HORIZON_F9='--horizon 14 --horizon 15 --horizon 16 --horizon 17 --horizon 18' +HORIZON_F11='--horizon 17 --horizon 18 --horizon 19 --horizon 20 --horizon 21' + +AUTOMATA_APP='--approach nfa --approach telingo --approach afw --approach dfa-stm --approach dfa-mso' +ALL_APP='--approach nc '${AUTOMATA_APP} +BASE='--models 0 --x #horizon --dom elevator ' +F5='--instance 5_' +F7='--instance 7_' +F9='--instance 9_' +F11='--instance 11_' +############ Models (Just for test) +python plot.py ${BASE} ${ALL_APP} ${F5} ${HORIZON_F5} --type bar --stat models --prefix="models-" --y 'models' + +############ Processing Time +python plot.py ${BASE} ${ALL_APP} ${F5} --horizon 8 --type bar --stat ptime --prefix="ptime-" --y 'Processing time (sec)' + +############ Clingo Times +python plot.py ${BASE} ${ALL_APP} ${F5} ${HORIZON_F5} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' +python plot.py ${BASE} ${AUTOMATA_APP} ${F7} ${HORIZON_F7} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' +python plot.py ${BASE} ${AUTOMATA_APP} ${F9} ${HORIZON_F9} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' +python plot.py ${BASE} ${AUTOMATA_APP} ${F11} ${HORIZON_F11} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' + +############ Choices +python plot.py ${BASE} ${AUTOMATA_APP} ${F5} ${HORIZON_F5} --type bar --stat choices --prefix="choices-" --y '#choices' +python plot.py ${BASE} ${AUTOMATA_APP} ${F7} ${HORIZON_F7} --type bar --stat choices --prefix="choices-" --y '#choices' + +############ Constraints +python plot.py ${BASE} ${AUTOMATA_APP} ${F5} ${HORIZON_F5} --type bar --stat cons --prefix="cons-" --y '#cons' +python plot.py ${BASE} ${AUTOMATA_APP} ${F7} ${HORIZON_F7} --type bar --stat cons --prefix="cons-" --y '#cons' + +############ Rules +python plot.py ${BASE} ${AUTOMATA_APP} ${F5} ${HORIZON_F5} --type bar --stat rules --prefix="rules-" --y '#rules' +python plot.py ${BASE} ${AUTOMATA_APP} ${F7} ${HORIZON_F7} --type bar --stat rules --prefix="rules-" --y '#rules' \ No newline at end of file diff --git a/benchmarks/plot_script_hanoi.sh b/benchmarks/plot_script_hanoi.sh new file mode 100755 index 0000000..be96c23 --- /dev/null +++ b/benchmarks/plot_script_hanoi.sh @@ -0,0 +1,39 @@ +HORIZON_D4='--horizon 14 --horizon 15 --horizon 16 --horizon 17 --horizon 18' +HORIZON_D5='--horizon 30 --horizon 31 --horizon 32 --horizon 33 --horizon 34' +HORIZON_D6='--horizon 62 --horizon 63 --horizon 64 --horizon 65 --horizon 66' + +AUTOMATA_APP='--approach nfa --approach nfa-afw --approach afw --approach dfa-stm --approach dfa-mso' +ALL_APP='--approach nc '${AUTOMATA_APP} +BASE='--models 0 --x #horizon --dom hanoi ' +D4='--instance 4_' +D5='--instance 5_' +D6='--instance 6_' +############ Models (Just for test) +# python plot.py ${BASE} ${AUTOMATA_APP} ${D4} ${HORIZON_D4} --type bar --stat models --prefix="models-" --y 'models' +# python plot.py ${BASE} ${AUTOMATA_APP} ${D5} ${HORIZON_D5} --type bar --stat models --prefix="models-" --y 'models' +python plot.py ${BASE} ${AUTOMATA_APP} ${D6} ${HORIZON_D6} --type bar --stat models --prefix="models-" --y 'models' + +# # ############ Processing Time +# python plot.py ${BASE} ${ALL_APP} ${D4} ${HORIZON_D4} --type bar --stat ptime --prefix="ptime-" --y 'Processing time (sec)' +# python plot.py ${BASE} ${ALL_APP} ${D5} ${HORIZON_D5} --type bar --stat ptime --prefix="ptime-" --y 'Processing time (sec)' +python plot.py ${BASE} ${ALL_APP} ${D6} ${HORIZON_D6} --type bar --stat ptime --prefix="ptime-" --y 'Processing time (sec)' + +# # ############ Clingo Times +# python plot.py ${BASE} ${ALL_APP} ${D4} ${HORIZON_D4} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' +# python plot.py ${BASE} ${ALL_APP} ${D5} ${HORIZON_D5} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' +python plot.py ${BASE} ${ALL_APP} ${D6} ${HORIZON_D6} --type bar --stat ctime --prefix="time-" --y 'Clingo time (sec)' + +# # ############ Choices +# python plot.py ${BASE} ${AUTOMATA_APP} ${D4} ${HORIZON_D4} --type bar --stat choices --prefix="choices-" --y '#choices' +# python plot.py ${BASE} ${AUTOMATA_APP} ${D5} ${HORIZON_D5} --type bar --stat choices --prefix="choices-" --y '#choices' +python plot.py ${BASE} ${AUTOMATA_APP} ${D6} ${HORIZON_D6} --type bar --stat choices --prefix="choices-" --y '#choices' + +# # ############ Constraints +# python plot.py ${BASE} ${AUTOMATA_APP} ${D4} ${HORIZON_D4} --type bar --stat cons --prefix="cons-" --y '#cons' +# python plot.py ${BASE} ${AUTOMATA_APP} ${D5} ${HORIZON_D5} --type bar --stat cons --prefix="cons-" --y '#cons' +python plot.py ${BASE} ${AUTOMATA_APP} ${D6} ${HORIZON_D6} --type bar --stat cons --prefix="cons-" --y '#cons' + +# # ############ Rules +# python plot.py ${BASE} ${AUTOMATA_APP} ${D4} ${HORIZON_D4} --type bar --stat rules --prefix="rules-" --y '#rules' +# python plot.py ${BASE} ${AUTOMATA_APP} ${D5} ${HORIZON_D5} --type bar --stat rules --prefix="rules-" --y '#rules' +python plot.py ${BASE} ${AUTOMATA_APP} ${D6} ${HORIZON_D6} --type bar --stat rules --prefix="rules-" --y '#rules' \ No newline at end of file diff --git a/benchmarks/print_summary.sh b/benchmarks/print_summary.sh new file mode 100755 index 0000000..5bac6af --- /dev/null +++ b/benchmarks/print_summary.sh @@ -0,0 +1,23 @@ +DOM=$1 + +echo "--------------------" > results/$DOM/summary.txt +echo "Summary">> results/$DOM/summary.txt +echo "--------------------">> results/$DOM/summary.txt + +echo "Successful:">> results/$DOM/summary.txt +for f in $(find ./results/$DOM/ -type f -name "*.ods"); +do + echo " $(basename $f .ods)">> results/$DOM/summary.txt +done +echo "Error:">> results/$DOM/summary.txt +for f in $(find ./results/$DOM/ -type f -name "*.error"); +do + if [ -s "$f" ];then + echo " $(basename $f .error)">> results/$DOM/summary.txt + fi +done + +cat results/$DOM/summary.txt + +# send an email to report that the experiments are done +cat results/$DOM/summary.txt | mail -s "[Benchmark Finished]" hahnmartinlu@uni-potsdam.de diff --git a/benchmarks/programs/clingo.py b/benchmarks/programs/clingo.py new file mode 100644 index 0000000..bb01545 --- /dev/null +++ b/benchmarks/programs/clingo.py @@ -0,0 +1,108 @@ +''' +Created on Jan 17, 2010 +@author: Roland Kaminski +modified by: Javier +''' + +import os +import re +import sys +import codecs + +clingo_re = { + "models" : ("float", re.compile(r"^(c )?Models[ ]*:[ ]*(?P[0-9]+)\+?[ ]*$")), + "optimal" : ("float", re.compile(r"^(c )?[ ]*Optimal[ ]*:[ ]*(?P[0-9]+)\+?[ ]*$")), + "choices" : ("float", re.compile(r"^(c )?Choices[ ]*:[ ]*(?P[0-9]+)\+?[ ]*")), + "time" : ("float", re.compile(r"^Real time \(s\): (?P[0-9]+(\.[0-9]+)?)$")), + "conflicts" : ("float", re.compile(r"^(c )?Conflicts[ ]*:[ ]*(?P[0-9]+)\+?[ ]*")), + "ctime" : ("float", re.compile(r"^(c )?Time[ ]*:[ ]*(?P[0-9]+(\.[0-9]+)?)")), + "csolve" : ("float", re.compile(r"^(c )?Time[ ]*:[ ]*[0-9]+(\.[0-9]+)?s[ ]*\(Solving:[ ]*(?P[0-9]+(\.[0-9]+)?)")), + "domain" : ("float", re.compile(r"^(c )?Choices[ ]*:[ ]*[0-9]+[ ]*\(Domain:[ ]*(?P[0-9]+)")), + "rules" : ("float", re.compile(r"^(c )?Rules[ ]*:[ ]*(?P[0-9]+)")), + "roriginal" : ("float", re.compile(r"^(c )?Rules[ ]*:[ ]*[0-9]+(\.[0-9]+)?[ ]*\(Original:[ ]*(?P[0-9]+(\.[0-9]+)?)")), + "rchoices" : ("float", re.compile(r"^(c )? Choice [ ]*:[ ]*(?P[0-9]+)")), + "atoms" : ("float", re.compile(r"^(c )?Atoms[ ]*:[ ]*(?P[0-9]+)")), + "bodies" : ("float", re.compile(r"^(c )?Bodies[ ]*:[ ]*(?P[0-9]+)")), + "equiv" : ("float", re.compile(r"^(c )?Equivalences[ ]*:[ ]*(?P[0-9]+)")), + "vars" : ("float", re.compile(r"^(c )?Variables[ ]*:[ ]*(?P[0-9]+)")), + "cons" : ("float", re.compile(r"^(c )?Constraints[ ]*:[ ]*(?P[0-9]+)")), + "restarts" : ("float", re.compile(r"^(c )?Restarts[ ]*:[ ]*(?P[0-9]+)\+?[ ]*")), + "optimum" : ("string", re.compile(r"^(c )?Optimization[ ]*:[ ]*(?P(-?[0-9]+)( -?[0-9]+)*)[ ]*$")), + "status" : ("string", re.compile(r"^(s )?(?PSATISFIABLE|UNSATISFIABLE|UNKNOWN|OPTIMUM FOUND)[ ]*$")), + "interrupted" : ("string", re.compile(r"(c )?(?PINTERRUPTED)")), + "error" : ("string", re.compile(r"^\*\*\* ERROR: (?P.*)$")), + "memerror" : ("string", re.compile(r"^Maximum VSize (?Pexceeded): sending SIGTERM then SIGKILL")), + "memerror2" : ("string", re.compile(r"^\*\*\* ERROR: \((?P.*)\): std::bad_alloc")), + "mem" : ("float", re.compile(r"^Max\. virtual memory \(cumulated for all children\) \(KiB\): (?P[0-9]+)")), + "ground0" : ("float", re.compile(r"^(c )?First Ground[ ]*:[ ]*(?P[0-9]+(\.[0-9]+)?)")), + "groundN" : ("float", re.compile(r"^(c )?Next Ground[ ]*:[ ]*(?P[0-9]+(\.[0-9]+)?)")), + "max_length" : ("float", re.compile(r"^(c )?Max\. Length[ ]*:[ ]*(?P[0-9]+)\+?[ ]*")), + "sol_length" : ("float", re.compile(r"^(c )?Sol\. Length[ ]*:[ ]*(?P[0-9]+)\+?[ ]*")), + "calls" : ("float", re.compile(r"^(c )?Calls[ ]*:[ ]*(?P[0-9]+)\+?[ ]*$")), + "ngadded" : ("float", re.compile(r"total nogoods added:[ ]*(?P[0-9]+)\+?[ ]*$")), +} + +status_mapping = {"SATISFIABLE": 1, "UNSATISFIABLE": 0, "UNKNOWN": 2, "OPTIMUM FOUND": 3} + + +def clingo(root, runspec, instance): + """ + Extracts some clingo statistics. + """ + + timeout = runspec.project.job.timeout + res = { "time": ("float", timeout) } + for f in ["runsolver.solver", "runsolver.watcher", "benchmark.txt"]: + if f == "benchmark.txt": + if "choices" in res or not os.path.isfile(os.path.join(root, f)): + break + res["status"] = ("string", "UNKNOWN") + for line in codecs.open(os.path.join(root, f), errors='ignore', encoding='utf-8'): + for val, reg in clingo_re.items(): + m = reg[1].search(line) + if m: + res[val] = (reg[0], float(m.group("val")) if reg[0] == "float" else m.group("val")) + if "memerror" in res or "memerror2" in res: + res["error"] = ("string", "std::bad_alloc") + res["status"] = ("string", "UNKNOWN") + res.pop("memerror", None) + res.pop("memerror2", None) + if "status" in res and res["status"][1] == "OPTIMUM FOUND" and not "optimal" in res: + res["optimal"] = ("float", float("1")) + result = [] + error = (not "status" in res and not "interrupted" in res) or ("error" in res and res["error"][1] != "std::bad_alloc") + memout = "error" in res and res["error"][1] == "std::bad_alloc" + status = res["status"][1] if "status" in res else None + if "models" in res and not "optimal" in res: + res["optimal"] = ("float", float("0")) + timedout = memout or error or status == "UNKNOWN" or (status == "SATISFIABLE" and "optimum" in res) or res["time"][1] >= timeout or "interrupted" in res; + if timedout: res["time"] = ("float", timeout) + if memout: + sys.stderr.write("*** MEMOUT: Run {0} did a memout!\n".format(root)) + elif error: + sys.stderr.write("*** ERROR: Run {0} failed with unrecognized status or error!\n".format(root)) + result.append(("error", "float", int(error))) + result.append(("timeout", "float", int(timedout))) + result.append(("memout", "float", int(memout))) + + if "optimum" in res and not " " in res["optimum"][1]: + result.append(("optimum", "float", float(res["optimum"][1]))) + del res["optimum"] + if "interrupted" in res: del res["interrupted"] + if "error" in res: del res["error"] + + if "status" in res: + status_val = res["status"][1] + res["status"] = ("float", status_mapping[status_val]) + else: + res["status"] = ("float", status_mapping["UNKNOWN"]) + + if "ngadded" not in res: + res["ngadded"] = ("float", 0.0) + + for key, val in res.items(): result.append((key, val[0], val[1])) + + if "ctime" in res: + result.append(("ptime","float",res["time"][1]-res["ctime"][1])) + + return result diff --git a/benchmarks/programs/general_compute-1 b/benchmarks/programs/general_compute-1 new file mode 100755 index 0000000..878c1d8 --- /dev/null +++ b/benchmarks/programs/general_compute-1 @@ -0,0 +1,28 @@ +#!/bin/bash + + +ROOT="$1""/" +INSTANCE=$2 +APP=$3 +DOM=$4 +HORIZON=$5 +MODELS=$6 +CONSTRAINT=$7 +CLINGO_ARGS=$8 +# FORCE_TRANSLATE=$(9) +: ${CLINGO_ARGS:=''} + +PATH_FROM_ATLINGO_TO_ROOT="benchmarks/benchmark-tool/" +PATH_FROM_ROOT_TO_ATLINGO="../../" + + +INSTANCE=${INSTANCE#"$ROOT"} +INSTANCE=${INSTANCE#"$PATH_FROM_ROOT_TO_ATLINGO"} +INSTANCE=${PATH_FROM_ATLINGO_TO_ROOT}${INSTANCE} +CONSTRAINT_NAME=$(basename "$CONSTRAINT") +ARGS="-q "$CLINGO_ARGS +echo $ARGS +echo "( cd $ROOT ; cd $PATH_FROM_ROOT_TO_ATLINGO ; make translate-run DOM=$DOM APP=$APP INSTANCE=$INSTANCE CONSTRAINT=$CONSTRAINT_NAME HORIZON=$HORIZON MODELS=$MODELS RUN_FILES=' --stats $ARGS ' FORCE_TRANSLATE=0)" +( cd $ROOT ; cd $PATH_FROM_ROOT_TO_ATLINGO ; make translate-run DOM=$DOM APP=$APP INSTANCE=$INSTANCE CONSTRAINT=$CONSTRAINT_NAME HORIZON=$HORIZON MODELS=$MODELS RUN_FILES="$ARGS " FORCE_TRANSLATE=0) + + diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/Changelog b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Changelog new file mode 100644 index 0000000..15f5d86 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Changelog @@ -0,0 +1,162 @@ +version 3.4.0 2017-08-12 + +- use (and require) prctl(PR_SET_CHILD_SUBREAPER,...) (available since Linux 3.4) +- fixed incorrect parsing of SwapFree/SwapTotal + +version 3.3.7 2016- + +- introduction of a new memory limit (-R, --rss-swap-limit) to cope with programs that map a lot of virtual memory but actually use only a portion of it (such as Java). This limit is set on the sum of RSS (Resident Set Size, or in other words, amount of RAM used) and swap. + +- renaming of (-M, --mem-limit) as (-V, --vsize-limit). (-M, --mem-limit) becomes deprecated because its name is ambiguous. It will be removed in a future release. + +version 3.3.6 2016- + +- introduction of the --sig option to select which signal to send to the solver + +- introduction of the --bin-var option to ease the transmission of + the statistics to a calling program + +- introduction of a separate Watcher class, in charge of watching the processes + +- added a --watchdog option, in order to kill runsolver after a given delay (for debugging) + +- fixed a bug which caused runsolver to kill itself sometimes just after the solver end + +version 3.3.5 2015-02-03 + +- fixed problem with concurrent access to process tree, which caused some + random crashes + +- removed the interception of system calls, which is unused, too costly and + complicates compilation. + +version 3.3.4 2013-11-28 + +- fix compilation problems on Ubuntu and get rid of compilation warnings + +version 3.3.3 2013-07-19 + +- fixed a bug which occurs on very short executions of the solver + (such as `echo test`). In such a case, runsolver did not have the time to + get the correct process group id (i.e. the watcher read /proc + before the child could run setpgid()) and in the end runsolver + signalled its own process group and killed itself. Besides, the + default ProcessTree::currentRootPID was set to 1, which means that + we could kill our whole session (kill(-1,...)) + +- fixed 2 bugs in timestamping: the CPU time didn't take into + account the lostCPUtime and the EOF line didn't appear on its own + line when the solver didn't print an EOL at the end. + +version 3.3.2 2013-04-19 + +- add option -v to save the most relevant information (times, ...) + in a separate file which is easy to parse (VAR=VALUE format) + +- display option --core in the help message and clarified the core + numbering scheme used by this option + +- new option --phys-core to select cores by their physical id + +- new option --add-eof: + + when timestamps are used, request to add an 'EOF' line at the + end of the solver output + +version 3.3.1 2011-06-12 + +- make sure to kill processes which are stopped and in their own + session + +version 3.3.0 2011-05-01 + +- support for core information and selection +- fixed a bug in case of input redirection (runsolver cmd < file) +- use long instead of int for memory limits + +version 3.2.9a 2010-03-09 + +- release under the GPL + +version 3.2.9 2009-03-27 + +- when the main process terminates, kill each children that could remain + +version 3.2.8 2009-03-27 + +- fixed a bug in the --output-limit start,max option + + when the output size was between start and max, "start" bytes of + garbage was appended to the ouput. + +- --output-limit now implies --timestamp + +version 3.2.7 2009-03-26 + +- added the --cleanup-ipc-queues option + +version 3.2.6 2009-03-24 + +- added support for identification of heavy processes run by another user + +version 3.2.5 2007-05-20 + +- the stack size command line argument was incorrectly understood as a +limit in GiB instead of a limit in MiB. + +version 3.2.4 2007-05-9 + +- add a test to indicate if the solver has dumped a core (when +supported by the system) + +version 3.2.3 2007-04-16 + +- lostCPUTime must be taken into account when deciding when the solver +times out + +- added tests to check that fgets() correctly reads the /proc/pid/stat +and statm files in ProcessData::read(). It is hoped this will fix some +incoherent data read such as: + +[startup+402.301 s] +/proc/loadavg: 1.00 0.99 0.91 2/78 12763 +/proc/meminfo: memFree=1564840/2055920 swapFree=4169436/4192956 +[pid=12688] ppid=12686 vsize=19880 CPUtime=402.13 +/proc/12688/stat : 12688 (cmusat) R 12686 12688 12410 0 -1 4194304 44325 0 0 0 40175 38 0 0 25 0 1 0 323084685 20357120 4250 18446744073709551615 134512640 135508737 4294956704 18446744073709551615 135092575 0 0 4096 35 0 0 0 17 1 0 0 +/proc/12688/statm: 4970 4251 119 243 0 4724 0 +Current children cumulated CPU time (s) 402.13 +Current children cumulated vsize (KiB) 19880 + +Solver just ended. Dumping a history of the last processes samples + +[startup+402.503 s] +/proc/loadavg: 1.00 0.99 0.91 1/77 12763 +/proc/meminfo: memFree=1679792/2055920 swapFree=4169436/4192956 +[pid=12688] ppid=-1 vsize=0 CPUtime=0 +/proc/12688/stat : 7 (events/1) S 1 0 0 0 -1 33088 0 0 0 0 0 5 0 0 5 -10 1 0 27 0 0 18446744073709551615 0 0 0 0 0 0 2147483647 65536 0 18446744073709551615 0 0 17 1 0 0 +/proc/12688/statm: 0 0 0 0 0 0 0 +Current children cumulated CPU time (s) 0 +Current children cumulated vsize (KiB) 0 + +Notice that in the last sample, we fetch information about process +12688 but actually get information about pid 7 (and ppid is set to +-1). The most likely explanation is that the fopen("/proc/pid/stat") +succeeds but the following fgets fails because the file has +disappeared. + + +version 3.2.2 2007-04-13 + +- added code to detect when the time of a child is not reported to its +parent. When this occurs, the 'lost time' is recorded and added at the +end. + +- minors changes in the messages that are printed when the time of a +child is not reported to its parent. + +version 3.2.1 2007-02-27 + +- added option --wall-clock-limit to deal with frozen solvers + +- minor changes in the timer thread + diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/CircularBufferFilter.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/CircularBufferFilter.hh new file mode 100644 index 0000000..eed9812 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/CircularBufferFilter.hh @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + + + +#ifndef _CircularBufferFilter_hh_ +#define _CircularBufferFilter_hh_ + +#include +#include + +using namespace std; + + +class AbstractFilter +{ +public: + virtual void write(const char *buffer, int len)=0; + + /** + * handle partial writes and EINTR + */ + void systemWrite(int fd, const char *buf, size_t len) + { + const char *p=buf; + int n; + + do + { + n=::write(fd,p,len); + if(n<0) + { + if(errno==EINTR) + continue; + + perror("write failed: "); + break; + } + + len-=n; + p+=n; + } + while(len); + } +}; + +class NullFilter : public AbstractFilter +{ +private: + int fd; +public: + NullFilter(int fd): fd(fd) {} + + virtual void write(const char *buffer, int len) + { + systemWrite(fd,buffer,len); + } +}; + +/** + * This filter enforces a limit on an output file size. When the file + * exceeds the limit, only the first and last bytes of output are + * saved in the file. + * + * This filter transmits directly to file descriptor fd the first + * activateSize bytes and then it only transmits the last + * maxSize-activateSize bytes. + * + * TODO ??? + * + * - we currently use a circular buffer in memory to do the job. We + may instead work directly on the file, using lseek to rewind to + position activateSize as soon as the file size exceeds + maxSize. At the end, we have to reorder the bytes at the end of + the file. This may save memory but requires to be able to lseek + on the file. + * + * - the last part of the file to which we output doesn't necessarily + start at the beginning of a line. This may cause problem in some + applications. + */ +class CircularBufferFilter : public AbstractFilter +{ +private: + unsigned long long int total; // total number of bytes sent to this filter + unsigned long long int activateSize,maxSize,bufferSize; + + char *data; // circular buffer + unsigned int w; // position where to write in the circular buffer + + int fd; // file descriptor to write to + +public: + CircularBufferFilter() + { + data=NULL; + } + + CircularBufferFilter(int fd, + unsigned long long int activateSize, + unsigned long long int maxSize) + { + data=NULL; + setup(fd,activateSize,maxSize); + } + + void setup(int fd, + unsigned long long int activateSize, + unsigned long long int maxSize) + { + this->fd=fd; + this->activateSize=activateSize; + this->maxSize=maxSize; + bufferSize=maxSize-activateSize; + total=0; + } + + ~CircularBufferFilter() + { + flush(); + } + + virtual void write(const char *buffer, int len) + { + total+=len; + + if (totalbufferSize-w) + n=bufferSize-w; + + memcpy(data+w,buffer+r,n); + len-=n; + r+=n; + w+=n; + if (w>=bufferSize) + w=0; + } while(len>0); + } + } + + /** + * normally, this should only be called by the destructor. + * + * remember that the destructor is not called if we are an auto + * object (local variable) and if we call exit() + */ + void flush() + { + if (!data) + return; + + char msg[512]; + + if (total<=maxSize) + systemWrite(fd,data,total-activateSize); + else + { + snprintf(msg,sizeof(msg), + "\n" + "###########################################################\n" + "# A total of %llu bytes were output by the program.\n" + "# This exceeds the hard limit that is enforced.\n" + "# Only the %llu first bytes are saved in this file before\n" + "# this point and only the %llu last bytes are saved after\n" + "# this point. A total of %llu bytes are lost.\n" + "###########################################################\n", + total,activateSize,bufferSize,total-maxSize); + systemWrite(fd,msg,strlen(msg)); + systemWrite(fd,data+w,bufferSize-w); + systemWrite(fd,data,w); + } + } +}; + +// Local Variables: +// mode: C++ +// End: +#endif diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/Cores.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Cores.hh new file mode 100644 index 0000000..6cb934d --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Cores.hh @@ -0,0 +1,203 @@ +#ifndef _Cores_hh_ +#define _Cores_hh_ + +#include +#include + +using namespace std; + +/** + * get the list of cores available on the system + * + * if physicalView is true, "list" will contain the id of existing + * cores in increasing order (from 0 to n-1). + * + * if physicalView is false, "list" will contain the id of existing + * cores ordered by the processor to which they belong. For example, + * list could contain 0,2,4,6,1,3,5,7 if the first processor contains + * cores 0,2,4,6 and the second processor contains cores 1,3,5,7. + */ +void getExistingCores(vector &list, bool physicalView) +{ + char fname[128]; + string buffer; + ifstream f; + cpu_set_t cores; + + CPU_ZERO(&cores); + + list.clear(); + + for(unsigned int cpu=0;cpu0) + --len; + + int id=0,mask; + for(int i=len;i>=0;--i,id+=4) + if(buffer[i]!='0' && buffer[i]!=',') + { + if(buffer[i]>='0' && buffer[i]<='9') + mask=buffer[i]-'0'; + else + if(buffer[i]>='a' && buffer[i]<='f') + mask=10+buffer[i]-'a'; + else + if(buffer[i]>='A' && buffer[i]<='F') + mask=10+buffer[i]-'A'; + else + throw runtime_error("invalid character in cpu mask"); + + for(int j=0;j<4;++j) + { + if((mask & 1) && !CPU_ISSET(id+j,&cores)) + { + list.push_back(id+j); + CPU_SET(id+j,&cores); // don't count it twice! + } + + mask>>=1; + } + } + } // if(CPU_ISET(...)) +} + + + +/** + * return the list of cores allocated to this process, ordered by + * physical cpu + */ +void getAllocatedCoresByProcessorOrder(vector &allocatedCores) +{ + char fname[128]; + string buffer; + ifstream f; + cpu_set_t affinityMask; + + allocatedCores.clear(); + + sched_getaffinity(0,sizeof(cpu_set_t),&affinityMask); + + for(unsigned int cpu=0;cpu0) + --len; + + int id=0,mask; + for(int i=len;i>=0;--i,id+=4) + if(buffer[i]!='0' && buffer[i]!=',') + { + if(buffer[i]>='0' && buffer[i]<='9') + mask=buffer[i]-'0'; + else + if(buffer[i]>='a' && buffer[i]<='f') + mask=10+buffer[i]-'a'; + else + if(buffer[i]>='A' && buffer[i]<='F') + mask=10+buffer[i]-'A'; + else + throw runtime_error("invalid character in cpu mask"); + + for(int j=0;j<4;++j) + { + if((mask & 1) && CPU_ISSET(id+j,&affinityMask)) + { + allocatedCores.push_back(id+j); + CPU_CLR(id+j,&affinityMask); // don't count it twice! + } + + mask>>=1; + } + } + } // if(CPU_ISET(...)) +} + +/** + * get the list of cores allocated to this process + */ +void getAllocatedCores(vector &list, pid_t pid=0) +{ + cpu_set_t mask; + list.clear(); + + sched_getaffinity(pid,sizeof(cpu_set_t),&mask); + + for(unsigned int i=0;i &list) +{ + size_t end; + + for(size_t beg=0;beg &cores) +{ + cpu_set_t mask; + + CPU_ZERO(&mask); + for(size_t i=0;i. + */ + + + +#ifndef _ExecutionSummary_hh_ +#define _ExecutionSummary_hh_ + +struct ExecutionSummary +{ + int byteOrder; // used to detect byte ordering if needed (=0x01020304) + int version; // version number of this format + char runsolverVersion[16]; // version of runsolver + float wcTime; // wall-clock time in seconds + float cpuTime; // CPU time in seconds (userTime+systemTime) + float userTime; // user CPU time in seconds + float systemTime; // system CPU time in seconds + float cpuUsage; // cpuTime/wcTime (in percent) + long maxVM; // maximum virtual memory used in KiB + long maxMem; // maximum memory used in KiB + bool timeOut; // did the solver exceed the time limit? + bool memOut; // did the solver exceed the memory limit? + + + ExecutionSummary() + { + set(); + } + + void set() + { + version=3; + byteOrder=0x01020304; + } + + void reset() + { + byteOrder=0; + } + + bool ok() const + { + return byteOrder==0x01020304 && version==3; + } +}; + +#endif diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/LICENSE-GPL-3.0.txt b/benchmarks/programs/runsolver-3.4.0/runsolver/src/LICENSE-GPL-3.0.txt new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/LICENSE-GPL-3.0.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/Makefile b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Makefile new file mode 100644 index 0000000..6797fb4 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Makefile @@ -0,0 +1,69 @@ +VERSION=3.4.0 +#SVNVERSION=`svnversion .` +SVNVERSION=$(word 2,$$Rev: 3018 $$) +DEBUG=-g +#DEBUG=-O3 -g + +STATIC= +#STATIC=-static + +WSIZE:=$(shell if [ `uname -m` = 'x86_64' ] ; then echo 64; else echo 32; fi ) + +CFLAGS=-std=c++11 -DWITH_NUMA -Dtmpdebug -Wall -DVERSION=\"$(VERSION)\" -DSVNVERSION=\"$(SVNVERSION)\" -DWSIZE=$(WSIZE) +LDFLAGS= $(STATIC) -Wl,--build-id +LIBS=-lnuma + +ifneq ($(findstring alineos.net,$(HOSTNAME)),) +# if needed, path to the dynamic library we use +LDFLAGS+=-Wl,-rpath,$(HOME)/tools-centos7/lib64 +endif + +SRC=runsolver.cc SignalNames.cc +OBJ=$(SRC:.cc=.o) + +all:runsolver + +install: runsolver + cp runsolver $(INSTROOT)/usr/bin + +include $(SRC:.cc=.d) + +.cc.o: + g++ $(CFLAGS) $(DEBUG) -c $*.cc + +runsolver: $(OBJ) + g++ $(LDFLAGS) $(DEBUG) -o $@ $^ -pthread $(LIBS) + +testlimit: testlimit.cc + g++ -o testlimit testlimit.cc + +testthread: testthread.cc + g++ -o testthread testthread.cc -pthread + +.PHONY: clean realclean archive + +tar: /tmp/runsolver-$(VERSION).tar.bz2 +archive: /tmp/runsolver-$(VERSION).tar.bz2 + +/tmp/runsolver-$(VERSION).tar.bz2: realclean $(SRC) Makefile + sed -i -e 's/^Version:.*/Version:\t'$(VERSION)'/' runsolver.spec + tar cvjf /tmp/runsolver-$(VERSION).tar.bz2 -C ../.. runsolver/src --exclude .svn + +rpm: /tmp/runsolver-$(VERSION).tar.bz2 + rpmbuild -tb /tmp/runsolver-$(VERSION).tar.bz2 + +srpm: /tmp/runsolver-$(VERSION).tar.bz2 + rpmbuild -ts /tmp/runsolver-$(VERSION).tar.bz2 + +clean: + rm -f runsolver $(OBJ) *.class testlimit testtimestamper vlineSplitter testProcessTree runtestlimit testthread + +realclean: clean + rm -f *.d *~ + + +%.d: %.cc + $(SHELL) -ec '$(CC) -MM $(CFLAGS) $< \ + | sed -e '\''s/$*\.o[ :]*/$@ &/g'\'' > $@' + + diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/Observer.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Observer.hh new file mode 100644 index 0000000..b96f389 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Observer.hh @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + + + +#ifndef _Observer_hh_ +#define _Observer_hh_ + +/** + * a class to watch file descriptors and wait for data to become + * available on one of them + * + */ +class Observer +{ +private: + vector desc; + fd_set readable; +public: + /** + * add a file descriptor to watch + */ + void add(int fd) + { + desc.push_back(fd); + } + + /** + * remove a file descriptor from the list of file descriptors to watch + * + * doit être appele avant de fermer la socket + */ + void remove(int fd) + { + vector::iterator i=find(desc.begin(),desc.end(),fd); + if (i!=desc.end()) + desc.erase(i); + } + + /** + * tell if there is some file descriptor left to watch + */ + bool empty() + { + return desc.empty(); + } + + /** + * wait for data to become available on one of the file descriptor + * that is watched + * + * this is a blocking method + */ + void waitForData() + { + int max=0; + + FD_ZERO(&readable); + + for (int i=0;i. + */ + + + +#ifndef _ProcessData_hh_ +#define _ProcessData_hh_ + +#include +using namespace std; + +/** + * The information we keep on a process + */ +class ProcessData +{ +private: + bool valid; // did we collect meaningful data? + + static const unsigned long int clockTicksPerSecond; + + uid_t uid; + gid_t gid; + + pid_t pid,tid,ppid,pgrp; + unsigned long int utime,stime,cutime,cstime; + unsigned long int starttime; + unsigned long int vsize; + + unsigned long int rss,swap; // in kB, see /proc/[pid]/status + + vector children; + + char statLine[1024]; // ??? + char statmLine[1024]; // ??? + + vector allocatedCores; + + bool selected; // a flag to select/unselect processes + + inline void init() + { + valid=false; + pid=-1; + tid=-1; + ppid=-1; + utime=stime=cutime=cstime=0; + vsize=0; + } + +public: + ProcessData() {init();} + + ProcessData(pid_t pid, pid_t tid=0) + { + init(); + read(pid,tid); + } + + ProcessData(const ProcessData &pd) + { + valid=false; + + uid=pd.uid; + gid=pd.gid; + + pid=pd.pid; + tid=pd.tid; + ppid=pd.ppid; + pgrp=pd.pgrp; + utime=pd.utime; + stime=pd.stime; + cutime=pd.cutime; + cstime=pd.cstime; + starttime=pd.starttime; + vsize=pd.vsize; + + statLine[0]=0; + statmLine[0]=0; + + for(size_t i=0;ipid=pid; + this->tid=tid; + + valid=false; + + if (tid) + snprintf(fileName,sizeof(fileName),"/proc/%d/task/%d/stat",pid,tid); + else + snprintf(fileName,sizeof(fileName),"/proc/%d/stat",pid); + + if ((file=fopen(fileName,"r"))!=NULL) + { + struct stat info; + + fstat(fileno(file),&info); + + uid=info.st_uid; + gid=info.st_gid; + + if (fgets(statLine,sizeof(statLine),file)==NULL) + { +#ifdef debug + perror("failed to read stat file"); +#endif + + strcpy(statLine,"-- couldn't read stat file --"); + fclose(file); + + return valid=false; + } + + fclose(file); + } + else + { +#ifdef debug + perror("failed to open stat file"); +#endif + + strcpy(statLine,"-- couldn't open stat file --"); + + return valid=false; + } + + nbFields=sscanf(statLine, +#if WSIZE==32 + "%*d " + "%*s " + "%*c " + "%d %d %*d %*d %*d " + "%*u %*u %*u %*u %*u " // lu lu lu lu lu + "%Lu %Lu %Lu %Lu " /* utime stime cutime cstime */ + "%*d %*d " // ld ld + "%*d " + "%*d " // ld + "%Lu " /* start_time */ + "%lu ", +#else + "%*d " + "%*s " + "%*c " + "%d %d %*d %*d %*d " + "%*u %*u %*u %*u %*u " // lu lu lu lu lu + "%lu %lu %lu %lu " /* utime stime cutime cstime */ + "%*d %*d " // ld ld + "%*d " + "%*d " // ld + "%lu " /* start_time */ + "%lu ", +#endif + &ppid,&pgrp, + &utime, &stime, &cutime, &cstime, + &starttime, + &vsize + ); + + if(nbFields!=8) + { +#ifdef debug + cout << "FAILED TO READ EACH FIELD (got " << nbFields << " fields)\n"; +#endif + + return valid=false; + } + + if (!tid) + { + snprintf(fileName,sizeof(fileName),"/proc/%d/statm",pid); + + if ((file=fopen(fileName,"r"))!=NULL) + { + if (fgets(statmLine,sizeof(statmLine),file)==NULL) + { +#ifdef debug + perror("failed to read statm file"); +#endif + + strcpy(statmLine,"-- couldn't read statm file --"); + fclose(file); + + return valid=false; + } + + fclose(file); + } + else + { +#ifdef debug + perror("failed to open statm file"); +#endif + + strcpy(statmLine,"-- couldn't open statm file --"); + } + } + + if (!tid) + { + // read /proc/%d/status + snprintf(fileName,sizeof(fileName),"/proc/%d/status",pid); + ifstream in(fileName); + string tmp; + int nbFieldsToRead=2; + + while(in.good() && nbFieldsToRead>0) + { + in >> tmp; + if(tmp=="VmRSS:") + { + in >> rss; + --nbFieldsToRead; + } + else + if(tmp=="VmSwap:") + { + in >> swap; + --nbFieldsToRead; + } + getline(in,tmp); + } + + if(nbFieldsToRead!=0) + { +#ifdef debug + cout << "FAILED TO READ EACH FIELD in /proc/" << pid << "/status\n"; +#endif + + return valid=false; + } + } + + getAllocatedCores(); + + return valid=true; + } + + /** + * update data on this process + * + * return false iff the process doesn't exit any more + */ + bool update() + { + return read(pid,tid); + } + + /** + * do we have valid data? + */ + bool isValid() const {return valid;} + + /** + * return the % of CPU used by this process (and its children when + * withChildren is true). The result is between 0 and 1 + */ + float percentageCPU(float uptime, bool withChildren=false) const + { + float cputime=stime+utime; + + if (withChildren) + cputime+=cstime+cutime; + + cputime/=clockTicksPerSecond; + + float wctime=uptime-static_cast(starttime)/clockTicksPerSecond; + + if (wctime==0) + return 0; + else + return cputime/wctime; + } + + + bool isTask() const + { + return tid!=0; + } + + + const vector &getChildren() const + { + return children; + } + + void addChild(pid_t child) + { + children.push_back(child); + } + + int getNbChildren() const + { + return children.size(); + } + + pid_t getPIDChild(int i) const + { + return children[i]; + } + + pid_t getppid() const + { + return ppid; + } + + pid_t getProcessGroupId() const + { + return pgrp; + } + + uid_t getUid() const + { + return uid; + } + + void select() + { + selected=true; + } + + void unselect() + { + selected=false; + } + + bool isSelected() const + { + return selected; + } + + float getOverallCPUTime() const + { + // note that cstime and cutime (child system and user time) are + // only updated by the wait call in the parent (this is to say, + // only once the child has terminated). Therefore, we can't rely + // on these variables to limit the global cpu use of a process + // and its children + + return (stime+(float)utime + +cstime+(float)cutime + )/clockTicksPerSecond; + } + + float getOverallUserTime() const + { + // note that cstime and cutime (child system and user time) are + // only updated by the wait call in the parent (this is to say, + // only once the child has terminated). Therefore, we can't rely + // on these variables to limit the global cpu use of a process + // and its children + + return (utime+(float)cutime)/clockTicksPerSecond; + } + + float getOverallSystemTime() const + { + // note that cstime and cutime (child system and user time) are + // only updated by the wait call in the parent (this is to say, + // only once the child has terminated). Therefore, we can't rely + // on these variables to limit the global cpu use of a process + // and its children + + return (stime+(float)cstime)/clockTicksPerSecond; + } + + /** + * return the current vsize in kB + */ + long getVSize() const + { + return vsize/1024; + } + + /** + * return the current memory consumption in kB + */ + long getMemory() const + { + return rss+swap; + } + + /** + * get the list of cores allocated to this process + */ + void getAllocatedCores() + { + //return; // ??? + + cpu_set_t mask; + allocatedCores.clear(); + + sched_getaffinity(pid,sizeof(cpu_set_t),&mask); + +#warning "don't watse time converting to a vector, just keep the cpu_set_t" + for(int i=0;i. + */ + + + +#ifndef _ProcessHistory_hh_ +#define _ProcessHistory_hh_ + +#include +#include "ProcessTree.hh" + +using namespace std; + +/** + * maintains a history of process trees + */ +class ProcessHistory +{ +private: + int nbcell; + vector nbitem; + vector history; + +public: + ProcessHistory(int n) + { + nbcell=n; + nbitem.resize(nbcell); + history.resize(2*nbcell); + for(int i=0;i0;++cell) + for(int i=0;i0;++cell) + { + for(int i=0;i=0;--cell) + { + if (nbitem[cell]==0 || + history[2*cell]->getElapsedTime()<=elapsedLimit) + continue; + + history[2*cell]->dumpProcessTree(s); + history[2*cell]->dumpCPUTimeAndVSize(s); + } + + if (nbitem[0]==2) + { + // also dump the most recent + history[1]->dumpProcessTree(s); + history[1]->dumpCPUTimeAndVSize(s); + } + } + +protected: + void drop(ProcessTree *elem) + { + delete elem; + } +}; + +// Local Variables: +// mode: C++ +// End: +#endif diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/ProcessList.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/ProcessList.hh new file mode 100644 index 0000000..956c762 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/ProcessList.hh @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + + + +#ifndef _ProcessList_hh_ +#define _ProcessList_hh_ + +#include + +using namespace std; + +/** + * a class to store a list of process IDs + * + * ??? should be optimized !!! + */ +class ProcessList +{ +private: + set s; +public: + typedef set::iterator iterator; + + inline void add(pid_t pid) + { + s.insert(pid); + } + + inline void remove(pid_t pid) + { + s.erase(pid); + } + + inline bool contains(pid_t pid) const + { + return s.find(pid)!=s.end(); + } + + iterator begin() const {return s.begin();} + iterator end() const {return s.end();} +}; + + +#endif + +// Local Variables: +// mode: C++ +// End: + diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/ProcessTree.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/ProcessTree.hh new file mode 100644 index 0000000..ec6810c --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/ProcessTree.hh @@ -0,0 +1,703 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + + + +#ifndef _ProcessTree_hh_ +#define _ProcessTree_hh_ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "ProcessData.hh" + +using namespace std; + +class ProcessTree +{ +private: + typedef map ProcMap; + + ProcMap tree; + vector roots; // root processes of the solver + + string loadavgLine; + long memTotal,memFree,swapTotal,swapFree; // data from /proc/meminfo + + float elapsed; // number of seconds elapsed since the start of the program + + float uptime; // up time of the host (in seconds) + + float completedCPUTime=0; // CPU time of completed processes + + bool treeHasAllProcesses=false; + + pid_t runsolverPID=-1; +public: + ProcessTree() + { + } + + ProcessTree(const ProcessTree &pt): roots(pt.roots), completedCPUTime(pt.completedCPUTime), runsolverPID(pt.runsolverPID) + { + treeHasAllProcesses=pt.treeHasAllProcesses; + + elapsed=pt.elapsed; + memTotal=pt.memTotal; + memFree=pt.memFree; + swapTotal=pt.swapTotal; + swapFree=pt.swapFree; + loadavgLine=pt.loadavgLine; + + clone(pt); + } + + ~ProcessTree() + { + clear(); + } + + void clear() + { + for(ProcMap::iterator it=tree.begin();it!=tree.end();++it) + delete (*it).second; + + tree.clear(); + roots.clear(); + } + + void setRunsolverPID(pid_t pid) + { + runsolverPID=pid; + } + + + void setElapsedTime(float timeSinceStartOfProgram) + { + elapsed=timeSinceStartOfProgram; + } + + void setCompletedCPUTime(float cpuTime) + { + completedCPUTime=cpuTime; + } + + float getElapsedTime() const + { + return elapsed; + } + + /** + * return true when the main process has ended + */ + bool solverEnded() + { + return roots.empty(); + } + + /** + * gather informations on all processes (to determine all children + * of the watched process) + * + */ + void readProcesses() + { + DIR *procfs=opendir("/proc"); + struct dirent *dirEntry; + pid_t pid; + + //cout << "??? runsolverPID=" << runsolverPID << endl; + + clear(); + + readGlobalData(); + + if (!procfs) + throw runtime_error("unable to read /proc filesystem"); + + while((dirEntry=readdir(procfs))) + { + // we only care about process ID + if (!isdigit(*dirEntry->d_name)) + continue; + + //cout << "process " << dirEntry->d_name << endl; + + pid=atoi(dirEntry->d_name); + ProcessData *pd=new ProcessData(pid); + + if(pd->isValid()) + { + //cout << "pid=" << pid << " ppid=" << pd->getppid() << endl; + + tree[pid]=pd; + if(pd->getppid()==runsolverPID) + roots.push_back(pid); + } + else + delete pd; + } + + closedir(procfs); + + treeHasAllProcesses=true; + + identifyChildren(); + + for(pid_t root: roots) + readTasksRec(root); + } + + /** + * update informations on processes which are a child of runsolver. + * + * doesn't attempt to identify new children processes + */ + void updateProcessesData() + { + bool allRootsOK=true; + + for(pid_t root: roots) + allRootsOK=allRootsOK && updateProcessesDataRec(root); + + if(!allRootsOK) // lost some roots? + readProcesses(); // find the new roots + } + + /** + * + * list heavy processes running on the system. must be called right + * after readProcesses. We only consider processes which are run + * by another user. + * + * threshold is the percentage of CPU (between 0 and 1) above which + * a process is considered as heavy + */ + void dumpHeavyProcesses(ostream &s, float threshold) + { + uid_t myUid=getuid(); + + // we need all processes in the tree. Reread if necessary. + if (!treeHasAllProcesses) + readProcesses(); + + cout << "heavy processes:\n"; + + for(ProcMap::iterator it=tree.begin();it!=tree.end();++it) + { + ProcessData *data=(*it).second; + + if (!data || !data->isValid()) + { + cout << "Ooops ! No data available on process " << (*it).first << endl; + continue; + } + + float pcpu=data->percentageCPU(uptime); + + // is this someone else process which uses a significant + // proportion of the CPU? + if (data->getUid()!=myUid && pcpu>threshold) + { + pid_t pid=(*it).first; + + s << " %CPU=" << static_cast(pcpu*100) + << " pid=" << pid + << " uid=" << data->getUid() + << " cmd="; + + dumpCmdLine(s,pid); + + s << endl; + } + } + } + + float currentCPUTime() + { + float userTime=0,systemTime=0; + + for(pid_t root: roots) + currentCPUTimeRec(root,userTime,systemTime); + + return userTime+systemTime; + } + + void currentCPUTime(float &userTime, float &systemTime) + { + userTime=0; + systemTime=0; + for(pid_t root: roots) + currentCPUTimeRec(root,userTime,systemTime); + } + + long currentVSize() + { + long sum=0; + for(pid_t root: roots) + sum+=currentVSizeRec(root); + + return sum; + } + + long currentMemory() + { + long sum=0; + for(pid_t root: roots) + sum+=currentMemoryRec(root); + return sum; + } + + /** + * add the pid of each solver task to "list" + */ + void listProcesses(set &list) + { + for(pid_t root: roots) + listProcessesRec(list,root); + } + + void dumpProcessTree(ostream &out) + { + cout << "\n[startup+" << elapsed << " s]"; + if(treeHasAllProcesses) + cout << '*'; + cout << endl; + + //cout << "nbRoots=" << roots.size() << endl; // ??? + dumpGlobalData(out); + + for(pid_t root: roots) + dumpProcessTreeRec(out,root); + } + + void dumpCPUTimeAndVSize(ostream &out) + { + float userTime,systemTime; + long VSize,mem; + VSize=currentVSize(); + mem=currentMemory(); + currentCPUTime(userTime,systemTime); + dumpCPUTimeAndVSize(out,userTime+systemTime,VSize,mem); + } + + void dumpCPUTimeAndVSize(ostream &out, + float currentCPUTime, long currentVSize, long currentMemory) + { + if(completedCPUTime!=0) + out << "Current cumulated CPU time of completed processes: " + << completedCPUTime << " s\n"; + + out << "Current children cumulated CPU time: " + << currentCPUTime << " s\n"; + + out << "Current children cumulated vsize: " + << currentVSize << " KiB\n"; + + out << "Current children cumulated memory: " + << currentMemory << " KiB" << endl; + } + + /** + * send a signal to the whole process tree without delay + */ + void sendSignalNow(int sig) + { + for(pid_t root: roots) + sendSignalNowRec(root,sig); + } + + void sendSignalBottomUp(int sig) + { + for(pid_t root: roots) + sendSignalBottomUpRec(root,sig); + } + + void sendSignalBottomUp(pid_t pid, int sig) + { + sendSignalBottomUpRec(pid,sig); + } + +protected: + void readGlobalData() + { + ifstream in; + string key; + long value; + + in.open("/proc/loadavg"); + if(in.good()) + getline(in,loadavgLine); + in.close(); + + in.open("/proc/meminfo"); + int fieldsToRead=4; + while(fieldsToRead>0) + { + in >> key >> value; + if(in.fail()) + break; + + if(key=="MemTotal:") + { + memTotal=value; + --fieldsToRead; + } + else if(key=="MemFree:") + { + memFree=value; + --fieldsToRead; + } + else if(key=="SwapTotal:") + { + swapTotal=value; + --fieldsToRead; + } + else if(key=="SwapFree:") + { + swapFree=value; + --fieldsToRead; + } + + getline(in,key); + } + in.close(); + + in.open("/proc/uptime"); + if(in.good()) + in >> uptime; + in.close(); + } + + void identifyChildren() + { + // get links from fathers to children + for(ProcMap::iterator it=tree.begin();it!=tree.end();++it) + { + ProcessData *data=(*it).second; + + if (!data || !data->isValid()) + { + cout << "Ooops ! No data available on process " << (*it).first << endl; + continue; + } + + pid_t parent=data->getppid(); + + if (parent==-1) + continue; // we just have no data on this process + + ProcMap::iterator itParent=tree.find(parent); + if (itParent!=tree.end()) + (*itParent).second->addChild((*it).first); +#ifdef debug + else + if ((*it).first!=1) // init has no father + { + cout << "Ooops! Can't find parent pid " << parent + << " of child pid " << (*it).first << endl; + dumpProcessTree(cout); + } +#endif + } + } + + + /** + * returns false if the process does not exist + */ + bool updateProcessesDataRec(pid_t root) + { + ProcessData *data=tree[root]; + + if (!data) // no data on this process + return false; + + if (!data->update()) + { + // this process doesn't exist any more + tree.erase(root); + return false; + } + + for(pid_t childpid: data->getChildren()) + updateProcessesDataRec(childpid); + + return true; + } + + void dumpGlobalData(ostream &out) + { + out << "/proc/loadavg: " << loadavgLine << "\n"; + out << "/proc/meminfo: memFree=" << memFree << "/" << memTotal + << " swapFree=" << swapFree << "/" << swapTotal << endl; + } + + void currentCPUTimeRec(pid_t pid, float &userTime, float &systemTime) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) // no data on this process + return; + + userTime+=data->getOverallUserTime(); + systemTime+=data->getOverallSystemTime(); + + for(pid_t childpid: data->getChildren()) + if (tree[childpid] && !tree[childpid]->isTask()) + currentCPUTimeRec(childpid,userTime,systemTime); + } + + long currentVSizeRec(pid_t pid) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) // no data on this process + return 0; + + long size=data->getVSize(); + + for(pid_t childpid: data->getChildren()) + if (tree[childpid] && !tree[childpid]->isTask()) + size+=currentVSizeRec(childpid); + + return size; + } + + long currentMemoryRec(pid_t pid) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) // no data on this process + return 0; + + long mem=data->getMemory(); + + for(pid_t childpid: data->getChildren()) + if (tree[childpid] && !tree[childpid]->isTask()) + mem+=currentMemoryRec(childpid); + + return mem; + } + + void sendSignalNowRec(pid_t pid, int sig) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) // no data on this process + return; + + if (data->getNbChildren()!=0) + { + for(pid_t childpid: data->getChildren()) + if (tree[childpid] && !tree[childpid]->isTask()) + sendSignalNowRec(childpid,sig); + } + + cout << "??? kill " << pid << " sig " << sig << endl; + kill(pid,sig); + } + + void sendSignalBottomUpRec(pid_t pid, int sig) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) // no data on this process + return; + + if (data->getNbChildren()!=0) + { + for(pid_t childpid: data->getChildren()) + if (tree[childpid] && !tree[childpid]->isTask()) + sendSignalBottomUpRec(childpid,sig); + + // give some time to the father to wait for its children + struct timespec delay={0,020000000}; // 20 ms + + // use a loop in case of an interrupt + while(nanosleep(&delay,&delay)==-1 && errno==EINTR); + } + + kill(pid,sig); + } + + void readTasksRec(pid_t pid) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) // no data on this process + return; + + readProcessTasks(pid); + + for(pid_t childpid: data->getChildren()) + if (tree[childpid] && !tree[childpid]->isTask()) + readTasksRec(childpid); + } + + void readProcessTasks(pid_t pid) + { + char processdir[64]; // ??? + DIR *procfs; + struct dirent *dirEntry; + pid_t tid; + ProcessData *data; + + data=tree[pid]; + + if (!data || !data->isValid()) + return; + + snprintf(processdir,sizeof(processdir),"/proc/%d/task",pid); + + procfs=opendir(processdir); + if (!procfs) + { + if (errno==ENOENT) + { + // process "pid" is probably gone. Don't make a fuss about it + return; + } + + cout << "!!! unable to read " << processdir << " filesystem (" + << strerror(errno) << ") !!!" << endl; + return; + } + + while((dirEntry=readdir(procfs))) + { + // we only care about process ID + if (!isdigit(*dirEntry->d_name)) + continue; + + tid=atoi(dirEntry->d_name); + if (tid==pid) + continue; + + //cout << "task " << dirEntry->d_name + // << " (pid=" << pid << ")" << endl; + + ProcessData *pd=new ProcessData(pid,tid); + + if(pd->isValid()) + { + tree[tid]=pd; + + // add a link from the father to the task + data->addChild(tid); + } + else + delete pd; + } + + closedir(procfs); + } + + void listProcessesRec(set &list,pid_t pid) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) + return; + + list.insert(pid); + + for(pid_t childpid: data->getChildren()) + listProcessesRec(list,childpid); + } + + void dumpProcessTreeRec(ostream &out,pid_t pid) + { + ProcessData *data=tree[pid]; + + if (!data || !data->isValid()) + return; + + out << *data; + for(pid_t childpid: data->getChildren()) + dumpProcessTreeRec(out,childpid); + } + + void clone(const ProcessTree &pt) + { + treeHasAllProcesses=false; // we only copy the solver processes + + for(pid_t root: pt.roots) + cloneRec(pt,root); + } + + void cloneRec(const ProcessTree &pt, pid_t pid) + { + ProcMap::const_iterator it=pt.tree.find(pid); + if (it==pt.tree.end()) + return; + + ProcessData *data=(*it).second; + + if (!data || !data->isValid()) + return; + + tree[pid]=new ProcessData(*data); + + for(pid_t childpid: data->getChildren()) + cloneRec(pt,childpid); + } + + void dumpCmdLine(ostream &s, pid_t pid) + { + char buffer[128]; + char fileName[64]; // ??? + int fd; + + snprintf(fileName,sizeof(fileName),"/proc/%d/cmdline",pid); + + fd=open(fileName,O_RDONLY); + + if(fd>0) + { + unsigned int size=0,r; + + while(size0) + size+=r; + + for(unsigned int i=0;i. + */ + + +#include + +#include "SignalNames.hh" + +const char *signalNames[]={ + "???", + "SIGHUP", + "SIGINT", + "SIGQUIT", + "SIGILL", + "SIGTRAP", + "SIGABRT", + "SIGBUS", + "SIGFPE", + "SIGKILL", + "SIGUSR1", + "SIGSEGV", + "SIGUSR2", + "SIGPIPE", + "SIGALRM", + "SIGTERM", + "SIGSTKFLT", + "SIGCHLD", + "SIGCONT", + "SIGSTOP", + "SIGTSTP", + "SIGTTIN", + "SIGTTOU", + "SIGURG", + "SIGXCPU", + "SIGXFSZ", + "SIGVTALRM", + "SIGPROF", + "SIGWINCH", + "SIGIO", + "SIGPWR", + "SIGSYS"}; + + +const char *getSignalName(int sig) +{ + if (sig>0 && sig<=static_cast(sizeof(signalNames)/sizeof(char *))) + return signalNames[sig]; + else + return "???"; +} + +int getSignalNum(const char *name) +{ + std::string uc=name,ucsig; + + for(char &c: uc) + c=toupper(c); + + ucsig="SIG"+uc; + + int nbSig=sizeof(signalNames)/sizeof(char *); + + for(int i=0;i. + */ + + + +#ifndef _SignalNames_hh_ +#define _SignalNames_hh_ + +const char *getSignalName(int sig); + +#endif diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/SignalNames.o b/benchmarks/programs/runsolver-3.4.0/runsolver/src/SignalNames.o new file mode 100644 index 0000000..f964c05 Binary files /dev/null and b/benchmarks/programs/runsolver-3.4.0/runsolver/src/SignalNames.o differ diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/TimeStamper.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/TimeStamper.hh new file mode 100644 index 0000000..26bf903 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/TimeStamper.hh @@ -0,0 +1,444 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + + + +#ifndef _TimeStamper_hh_ +#define _TimeStamper_hh_ + +#include +#include +#include +#include +#include +#include +#include +#include + +// if we use the TimeStamper in a threaded program, we may have to use +// mutexes +#include + +#include "CircularBufferFilter.hh" + +using namespace std; + +/** + * a class that intercepts the data on some watched file descriptors + * and adds a timestamp at the beginning of each line. + */ +class TimeStamper +{ +public: + TimeStamper(bool withCPUtime=true) : withCPUtime(withCPUtime) + { + // initialize select() data + FD_ZERO(&watcher); + max=1; + + // in case the user forgets to call it + resetTimeStamp(); + + lastKnownCPUtime=0; + pthread_mutex_init(&cputimeMutex,NULL); + + addEOFLine=false; + + incompleteLineSent=false; + } + + /** + * specifies if a special 'EOF' line should be added at the end of + * output. This line allows to get the value of the timestamps when + * the process ends. + * + * @parm add: true iff the 'EOF' line must be added + */ + void addEOF(bool add) + { + addEOFLine=add; + } + + /** + * add a file descriptor (inputfd) to the list of timestamped files + * + * @parm inputfd: file descriptor of the file that must be timestamped + * @parm letter: one letter name of the timestamped stream (0 if unused) + * @parm outputfd: file descriptor to use to output the + * timestamped stream (stdout by default) + */ + void watch(int inputfd, char letter=0, int outputfd=STDOUT_FILENO) + { + FD_SET(inputfd,&watcher); + if(inputfd>=max) + max=inputfd+1; + + watched.push_back(info(inputfd,outputfd,letter,true)); + } + + /** + * add a file descriptor (inputfd) to the list of timestamped files + * + * @parm inputfd: file descriptor of the file that must be timestamped + * @parm letter: one letter name of the timestamped stream (0 if unused) + * @parm outputfilter: filter to use to output the timestamped stream + */ + void watch(int inputfd, AbstractFilter *outputfilter, char letter=0) + { + FD_SET(inputfd,&watcher); + if(inputfd>=max) + max=inputfd+1; + + watched.push_back(info(inputfd,outputfilter,letter,true)); + } + + /** + * reset the time stamp + */ + void resetTimeStamp() + { + gettimeofday(&tvStart,NULL); + } + + /** + * obtain the current time stamp + * + * @return the current timestamp (for external use) + */ + struct timeval getTimeStamp() + { + gettimeofday(&tv,NULL); + tv.tv_usec-=tvStart.tv_usec; + tv.tv_sec-=tvStart.tv_sec; + if(tv.tv_usec<0) + { + tv.tv_sec-=1; + tv.tv_usec+=1000000; + } + + return tv; + } + + /** + * loop that waits for data on one of the watched files + * and timestamps each line read from these files + * + * the loop ends when all watched files are closed + * + * should be called from a separate thread of process (in most cases) + */ + void timeStampLines() + { + fd_set tmp; + int result,watchDog=0; + + while (watched.size()) + { + tmp=watcher; + + // wait for data to become available on one of the watched files + result=select(max,&tmp,NULL,NULL,NULL); + + if(result<0) + { + cout << "timestamper::select: " << strerror(errno) << endl; // ??? + + if(++watchDog<10) + continue; + else + { + cout << "Error in TimeStamper::timeStampLines(), select() keeps returning errors, exiting." << endl; + break; + } + } + + watchDog=0; + + for(size_t i=0;i=max) + max=watched[i].inputdescr+1; + } + else + ++i; + } + } + + + if(addEOFLine) + { + const char *lastLine="EOF\n"; + + if(incompleteLineSent) + watched[0].write("\n",strlen("\n")); + + prepareTimeStamp(0); + watched[0].write(tstampbuffer,tstampsize); + watched[0].write(lastLine,strlen(lastLine)); + } + } + + /** + * communicate the current CPU time to the time stamper + * + * must only be called from another thread than the one running + * timeStampLines() !! + */ + void setCPUtimeFromAnotherThread(float cputime) + { + pthread_mutex_lock(&cputimeMutex); + lastKnownCPUtime=cputime; + pthread_mutex_unlock(&cputimeMutex); + } + + protected: + + /** + * get the current time and store the ascii representation of the + * time stamp in tstampbuffer (tstampsize will contain the number of + * characters of the representation) + * + * @parm name=one letter name of the watched file (0 if unused) + */ + void prepareTimeStamp(char name) + { + float cputimeCopy; + + getTimeStamp(); + pthread_mutex_lock(&cputimeMutex); + cputimeCopy=lastKnownCPUtime; + pthread_mutex_unlock(&cputimeMutex); + + // store time stamp in tstampbuffer + if(withCPUtime) + { + // CPU time+Wall Clock time + if(name) + tstampsize=snprintf(tstampbuffer,sizeof(tstampbuffer), +#if WSIZE==32 + "%c%.2f/%d.%02d\t", +#else + "%c%.2f/%ld.%02ld\t", +#endif + name,cputimeCopy,tv.tv_sec,tv.tv_usec/10000); + else + tstampsize=snprintf(tstampbuffer,sizeof(tstampbuffer), +#if WSIZE==32 + "%.2f/%d.%02d\t", +#else + "%.2f/%ld.%02ld\t", +#endif + cputimeCopy, + tv.tv_sec,tv.tv_usec/10000); + } + else + { + // no CPU time + if(name) + tstampsize=snprintf(tstampbuffer,sizeof(tstampbuffer), +#if WSIZE==32 + "%c%d.%02d\t", +#else + "%c%ld.%02ld\t", +#endif + name,tv.tv_sec,tv.tv_usec/10000); + else + tstampsize=snprintf(tstampbuffer,sizeof(tstampbuffer), +#if WSIZE==32 + "%d.%02d\t", +#else + "%ld.%02ld\t", +#endif + tv.tv_sec,tv.tv_usec/10000); + } + + } + + private: + /** + * read data available on watched file with index id (in the watched + * vector) and output the timestamp stream + * + * @return false on EOF + */ + bool readFrom(int id) + { + char buffer[1024]; + + int size=read(watched[id].inputdescr,buffer,sizeof(buffer)); + + // PTY seem to be special (this is a quick fix that must be cleaned ???) + if(size<0) + return false; // ??? + + if(size<0) + throw runtime_error(string("TimeStamper::readFrom(): read failed: ") + +strerror(errno)); + + if(size==0) + return false; // indicate EOF + + // create the time stamp once for all the lines we read + prepareTimeStamp(watched[id].name); + + if(watched[id].EOLBefore) + { + watched[id].write(tstampbuffer,tstampsize); + watched[id].EOLBefore=false; + } + + char *s=buffer; + char *eol; + + // split into lines + while (size>0 && (eol=(char*)memchr(s,'\n',size))!=NULL) + { + // output up to EOL included + watched[id].write(s,eol-s+1); + size-=eol-s+1; + s=eol+1; + + if(size>0) + watched[id].write(tstampbuffer,tstampsize); + else + watched[id].EOLBefore=true; + } + + // output the last incomplete line + if(size>0) + { + watched[id].write(s,size); + incompleteLineSent=true; + } + else + incompleteLineSent=false; + + return true; + } + +private: + bool withCPUtime; // do we display CPU time in the timestamp ? + + float lastKnownCPUtime; // current CPU time (provided by an external source) + pthread_mutex_t cputimeMutex; // a mutex to protect access to cputime + + struct timeval tvStart,tv; // first timestamp and current timestamp + + int max; // max(fd)+1 for select + fd_set watcher; // set of watched file descriptors for use by select + + // buffer that contains the ascii representation of the timestamp + char tstampbuffer[64]; // a buffer to output the time stamps + int tstampsize; // size of the timestamp + + bool incompleteLineSent; // true iff the last line we sent didn't have an EOL + + bool addEOFLine; // true if we must add an 'EOF' line at the end of output + + /** + * internal information kept on each file to be watched + */ + struct info + { + bool filteredOutput; + int inputdescr; // file descriptor to watch + int outputdescr; // file descriptor to use to output the timestamped stream (when filteredOutput is false) + AbstractFilter *outputfilter; // filter to write to (when filteredOutput is true) + char name; // a letter that identifies the watched file + bool EOLBefore; // true iff the first character we read is the start of + // a new line + + info(int inputfd, int outputfd, char letter, bool lineStart) + { + filteredOutput=false; + inputdescr=inputfd; + outputdescr=outputfd; + name=letter; + EOLBefore=lineStart; + } + + info(int inputfd, AbstractFilter *filter, char letter, bool lineStart) + { + filteredOutput=true; + inputdescr=inputfd; + outputfilter=filter; + name=letter; + EOLBefore=lineStart; + } + + void write(const char *buffer, int len) + { + if(filteredOutput) + outputfilter->write(buffer,len); + else + systemWrite(outputdescr,buffer,len); + } + + /** + * handle partial writes and EINTR + */ + void systemWrite(int fd, const char *buf, size_t len) + { + const char *p=buf; + int n; + + do + { + n=::write(fd,p,len); + if(n<0) + { + if(errno==EINTR) + continue; + + perror("write failed: "); + break; + } + + len-=n; + p+=n; + } + while(len); + } + }; + + vector watched; // list of files we watch +}; + +#endif diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/Watcher.hh b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Watcher.hh new file mode 100644 index 0000000..270dc58 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/Watcher.hh @@ -0,0 +1,809 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ +#ifndef _Watcher_hh_ +#define _Watcher_hh_ + +#include +#include + +#include "ProcessTree.hh" +#include "ProcessHistory.hh" +#include "TimeStamper.hh" + +using namespace std; + +class Watcher +{ +private: + bool hasChildReaper=false; // did we set prctl(PR_SET_CHILD_SUBREAPER)? + + thread watcherThread; + mutex cout_mutex; + + // when set, save the most relevant information in an easy to parse + // format consisting of VAR=VALUE lines + char *varOutputFilename; + + // when set, save the most relevant information in a binary format file + char *binVarOutputFilename; + + // when the solver uses less than cpuUsageThreshold % of the CPU, + // try to identify process of other users which use more than + // heavyProcessThreshold % of the CPU + static constexpr float cpuUsageThreshold=0.8; // % of CPU + static constexpr float heavyProcessThreshold=0.1; // % of CPU + + pid_t childpid=0; // pid of the process we're watching + bool solverIsRunning; + bool abortChild; // request to kill the child when runsolver is killed + + float limitCPUTime; // CPU time (in seconds) given to solver before we stop it + float limitWallClockTime; // Wall clock time (in seconds) given to solver before we stop it + long limitVSize; // VSize given to solver before we stop it + long limitMemory; // memory given to solver before we stop it + + + // used in timerThread + float maxDisplayPeriod; // max. period between two samplings + + struct timeval starttv,stoptv; + float elapsed; // elapsed time in seconds since the start of the + // watched process. Updated by timerThread + float lastDisplayedElapsedTime; // last elapsed time at which a + // process tree was displayed + + bool stopSolverRequested=false; + const char *stopReason=nullptr; // reason for stopping the solver + int stopSolverState=0; // steps during the solver stop + + ProcessTree *procTree,*lastProcTree; // to gather data about a process and its children + ProcessHistory procHistory; // history of the last procTree + + // list of all tasks created by the solver. Only updated when + // cleanupSolverOwnIPCQueues is set + set listAllProcesses; + + // time in seconds between a SIGTERM and a SIGKILL sent to children + int delayBeforeKill; + + // maximum cumulated vsize/memory of all children + long maxVSize,maxMemory; + + // current CPU time of the watched process + float currentCPUTime,currentSystemTime,currentUserTime; + + // the time of children whose termination was reported directly to + // runsolver (because their parent died and they were adopted by + // runsolver) + float completedCPUTime,completedUserTime,completedSystemTime; + // pid of the processes whose termination was reported to runsolver + vector completedChildrenList; + + long currentVSize; // current VSize of the watched process + long lastVSize; // last VSize of the watched process + + long currentMemory; // current memory of the watched process + long lastMemory; // last memory of the watched process + + bool cleanupSolverOwnIPCQueues; // delete IPC queues that the solver may have created? + bool cleanupAllIPCQueues; // delete all IPC queues that are owned by the user on exit + + TimeStamper *timeStamper=nullptr; +public: + Watcher(): procHistory(10) + { + solverIsRunning=false; + abortChild=false; + + maxDisplayPeriod=60; + + limitCPUTime=0; // no CPU limit by default + limitWallClockTime=0; // no CPU limit by default + limitVSize=0; // no vsize limit by default + limitMemory=0; // no memory limit by default + + delayBeforeKill=2; + + maxVSize=0; + maxMemory=0; + + currentCPUTime=0; + currentUserTime=0; + currentSystemTime=0; + + completedCPUTime=0; + completedUserTime=0; + completedSystemTime=0; + + currentVSize=0; + lastVSize=0; + + currentMemory=0; + lastMemory=0; + + varOutputFilename=NULL; + binVarOutputFilename=NULL; + + cleanupAllIPCQueues=false; + cleanupSolverOwnIPCQueues=false; + + lastProcTree=NULL; + procTree=new ProcessTree(); + procHistory.push(procTree); + } + + ~Watcher() + { + // procTree and lastProcTree are deleted by ~ProcessHistory() + } + + /** + * associate a timestamper. The timeStamper will be called + * periodically to communicate the current CPU time. + */ + void setTimeStamper(TimeStamper &t) + { + timeStamper=&t; + } + + /** + * indicate if prctl(PR_SET_CHILD_SUBREAPER,...) was used + */ + void setChildReaper(bool cr) + { + hasChildReaper=cr; + } + + /** + * delete IPC queues that the solver may have created + */ + void setCleanupSolverOwnIPCQueues(bool cleanup) + { + cleanupSolverOwnIPCQueues=cleanup; + } + + /** + * delete all IPC queues that were created by this user + */ + void setCleanupAllIPCQueues(bool cleanup) + { + cleanupAllIPCQueues=cleanup; + } + + void setCPULimit(int sec) + { + limitCPUTime=sec; + } + + void setWallClockLimit(int sec) + { + limitWallClockTime=sec; + } + + /** + * limits are expressed in kilobytes + * + * soft limit= limit (calls stopSolver()) + * hard limit= limit+reserve (causes immediate SIGKILL) + */ + void setVSizeLimit(long limit) + { + limitVSize=limit; + } + + /** + * limits are expressed in kilobytes + * + * soft limit= limit (calls stopSolver()) + */ + void setMemoryLimit(long limit) + { + limitMemory=limit; + } + + /** + * save the main statistics to a given file (text format) + */ + void setVarOutputFile(char *filename) + { + varOutputFilename=filename; + } + + /** + * save the main statistics to a given file (binary format) + */ + void setBinVarOutputFile(char *filename) + { + binVarOutputFilename=filename; + } + + /** + * set the time we should wait between sending a SIGTERM and a + * SIGKILL to a solver we want to stop + */ + void setDelayBeforeKill(int seconds) + { + delayBeforeKill=seconds; + } + + + void watchPID(pid_t pid) + { + cout << "solver pid=" << pid << ", runsolver pid=" << getpid() << endl; + + childpid=pid; + solverIsRunning=true; + + gettimeofday(&starttv,NULL); + + procTree->setRunsolverPID(getpid()); + + procTree->setElapsedTime(0); + + // it looks like we can't get reliable information on the process + // immediately + // procTree->readProcesses(); + + watcherThread=thread(ref(*this)); + + int childstatus; + struct rusage childrusage; + int wait4result; + + while(true) + { + wait4result=waitpid(-1,&childstatus,0); + + if(wait4result<0 && errno==ECHILD) // nothing to wait for + break; + + if(wait4result<0) + { + perror("FATAL: waitpid() failed"); + break; + } + + float user,syst; + + getrusage(RUSAGE_CHILDREN,&childrusage); + + user=childrusage.ru_utime.tv_sec+childrusage.ru_utime.tv_usec*1E-6; + syst=childrusage.ru_stime.tv_sec+childrusage.ru_stime.tv_usec*1E-6; + + completedCPUTime=user+syst; + completedUserTime=user; + completedSystemTime=syst; + + completedChildrenList.push_back(wait4result); + +#warning print the last history? + struct timeval tv; + + gettimeofday(&tv,NULL); + float elapsed=tv.tv_sec+tv.tv_usec/1E6-starttv.tv_sec-starttv.tv_usec/1E6; + + cout_mutex.lock(); + cout << "\n[startup+" << elapsed << " s]\n" + << "# the end of solver process " << wait4result + << " was just reported to runsolver\n" + << "# cumulated CPU time of all completed processes: user=" << user << " s, system=" << syst << " s" << endl; + if(wait4result!=childpid) + cout << "# this solver process was not waited by its parent and was adopted by runsolver\n"; + cout_mutex.unlock(); + } + + solverIsRunning=false; + gettimeofday(&stoptv,NULL); + + cout << endl << "Solver just ended." << endl; + + watcherThread.join(); + + cout << "Dumping a history of the last processes samples" + << endl; + + procHistory.dumpHistory(cout,lastDisplayedElapsedTime); + cout << endl; + + if (WIFEXITED(childstatus)) + cout << "Child status: " << WEXITSTATUS(childstatus) << endl; + else + if (WIFSIGNALED(childstatus)) + { + int sig=WTERMSIG(childstatus); + + cout << "Child ended because it received signal " + << sig << " (" << getSignalName(sig) << ")" << endl; + +#ifdef WCOREDUMP + if (WCOREDUMP(childstatus)) + cout << "Child dumped core" << endl; +#endif + + } + else + if (WIFSTOPPED(childstatus)) + { + cout << "Child was stopped by signal " + << getSignalName(WSTOPSIG(childstatus)) + << endl; + } + else + { + cout << "Child ended for unknown reason !!" << endl; + } + + float wcTime; // Elapsed real seconds + float solverCPUTime; // Elapsed solver (CPU) seconds + float solverUserTime; // Elapsed solver (User CPU) seconds + float solverSystemTime; // Elapsed solver (System CPU) seconds + + wcTime= + stoptv.tv_sec+stoptv.tv_usec*1E-6 + -starttv.tv_sec-starttv.tv_usec*1E-6; + + // get the CPU time of our children + getrusage(RUSAGE_CHILDREN,&childrusage); + + solverUserTime= + childrusage.ru_utime.tv_sec+childrusage.ru_utime.tv_usec*1E-6; + + solverSystemTime= + childrusage.ru_stime.tv_sec+childrusage.ru_stime.tv_usec*1E-6; + + // solverCPUTime already contains completedCPUTime + solverCPUTime=solverUserTime+solverSystemTime; + + cout << "Real time (s): " << wcTime << endl; + cout << "CPU time (s): " << solverCPUTime << endl; + cout << "CPU user time (s): " << solverUserTime << endl; + cout << "CPU system time (s): " << solverSystemTime << endl; + cout << "CPU usage (%): " << ((wcTime!=0)?100*solverCPUTime/wcTime:100) + << endl; + cout << "Max. virtual memory (cumulated for all children) (KiB): " + << maxVSize << endl; + cout << "Max. memory (cumulated for all children) (KiB): " + << maxMemory << endl; + + if (cleanupAllIPCQueues || cleanupSolverOwnIPCQueues) + cleanupIPCMsgQueues(); + + struct rusage r; + getrusage(RUSAGE_CHILDREN,&r); + + cout << endl; + cout << "getrusage(RUSAGE_CHILDREN,...) data:" << endl; + cout << "user time used= " + << r.ru_utime.tv_sec+r.ru_utime.tv_usec*1E-6 << endl; + cout << "system time used= " + << r.ru_stime.tv_sec+r.ru_stime.tv_usec*1E-6 << endl; + cout << "maximum resident set size= " << r.ru_maxrss << endl; + cout << "integral shared memory size= " << r.ru_ixrss << endl; + cout << "integral unshared data size= " << r.ru_idrss << endl; + cout << "integral unshared stack size= " << r.ru_isrss << endl; + cout << "page reclaims= " << r.ru_minflt << endl; + cout << "page faults= " << r.ru_majflt << endl; + cout << "swaps= " << r.ru_nswap << endl; + cout << "block input operations= " << r.ru_inblock << endl; + cout << "block output operations= " << r.ru_oublock << endl; + cout << "messages sent= " << r.ru_msgsnd << endl; + cout << "messages received= " << r.ru_msgrcv << endl; + cout << "signals received= " << r.ru_nsignals << endl; + cout << "voluntary context switches= " << r.ru_nvcsw << endl; + cout << "involuntary context switches= " << r.ru_nivcsw << endl; + cout << endl; + + if(completedCPUTime!=0) + { + cout << endl; + cout << "# summary of solver processes directly reported to runsolver:\n"; + if(!completedChildrenList.empty()) + { + cout << "# pid: " << completedChildrenList[0]; + for(size_t i=1;ilimitCPUTime) || + (limitWallClockTime && (wcTime>limitWallClockTime)); + execSummary.memOut=limitVSize && maxVSize>limitVSize; + execSummary.maxMem=maxMemory; + + if(varOutputFilename) + { + ofstream var(varOutputFilename); + + if(!var.good()) + cout << "Unable to open file " << varOutputFilename + << " to save the main statistics in text format" + << " (option --var): " << strerror(errno) << "\n" <dumpProcessTree(cout); //??? + if(elapsed>=nextDisplayTime) + { + displayProcessData(); + + nextDisplayTime+=displayPeriod; + displayPeriod=std::min(2*displayPeriod,maxDisplayPeriod); + //cout << "displayPeriod=" << displayPeriod << endl; + //cout << "nextDisplayTime=" << nextDisplayTime << endl; + } + + + if(stopSolverRequested) + { + /*The solver will first receive a SIGTERM to give it a chance to + output the best solution it found so far (in the case of an + optimizing solver). A few seconds later, the program will receive a + SIGKILL signal from the controlling program to terminate the + solver.*/ + + if(stopSolverState==0) + { + // we've just been notified + cout << "\n\n\n" << stopReason << endl; + + // give some evidence to the user + displayProcessData(); + + // send SIGTERM + sendSIGTERM(); + + cout << "Sleeping " << delayBeforeKill << " seconds" << endl; + } + else if(stopSolverState>=delayBeforeKill*10) + { + sendSIGKILL(); + solverIsRunning=false; // we can't do any better anyway + } + + ++stopSolverState; + } // if(stopSolverRequested) + } + + // just to be sure, make sure we don't have any child any more + d={0,10000000}; + nanosleep(&d,nullptr); // wait 10 ms + ProcessTree pt; + pt.setRunsolverPID(getpid()); + pt.readProcesses(); // get a fresh list of processes + if(!pt.solverEnded()) + { + cout << "WARNING: unexpectedly, some solver processes are still present and will be killed:" << endl; + pt.dumpProcessTree(cout); + pt.sendSignalNow(SIGKILL); + } + + cout << "??? end of watcher thread" << endl; + +#ifdef debug + struct rusage r; + getrusage(RUSAGE_THREAD,&r); + cout << "the watcher thread used " + << r.ru_utime.tv_sec+r.ru_utime.tv_usec*1E-6 + << " second user time and " + << r.ru_stime.tv_sec+r.ru_stime.tv_usec*1E-6 + << " second system time\n" + << endl; +#endif + } + +protected: + + /** + * gather data about the watched processes + * + * if updateChildrenList is false, only update process informations + * but don't try to identify new processes (faster), if + * updateChildrenList is true, identify all processes which are a + * children of a watched process. + * + * @return true iff the main process was terminated + */ + bool readProcessData(bool updateChildrenList=true) + { + if (!childpid) + return false; // trying to collect data before parent got the pid + +#ifdef debug + cout << "Reading process data (updateChildrenList=" << updateChildrenList << ")" << endl; +#endif + + lastProcTree=procTree; + procTree=new ProcessTree(*procTree); + + procTree->setElapsedTime(elapsed); + procTree->setCompletedCPUTime(completedCPUTime); + + if (updateChildrenList) + { + procTree->readProcesses(); + if (cleanupSolverOwnIPCQueues) + procTree->listProcesses(listAllProcesses); + } + else + procTree->updateProcessesData(); + + if (procTree->solverEnded() && !solverIsRunning) // ??? + { + delete procTree; + procTree=lastProcTree; + return true; // don't go any further + } + + lastVSize=currentVSize; + lastMemory=currentMemory; + + procTree->currentCPUTime(currentUserTime,currentSystemTime); + currentCPUTime=currentUserTime+currentSystemTime; + + currentVSize=procTree->currentVSize(); + currentMemory=procTree->currentMemory(); + + maxVSize=max(maxVSize,currentVSize); + maxMemory=max(maxMemory,currentMemory); + + procHistory.push(procTree); + + if(timeStamper) + timeStamper->setCPUtimeFromAnotherThread(currentCPUTime+completedCPUTime); + +#warning do we need a mutex or volatile or something? + if (limitCPUTime && currentCPUTime+completedCPUTime>=limitCPUTime) + stopSolver("Maximum CPU time exceeded: sending SIGTERM then SIGKILL"); + + if (limitWallClockTime && elapsed>=limitWallClockTime) + stopSolver("Maximum wall clock time exceeded: sending SIGTERM then SIGKILL"); + + if (limitVSize && currentVSize>=limitVSize) + stopSolver("Maximum VSize exceeded: sending SIGTERM then SIGKILL"); + + if (limitMemory && currentMemory>=limitMemory) + stopSolver("Maximum memory exceeded: sending SIGTERM then SIGKILL"); + + return false; + } + + /** + * display the data we have about all watched processes + * + */ + void displayProcessData() + { + cout_mutex.lock(); + + lastDisplayedElapsedTime=procTree->getElapsedTime(); + procTree->dumpProcessTree(cout); + procTree->dumpCPUTimeAndVSize(cout,currentCPUTime,currentVSize,currentMemory); + + if (elapsed>2 && currentCPUTimedumpHeavyProcesses(cout,heavyProcessThreshold); + } + + cout_mutex.unlock(); + } + + void sendSIGTERM() + { + cout << "\nSending SIGTERM to process tree (bottom up)" << endl; + procTree->sendSignalBottomUp(SIGTERM); + } + + void sendSIGKILL() + { + cout << "\nSending SIGKILL to process tree (bottom up)" << endl; + procTree->sendSignalBottomUp(SIGKILL); + } + + /** + * delete IPC queues that may have been created by the solver + */ + void cleanupIPCMsgQueues() + { +#ifndef __linux__ +#error This code is linux specific +#endif + + struct msginfo msginfo; + struct msqid_ds msgqueue; + int maxid,msqid; + uid_t myUid=geteuid(); + + cout << "\n"; + + maxid=msgctl(0,MSG_INFO,reinterpret_cast(&msginfo)); + if (maxid<0) + return; + + for (int id=0;id<=maxid;++id) + { + msqid=msgctl(id,MSG_STAT,&msgqueue); + + if (msqid<0) + continue; + + if (msgqueue.msg_perm.cuid==myUid && + (cleanupAllIPCQueues || + listAllProcesses.find(msgqueue.msg_lspid)!=listAllProcesses.end() || + listAllProcesses.find(msgqueue.msg_lrpid)!=listAllProcesses.end())) + { + cout << "deleting IPC queue " << msqid; + if (msgctl(msqid,IPC_RMID,&msgqueue)) + cout << " (failed: " << strerror(errno) << ")"; + cout << "\n"; + } + } + } +}; + +// Local Variables: +// mode: C++ +// End: +#endif diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver new file mode 100755 index 0000000..0c9ffcc Binary files /dev/null and b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver differ diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.cc b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.cc new file mode 100644 index 0000000..7206e6f --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.cc @@ -0,0 +1,1355 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + +#define _GNU_SOURCE + + +// if TIMESTAMPSEPARATESTDOUTANDERR is defined, when time stamping the +// solver output, stdout and stderr are transmitted separately to +// runsolver. This lets us print whether the line comes from stdout or +// stderr. Unfortunately, when streams are separated, we have no +// guarantee to get the lines in the order they were sent (try with +// testtimestamper.cc). For this reason, this flag should be +// undefined. When undefined, stdout and stderr are combined together +// in the solver and are transmitted through one single pipe to +// runsolver. Anyway, this is the usual way to pipe a program output +// to another program input +#undef TIMESTAMPSEPARATESTDOUTANDERR + +#define SENDSIGNALBOTTOMUP + +/* + * TODO + * + * - create a class Watcher that handles the procTree and the timer thread + * + * - arrange so that display occurs each n*period seconds (and not n*(period+epsilon)) + * - print the command line of new processes (??) + * + * - use /proc/%pid/status + * + * - man pthreads : le comportement de la mesure du temps pour les + * threads depend de la version du noyau + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef WITH_NUMA +#include +#endif + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include + +#include "Cores.hh" +#include "SignalNames.hh" +#include "ProcessList.hh" +#include "CircularBufferFilter.hh" +#include "ExecutionSummary.hh" + +#include "Watcher.hh" +#include "TimeStamper.hh" + +using namespace std; + +const char *version=VERSION; + +/** + * use only one instance + * + */ +class RunSolver +{ +private: + class Limit + { + private: + int resource; + rlim_t limit; + protected: + const char *name,*unit; // name and unit of this limit + int scale; // call setrlimit() with limit<>scale; + } + }; + +public: + /** + * This is a fake limit. It doesn't enforce anything by its own. + */ + class SoftVSIZELimit : public Limit + { + public: + SoftVSIZELimit(rlim_t size) : Limit(-1) + { + name="VSIZE limit (soft limit, will send SIGTERM then SIGKILL)"; + unit="KiB"; + scale=10; + setLimit(size); + } + }; + + class HardVSIZELimit : public Limit + { + public: + HardVSIZELimit(rlim_t size) : Limit(RLIMIT_AS) + { + name="VSIZE limit (hard limit, stack expansion will fail with SIGSEGV, brk() and mmap() will return ENOMEM)"; + unit="KiB"; + scale=10; + setLimit(size); + } + }; + + /** + * This is a fake limit. It doesn't enforce anything by its own. + */ + class MemoryLimit : public Limit + { + public: + MemoryLimit(rlim_t size) : Limit(-1) + { + name="RSS+Swap limit (soft limit, will send SIGTERM then SIGKILL)"; + unit="KiB"; + scale=10; + setLimit(size); + } + }; + + /** + * This is a fake limit. It doesn't enforce anything by its own. + */ + class SoftCPULimit : public Limit + { + public: + SoftCPULimit(rlim_t cpuTime) : Limit(-1) + { + name="CPUTime limit (soft limit, will send SIGTERM then SIGKILL)"; + unit="seconds"; + setLimit(cpuTime); + } + }; + + /** + * This is a fake limit. It doesn't enforce anything by its own. + */ + class WallClockLimit : public Limit + { + public: + WallClockLimit(rlim_t wallClockTime) : Limit(-1) + { + name="wall clock limit (soft limit, will send SIGTERM then SIGKILL)"; + unit="seconds"; + setLimit(wallClockTime); + } + }; + + class HardCPULimit : public Limit + { + public: + HardCPULimit(rlim_t cpuTime) : Limit(RLIMIT_CPU) + { + name="CPUTime limit (hard limit, will send SIGXCPU)"; + unit="seconds"; + setLimit(cpuTime); + } + }; + + class FileSizeLimit : public Limit + { + public: + FileSizeLimit(rlim_t fileSize) : Limit(RLIMIT_FSIZE) + { + name="FSIZE limit"; + unit="KiB"; + scale=10; + setLimit(fileSize); + } + }; + + class NumberOfFilesLimit : public Limit + { + public: + NumberOfFilesLimit(rlim_t nbFiles) : Limit(RLIMIT_NOFILE) + { + name="NbFILES limit"; + unit="files"; + setLimit(nbFiles); + } + }; + + class StackSizeLimit : public Limit + { + public: + /** + * won't enforce limit + */ + StackSizeLimit() : Limit(RLIMIT_STACK) + { + name="StackSize limit"; + unit="KiB"; + scale=10; + } + + /** + * will enforce limit + */ + StackSizeLimit(rlim_t size) : Limit(RLIMIT_STACK) + { + name="Stack size limit"; + unit="KiB"; + scale=10; + setLimit(size); + } + }; + + +private: + // this is the object in charge of monitoring the solver and its children + Watcher watcher; + + static Watcher *instanceWatcher; // instance of Watcher for signal handlers + + /** + * signal handler to gather data about the solver + * + * may be called for SIGINT, SIGTERM or SIGALRM + */ + static void watcherSigHandler(int signum, siginfo_t *siginfo, void *ucontext) + { +#ifdef debug + cout << "signal handler called for " << getSignalName(signum) << endl; +#endif + +#ifdef disabled + // if we don't use the SA_NOCLDSTOP flag for sigaction() when + // registering the handler for SIGCHLD, we get a SIGCHLD each time + // the traced process is stopped by a sigtrap. These must be + // ignored. The code below ignores all SIGCHLD including the one + // which let us know that the process we're watching has + // terminated (despite the fact that this is something we want to + // know). For this reason, this code is disabled and we use + // SA_NOCLDSTOP + + if (signum==SIGCHLD) + return; +#endif + + if (signum==SIGTERM || signum==SIGINT) + { + // ask the timer thread to kill the child + instanceWatcher->stopSolver("Received SIGTERM or SIGINT, killing child"); + return; + } + } + + vector limits; + + ofstream out; + + // when set, redirect the standard input of the child to this file + char *inputRedirectionFilename=nullptr; + + // when set, redirect the standard output of the child to this file + char *outputRedirectionFilename=nullptr; + + // a class to timestamp each line of some output streams + static TimeStamper tStamp; + + bool timeStamping=false; // true iff the solver output must be timestamped + int stdoutRedirFD[2]; // pipe for timestamping the solver stdout +#ifdef TIMESTAMPSEPARATESTDOUTANDERR + int stderrRedirFD[2]; // pipe for timestamping the solver stderr +#endif + bool usePTY=false; // use a PTY to collect output from the solver ? (to + // force the solver to line-buffer its output) + int ptymaster; // PTY master + + pthread_t timeStamperTID; // tid of the thread which does the timestamping + + // limits imposed on the size of the solver output (0 if unlimited) + unsigned long long int limitedOutputActivateSize=0,limitedOutputMaxSize=0; + + CircularBufferFilter limitedOutputSizeFilter; // a filter to limit + // the solver output + // size + + streambuf *coutSaveBuf=nullptr; // backup of the cout buf (in case of a redirection) + +public: + RunSolver() + { + } + + ~RunSolver() + { + // delete limits + for(Limit *l: limits) + delete l; + + // cancel redirection before we leave + if (coutSaveBuf) + cout.rdbuf(coutSaveBuf); + } + + + /** + * use a PTY to collect the solver output + */ + void setUsePTY(bool usePTY) + { + this->usePTY=usePTY; + } + + /** + * send the output of the watching process to a given file + */ + void setWatcherOutputFile(char *filename) + { + out.open(filename); + coutSaveBuf=cout.rdbuf(out.rdbuf()); + } + + /** + * redirect the standard input of the solver to a given file + */ + void setInputRedirection(char *filename) + { + inputRedirectionFilename=filename; + } + + /** + * redirect the standard output of the solver to a given file + */ + void setOutputRedirection(char *filename) + { + outputRedirectionFilename=filename; + } + + /** + * save the main statistics to a given file (text format) + */ + void setVarOutputFile(char *filename) + { + watcher.setVarOutputFile(filename); + } + + /** + * save the main statistics to a given file (binary format) + */ + void setBinVarOutputFile(char *filename) + { + watcher.setBinVarOutputFile(filename); + } + + /** + * decide if we should timestamp the solver output or not + */ + void setTimeStamping(bool val) + { + timeStamping=val; + } + + /** + * decide if we should add an EOF line to the solver output or not + */ + void setTimeStampingAddEOF(bool val) + { + if (!timeStamping) + throw runtime_error("EOF line can only be added when timestamping is on"); + + tStamp.addEOF(val); + } + + /** + * limit the size of the solver output + */ + void setSolverOutputLimits(unsigned long long int activateSize, + unsigned long long int maxSize) + { + if (!timeStamping) + throw runtime_error("limit on the output size can only be enforced when timestamping is on"); + + limitedOutputActivateSize=activateSize; + limitedOutputMaxSize=maxSize; + } + + /** + * set the time we should wait between sending a SIGTERM and a + * SIGKILL to a solver we want to stop + */ + void setDelayBeforeKill(int seconds) + { + watcher.setDelayBeforeKill(seconds); + } + + void setCPULimit(int sec) + { + watcher.setCPULimit(sec); + + // SoftCPULimit doesn't enforce anything by its own + addLimit(new SoftCPULimit(sec)); + + addLimit(new HardCPULimit(sec+30)); + // add an extra delay because we want to stop the solver by + // stopSolver() instead of SIGXCPU + } + + void setWallClockLimit(int sec) + { + watcher.setWallClockLimit(sec); + + // WallClockLimit doesn't enforce anything by its own + addLimit(new WallClockLimit(sec)); + } + + /** + * limits are expressed in kilobytes + * + * soft limit= limit (calls stopSolver()) + * hard limit= limit+reserve (causes immediate SIGKILL) + */ + void setVSizeLimit(long limit, long reserve) + { + watcher.setVSizeLimit(limit); + + // SoftVSIZELimit doesn't enforce anything by its own + addLimit(new SoftVSIZELimit((limit))); + + // add an extra amount of memory because we want to stop the solver by + // stopSolver() instead of SIGKILL + addLimit(new HardVSIZELimit((limit+reserve))); + } + + /** + * limits are expressed in kilobytes + * + * soft limit= limit (calls stopSolver()) + */ + void setMemoryLimit(long limit) + { + watcher.setMemoryLimit(limit); + + addLimit(new MemoryLimit((limit))); + } + + void setSignal(const char *signalName) + { + throw runtime_error("unimplemented"); + } + + /** + * delete IPC queues that the solver may have created + */ + void setCleanupSolverOwnIPCQueues(bool cleanup) + { + watcher.setCleanupSolverOwnIPCQueues(cleanup); + } + + /** + * delete all IPC queues that were created by this user + */ + void setCleanupAllIPCQueues(bool cleanup) + { + watcher.setCleanupAllIPCQueues(cleanup); + } + + /** + * add a limit to respect + * + * @parm limit: must be dynamically allocated + */ + void addLimit(Limit *limit) + { + limits.push_back(limit); + } + + void printLimits(ostream &s) + { + for(size_t i=0;ioutput(s); + + if (limitedOutputMaxSize) + { + if (timeStamping) + cout << "Solver output will be limited to a maximum of " + << limitedOutputMaxSize << " bytes. The first " + << limitedOutputActivateSize << " bytes and the last " + << limitedOutputMaxSize-limitedOutputActivateSize + << " bytes will be preserved" << endl; + else + cout << "Solver output limit is ignored (currently only " + "available with timestamping)" << endl; + } + + if (timeStamping && usePTY) + cout << "Using a pseudo terminal to collect output from the solver" + << endl; + } + + /** + * select cores that will be available to the process we watch + * + * if physicalView is true, desc contains the id of the cores to be + * used as they are known on the system. In this case, cores 0 and + * 1 (for example) may belong to different processors. + * + * if physicalView is false, desc contains the index of the cores to + * be used in a list of available cores sorted by the processor to + * which they belong. In this case, cores 0 and 1 (for example) will + * necessarily belong to the same processor (unless it has only one + * core!) + */ + void selectCores(const string &desc, bool physicalView) + { + vector availableCores,selectedCores; + + getExistingCores(availableCores,physicalView); + + istringstream d(desc); + size_t a,b; + + while(true) + { + if(!(d>>a)) + { + printCoresListSyntax(); + exit(1); + } + + while(isspace(d.peek())) + d.get(); + + if(d.peek()=='-') + { + d.get(); + if(d>>b) + { + //cout << "read " << a << "-" << b << endl; + if(b=0 && i= 3.4 in order to use prctl(PR_SET_CHILD_SUBREAPER,...). Aborting.\n"; + exit(1); + } + else + watcher.setChildReaper(true); + } + + struct sigaction handler; + + handler.sa_sigaction=watcherSigHandler; + sigemptyset(&handler.sa_mask); + handler.sa_flags=SA_SIGINFO|SA_NOCLDSTOP|SA_RESTART; + /* + The SA_RESTART flag tells that system calls which are + interrupted by a signal should be automatically restarted. This + way, we don't have to encapsulate system calls in a loop which + would restart them when they return with + errno=EINTR. Alternatively, we could have used + siginterrupt(). + + The SA_NOCLDSTOP prevent us from getting a SIGCHLD each time a + process is stopped for tracing. + */ + + sigaction(SIGALRM,&handler,NULL); + sigaction(SIGINT,&handler,NULL); + sigaction(SIGTERM,&handler,NULL); + + if (timeStamping) + { + int fd=STDOUT_FILENO; + + if (outputRedirectionFilename) + { + fd=open(outputRedirectionFilename,O_WRONLY|O_CREAT|O_TRUNC,0644); + if (fd<0) + throw runtime_error(string("open failed during output redirection: ") + +strerror(errno)); + } + + int outputFromSolverFD=0; + + if (usePTY) + { + ptymaster=posix_openpt(O_RDWR); + if (ptymaster<0) + { + perror("Failed to create pseudo-terminal"); + exit(1); + } + + outputFromSolverFD=ptymaster; + + if (grantpt(ptymaster)!=0) + { + perror("Failed to grant the pseudo-terminal"); + exit(1); + } + + if (unlockpt(ptymaster)!=0) + { + perror("Failed to unlock the pseudo-terminal"); + exit(1); + } + } + else + { + pipe(stdoutRedirFD); +#ifdef TIMESTAMPSEPARATESTDOUTANDERR + pipe(stderrRedirFD); +#endif + } + +#ifdef TIMESTAMPSEPARATESTDOUTANDERR + tStamp.watch(stdoutRedirFD[0],'o',fd); // 'o' as output + tStamp.watch(stderrRedirFD[0],'e',fd); // 'e' as error +#else + + if (usePTY) + outputFromSolverFD=ptymaster; + else + outputFromSolverFD=stdoutRedirFD[0]; + + if (limitedOutputMaxSize) + { + limitedOutputSizeFilter.setup(fd,limitedOutputActivateSize, + limitedOutputMaxSize); + tStamp.watch(outputFromSolverFD,&limitedOutputSizeFilter,0); + } + else + tStamp.watch(outputFromSolverFD,0,fd); +#endif + tStamp.resetTimeStamp(); + + int err=pthread_create(&timeStamperTID,NULL,timeStampThread,NULL); + if (err) + cout << "Failed to create a thread to timestamp the solver output" + << endl; + } + + pid_t childpid=fork(); + if (childpid<0) + { + perror("fork failed"); + exit(127); + } + else + if (childpid==0) + { + // child + + // enforce limits + for(size_t i=0;ienforceLimit(); + + StackSizeLimit stackLimit; + stackLimit.outputEnforcedLimit(cout); + cout << endl; + + // create a new process group (for several reasons, see for + // example ProcessTree::rootProcessEnded()) + setpgid(0,0); + + if (inputRedirectionFilename) + { + int err; + int fd; + + fd=open(inputRedirectionFilename,O_RDONLY); + if (fd<0) + throw runtime_error(string("open failed during input redirection: ") + +strerror(errno)); + + err=dup2(fd,STDIN_FILENO); + if (err<0) + throw runtime_error(string("dup2 failed during input redirection: ") + +strerror(errno)); + + close(fd); + } + + if (outputRedirectionFilename && !timeStamping) + { + int err; + int fd; + + fd=open(outputRedirectionFilename,O_WRONLY|O_CREAT|O_TRUNC,0644); + if (fd<0) + throw runtime_error(string("open failed during output redirection: ") + +strerror(errno)); + + err=dup2(fd,STDOUT_FILENO); + if (err<0) + throw runtime_error(string("dup2 failed during output redirection: ") + +strerror(errno)); + + err=dup2(fd,STDERR_FILENO); + if (err<0) + throw runtime_error(string("dup2 failed during output redirection: ") + +strerror(errno)); + + close(fd); + } + + if (timeStamping) + { + if (usePTY) + { + int err; + int fd; + + char *pts=ptsname(ptymaster); + + if (pts==NULL) + throw runtime_error(string("Failed to get pty slave name:") + +strerror(errno)); + + fd=open(pts,O_RDWR); + if (fd<0) + throw runtime_error(string("open of pty slave failed: ") + +strerror(errno)); + + err=dup2(fd,STDOUT_FILENO); + if (err<0) + throw runtime_error(string("dup2 failed during output redirection: ") + +strerror(errno)); + + err=dup2(fd,STDERR_FILENO); + if (err<0) + throw runtime_error(string("dup2 failed during output redirection: ") + +strerror(errno)); + + close(fd); + } + else + { + // plain tube + + // redirecting stdout and stderr to the write side of the + // pipes to runsolver; close the read side of the pipe which + // belongs to our father + + close(stdoutRedirFD[0]); + dup2(stdoutRedirFD[1],STDOUT_FILENO); + close(stdoutRedirFD[1]); + +#ifdef TIMESTAMPSEPARATESTDOUTANDERR + close(stderrRedirFD[0]); + dup2(stderrRedirFD[1],STDERR_FILENO); + close(stderrRedirFD[1]); +#else + dup2(STDOUT_FILENO,STDERR_FILENO); +#endif + } + } + + execvp(cmd[0],cmd); + // only returns when it failed + perror("exec failed"); + + int i=0; + cerr << "Solver command line was: "; + while (cmd[i]) + cerr << cmd[i++] << ' '; + + cerr << '\n' << endl; + + exit(127); + } + else + { + // parent +#ifdef debug + cout << "child has pid " << childpid << endl; +#endif + // We don't care about stdin. In case someone writes 'echo + // data | runsolver program', runsolver just closes its stdin + // and the child will be the only one to access it. + close(STDIN_FILENO); + + // let runsolver run on the last allocated core + vector cores; + + getAllocatedCoresByProcessorOrder(cores); + if(cores.size()>1) + { + int tmp=cores.back(); + cores.clear(); + cores.push_back(tmp); + } + + cpu_set_t mask=affinityMask(cores); + if(sched_setaffinity(0,sizeof(cpu_set_t),&mask)!=0) + perror("sched_setaffinity failed: "); + + if (timeStamping && !usePTY) + { + // the write side of the pipe belongs to the child + close(stdoutRedirFD[1]); +#ifdef TIMESTAMPSEPARATESTDOUTANDERR + close(stderrRedirFD[1]); +#endif + } + + if(timeStamping) + watcher.setTimeStamper(tStamp); + + // start monitoring the solver (will create a thread, and wait + // for the solver end) + watcher.watchPID(childpid); + + if (timeStamping) + { + // wait for the time stamper thread to output the last lines + cout << "??? join timestamper begins" << endl; + pthread_join(timeStamperTID,NULL); + cout << "??? join timestamper ends" << endl; + } + + cout << "??? end of timestamper thread" << endl; //??? + + // print the resources used by runsolver itself + struct rusage r; + getrusage(RUSAGE_SELF,&r); + cout << "runsolver used " + << r.ru_utime.tv_sec+r.ru_utime.tv_usec*1E-6 + << " second user time and " + << r.ru_stime.tv_sec+r.ru_stime.tv_usec*1E-6 + << " second system time\n" + << endl; + + cout << "The end" << endl; + } + } + + + /** + * procedure run by the thread in charge of timestamping the solver + * output stream + */ + static void *timeStampThread(void *) + { + tStamp.timeStampLines(); // enless loop + + return NULL; + } + +}; + + +#ifdef WITH_NUMA +void numaInfo() +{ + if(numa_available()==-1) + return; + + int nbNodes=numa_num_configured_nodes(); + long mem,memFree; + + cout << "NUMA information:\n"; + cout << " number of nodes: " << nbNodes << endl; + for(int i=0;i " + << "seconds will send a SIGKILL to the watched process" << endl; + cout << "--version\n" + << " print the version and exit\n"; + cout << "-w filename or --watcher-data filename\n" + << " sends the watcher informations to filename" << endl; + cout << "-v filename or --var filename\n" + << " save the most relevant information (times,...) in an easy to parse VAR=VALUE file" << endl; + cout << "-o filename or --solver-data filename\n" + << " redirects the solver output (both stdout and stderr) to filename\n" + << "--signal signalName\n" + << " send signal instead of SIGTERM\n" + << "--input filename\n" + << " redirects the standard input of the runned program to filename\n" + << "--timestamp\n" + << " instructs to timestamp each line of the solver standard output and\n" + << " error files (which are then redirected to stdout)\n" + << "--add-eof\n" + << " when timestamps are used, request to add an 'EOF' line at the end of the solver output\n" + << "--output-limit start,max or -O start,max:\n" + << " limits the size of the solver output.\n" + << " Currently implies --timestamp. The solver output will be limited\n" + << " to a maximum of MiB. The first MiB will be\n" + << " preserved as well as the last MiB.\n" + << "--phys-cores list\n" + << " allocate a subset of the cores to the solver. The list contains\n" + << " core numbers separated by commas, or ranges first-last. This list\n" + << " must contain core identifiers as they are known by the system in\n" + << " /proc/cpuinfo.\n" + << "--cores list\n" + << " allocate a subset of the cores to the solver. The list contains\n" + << " core numbers separated by commas, or ranges first-last. This list\n" + << " contains the index of the selected cores in a list of core identifiers\n" + << " sorted by the processor they belong to. For example, if processor 0\n" + << " contains cores 0, 2, 4, 6 and processor 1 contains cores 1, 3, 5, 7,\n" + << " the sorted list is 0, 2, 4, 6, 1, 3, 5, 7 and the argument 0-3 will select\n" + << " the 4 cores of processor 0 (with physical id 0, 2, 4, 6). This option\n" + << " allows to ignore the details of the core numbering scheme used by the kernel.\n" + << "--use-pty\n" + << " use a pseudo-terminal to collect the solver output. Currently only\n" + << " available when lines are timestamped. Some I/O libraries (including\n" + << " the C library) automatically flushes the output after each line when\n" + << " the standard output is a terminal. There's no automatic flush when\n" + << " the standard output is a pipe or a plain file. See setlinebuf() for\n" + << " some details. This option instructs runsolver to use a\n" + << " pseudo-terminal instead of a pipe/file to collect the solver\n" + << " output. This fools the solver which will line-buffer its output.\n" + << "--cleanup-own-ipc-queues\n" + << " on exit, delete IPC queues that the user owns and to which the solver\n" + << " was the last process to read/write [may fail to delete some queues]\n" + << "--cleanup-all-ipc-queues\n" + << " on exit, delete all IPC queues that the user created [will also delete\n" + << " queues that don't belong to the solver]\n" + << "--bin-var filename\n" + << " save the most relevant information (times,...) about the solver\n" + << " execution in a binary format file named filename. The format of\n" + << " the file is given by the internal struct ExecutionSummary (see\n" + << " ExecutionSummary.hh). As this file is accessed through a shared\n" + << " memory mapping, this option is essentially useful to\n" + << " efficiently report the results to a calling program. This\n" + << " avoids to use the --var option and parse the resulting text\n" + << " file later.\n" + << "--watchdog delay\n" + << " send an ABRT signal to runsolver after delay seconds\n" + << endl; + + exit(1); +} + +void printVersion() +{ + cout << "runsolver version " << version << " (svn: " << SVNVERSION + << ") Copyright (C) 2010-2013 Olivier ROUSSEL\n\n" + << "This program is distributed in the hope that it will be useful,\n" + << "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + << "GNU General Public License for more details.\n" + << endl; +} + +void watchdog(int watchdogDelay) +{ + cout << "Starting watchdog thread" << endl; + sleep(watchdogDelay); + cout << "watchdog killed runsolver after " << watchdogDelay << " seconds." << endl; + kill(getpid(),SIGABRT); +} + +int main(int argc, char **argv) +{ + RunSolver solver; + int optc; + + // memLimit in KiB + long vsizeLimit=0,memLimit=0; + // difference between the 'hard' and the 'soft' limit (in KiB) + int vsizeSoftToHardLimit=50*1024; + + int watchdogDelay=0; + + string cmdline; + for(int i=0;i=max) + { + cout << "Syntax: --output-limit A,M with A cores; + + getAllocatedCoresByProcessorOrder(cores); + + cout << "running on " << cores.size() << " cores: "; + printAllocatedCores(cout,cores); + cout << "\n\n"; + + if (vsizeLimit) + solver.setVSizeLimit(vsizeLimit,vsizeSoftToHardLimit); + + if (memLimit) + solver.setMemoryLimit(memLimit); + + solver.printLimits(cout); + + thread watchdogThread; + if(watchdogDelay) + { + watchdogThread=move(thread(watchdog,watchdogDelay)); + watchdogThread.detach(); + } + + solver.run(&argv[optind]); + } + catch (exception &e) + { + cout.flush(); + cerr << "\n\tUnexpected exception in runsolver:\n"; + cerr << "\t" << e.what() << endl; + exit(1); + } +} + +/* +setitimer(ITIMER_PROF,...) to receive SIGPROF regularly + +alarm to receive SIGALRM at the timeout ??? +*/ + +// Local Variables: +// mode: C++ +// End: + diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.d b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.d new file mode 100644 index 0000000..767e042 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.d @@ -0,0 +1,3 @@ +runsolver.d runsolver.o: runsolver.cc Cores.hh SignalNames.hh ProcessList.hh \ + CircularBufferFilter.hh ExecutionSummary.hh Watcher.hh ProcessTree.hh \ + ProcessData.hh ProcessHistory.hh TimeStamper.hh diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.o b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.o new file mode 100644 index 0000000..f33ef95 Binary files /dev/null and b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.o differ diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.spec b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.spec new file mode 100644 index 0000000..f91b259 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/runsolver.spec @@ -0,0 +1,53 @@ +Name: runsolver +Summary: run a solver and tightly control the ressources it uses +Version: 3.4.0 +Release: 1 +License: GPLv3 +Group: Applications/System +Source0: %{name}-%{version}.tar.bz2 +BuildRoot: %{_tmppath}/%{name}-root +URL: http://www.cril.univ-artois.fr/~roussel/runsolver + +%description + +runsolver is a program meant to control the ressources used by a +solver. Basically, it can be seen as the integration of the time and +ulimit commands, but it has several other features. It is able to +timestamp each line output by a program, is able to handle correctly +multithreads or multiprocesses programs (don't loose the time of the +child even when the parent doesn't call wait()), is able to enforce +strict limits on the memory usage, logs information on each process +generated by the solver and is able to limit the size of the solver +output. + +This program is especially useful when you want to run a program and +strictly control the ressources it uses. + +This program was first used in the competitions of Pseudo-Boolean +solvers (2005) and was later used in the SAT and CSP competitions. + +For now, the code is Linux specific. + +%prep +%setup -q -n runsolver + +%build +cd src +make + +%install +cd src +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/usr/bin +make INSTROOT=$RPM_BUILD_ROOT install + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +/usr/bin/runsolver + +%changelog +* Fri Nov 8 2009 roussel +- Initial build. diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/Makefile b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/Makefile new file mode 100644 index 0000000..36d7837 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/Makefile @@ -0,0 +1,6 @@ +server: server.cc + g++ -std=c++11 -o server server.cc + +run: server + ./server + diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/Makefile~ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/Makefile~ new file mode 100644 index 0000000..4ccff0c --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/Makefile~ @@ -0,0 +1,2 @@ +server: server.cc + g++ -std=c++11 -o server server.cc diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server new file mode 100755 index 0000000..3efc25c Binary files /dev/null and b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server differ diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server.cc b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server.cc new file mode 100644 index 0000000..c8c8f8c --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server.cc @@ -0,0 +1,207 @@ +/* + https://lwn.net/Articles/230975/ saved as ELC: How much memory are applications really using? [LWN.net].html +http://eqware.net/Articles/CapturingProcessMemoryUsageUnderLinux/index.html saved as Capturing Process Memory Usage Under Linux.html +https://stackoverflow.com/questions/561245/virtual-memory-usage-from-java-under-linux-too-much-memory-used/561450#561450 saved as Virtual Memory Usage from Java under Linux, too much memory used - Stack Overflow.html +https://www.selenic.com/smem/ +pmap + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +/** + * /proc/xx/maps [beg,end( + * + */ + +class MemoryUsage +{ +protected: + //enum PageMapType + + uint64_t unmappedPages,ramPages,swapPages,sharedPages; + +public: + MemoryUsage() + { + struct utsname unam; + + uname(&unam); + + vector ver; + boost::split(ver,unam.release, boost::is_any_of(".")); + + cout << "rel=" << ver[0] << "." << ver[1] << endl; + } + + bool readMaps(const vector &pidList) + { +#warning must add support for hugepages + uint64_t lastUnmappedPages,lastRamPages,lastSwapPages,lastSharedPages; + uint64_t pagesize=sysconf(_SC_PAGESIZE); + + set pagesList; + pair::iterator,bool> ret; + + unmappedPages=ramPages=swapPages=sharedPages=0; + + for(pid_t pid: pidList) + { + ostringstream mapsfname,pagemapfname; + mapsfname << "/proc/" << pid << "/maps"; + pagemapfname << "/proc/" << pid << "/pagemap"; + + ifstream maps(mapsfname.str()); + if(!maps.good()) + return false; + + int pagemap=open(pagemapfname.str().c_str(),O_RDONLY); + if(pagemap<0) + cout << "access to " << pagemapfname.str() << " denied\n"; + + unsigned long beg,end,inode; + string perm,path,tmp; + char c; + + while(true) + { + path.clear(); + maps >> hex >> beg >> c >> end >> dec >> perm >> tmp >> tmp >> inode; + while((c=maps.peek()) && isspace(c) && c!='\n') + maps.get(); + getline(maps,path); + if(maps.fail() && path.empty()) + break; + + + cout << (end-beg)/pagesize << "\t" << hex << beg << "-" << end << dec << " " << perm << " path=" << path << endl; + + lastUnmappedPages=unmappedPages; + lastRamPages=ramPages; + lastSwapPages=swapPages; + lastSharedPages=sharedPages; + + if(pagemap>=0) + { + uint64_t desc; + off_t pos=sizeof(desc)*(beg/pagesize); + off_t res=lseek(pagemap,pos,SEEK_SET); + if(res<0 || res!=pos) + cout << "lseek failed:" << strerror(errno) << endl; + + //cout << "res=" << hex << res << dec << endl; + + for(unsigned long p=beg;p " + << (present?"Present ":"") + << (swap?"Swp ":"") + << (map?"Map ":"") + << (excl?"Excl ":"") + << (softDirty?"SoftD ":"") + << " " + << ((desc>>57)&0xF) + << " " << (desc&((1UL<<55)-1)) << dec << endl; + + if(pfn) + { + ret=pagesList.insert(pfn); + if(!ret.second) + ++sharedPages; + else + if(swap) + ++swapPages; + else + ++ramPages; + } + else + ++unmappedPages; + } + } //if(pagemap>=0 + + cout << "=> total=" << (end-beg)/1024 << "KB" + << " unmapped=" << (unmappedPages-lastUnmappedPages)*(pagesize/1024) << "KB" + << " ram=" << (ramPages-lastRamPages)*(pagesize/1024) << "KB" + << " swap=" << (swapPages-lastSwapPages)*(pagesize/1024) << "KB" + << " shared=" << (sharedPages-lastSharedPages)*(pagesize/1024) << "KB" << endl; + + + }//while(true) + + close(pagemap); + }//for(pid_t pid... + + + cout << "pagesList (size=" << pagesList.size() << "):"; + //for(uint64_t p: pagesList) + // cout << " " << hex << p << dec; + cout << endl; + + cout << "unmapped=" << unmappedPages*(pagesize/1024) << "KB\n" + << "ram=" << ramPages*(pagesize/1024) << "KB\n" + << "swap=" << swapPages*(pagesize/1024) << "KB\n" + << "shared=" << sharedPages*(pagesize/1024) << "KB\n" + << "VSS=all=" << (ramPages+unmappedPages+swapPages+sharedPages)*(pagesize/1024) << "KB\n" + << "RSS=ram+shared=" << (ramPages+sharedPages)*(pagesize/1024) << "KB\n"; + + return true; + } +}; + +int main() +{ + MemoryUsage mu; + + + mu.readMaps({getpid()}); + + sleep(1); + cout << "pid=" << getpid() << endl; + ostringstream cmd; + + for(const char *fname: {"status","stat","statm","smaps","maps"}) + { + cmd.str(""); + cmd << "/bin/cat /proc/" << getpid() << "/" << fname; + cout << "\n\n#######################################################################\n" + << cmd.str() << endl; + system(cmd.str().c_str()); + } + //sleep(30); + + /* + ./server>/tmp/res + awk '/^Rss:/ {s=s+$2} END {print s}' /tmp/res + + status ne semble pas donner la bonne valeur de RSS (incohérent avec la somme des RSS de smaps) + + il y a quelques petites différences avec les valeurs données par smaps + */ +} diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server.cc~ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server.cc~ new file mode 100644 index 0000000..d26353f --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/server/server.cc~ @@ -0,0 +1,35 @@ +#include +#include +using namespace std; + + +bool readMaps(pid_t pid) +{ + ostringstream fname; + fname << "/proc/" << pid << "/maps"; + + ifstream in(fname.str()); + if(!in.good()) + return false; + + long beg,end,inode; + string perm,path,tmp; + char sep; + + while(true) + { + in >> hex >> beg >> sep >> end >> dec >> perm >> tmp >> tmp >> inode; + getline(in,path); + if(in.fail() &&path.empty()) + break; + + cout << hex << beg << "-" << end << " " << perm <<<< endl; + } + + return true; +} + +int main() +{ + +} diff --git a/benchmarks/programs/runsolver-3.4.0/runsolver/src/vlineSplitter.cc b/benchmarks/programs/runsolver-3.4.0/runsolver/src/vlineSplitter.cc new file mode 100644 index 0000000..5692526 --- /dev/null +++ b/benchmarks/programs/runsolver-3.4.0/runsolver/src/vlineSplitter.cc @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2010 Olivier ROUSSEL + * + * This file is part of runsolver. + * + * runsolver is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * runsolver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with runsolver. If not, see . + */ + + + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +int main(int argc, char **argv) +{ + string s,timestamp; + bool withTimestamp; + + withTimestamp=argc==2 && strcmp(argv[1],"--timestamp")==0; + + try + { + while(cin.good()) + { + if (withTimestamp) + { + cin >> timestamp; + cin.get(); // skip tabulation + + if (!cin.good()) + break; + } + + getline(cin,s); + + if (!cin.good() && s.length()==0) + break; + + // we're only concerned by a "v " line + if (s.length()>=2 && s[0]=='v' && s[1]==' ') + { + istringstream f(s); + string word; + int len=0; + + f >> word; // skip "v " + + while (f.good()) + { + // read a literal + word=""; + f >> word; + if (word=="") + break; + + if (len==0) + { + if (withTimestamp) + cout << timestamp << "\t"; + cout << "v"; + } + + cout << " " << word; + len+=word.length(); + + if (len>100) + { + cout << endl; + len=0; + } + } + + if (len!=0) + cout << endl; + + s.clear(); + } + else + { + // copy + if (withTimestamp) + cout << timestamp << "\t"; + cout << s << endl; + } + } + } + catch (exception &e) + { + cout.flush(); + cerr << "\n\tUnexpected exception :\n"; + cerr << "\t" << e.what() << endl; + exit(1); + } +} + diff --git a/benchmarks/programs/seq-asprilo.sh b/benchmarks/programs/seq-asprilo.sh new file mode 100644 index 0000000..de1dabb --- /dev/null +++ b/benchmarks/programs/seq-asprilo.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# http://www.cril.univ-artois.fr/~roussel/runsolver/ + +CAT="{run.root}/programs/gcat.sh" + +cd "$(dirname $0)" + +#top -n 1 -b > top.txt + +[[ -e .finished ]] || $CAT "{run.file}" | "{run.root}/runsolver-3.4.0/runsolver/src/runsolver" \ + -M 20000 \ + -w runsolver.watcher \ + -o runsolver.solver \ + -W {run.timeout} \ + "{run.root}/programs/{run.solver}" {run.root} {run.file} {run.args} + +touch .finished + diff --git a/benchmarks/programs/seq-elevator.sh b/benchmarks/programs/seq-elevator.sh new file mode 100644 index 0000000..de1dabb --- /dev/null +++ b/benchmarks/programs/seq-elevator.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# http://www.cril.univ-artois.fr/~roussel/runsolver/ + +CAT="{run.root}/programs/gcat.sh" + +cd "$(dirname $0)" + +#top -n 1 -b > top.txt + +[[ -e .finished ]] || $CAT "{run.file}" | "{run.root}/runsolver-3.4.0/runsolver/src/runsolver" \ + -M 20000 \ + -w runsolver.watcher \ + -o runsolver.solver \ + -W {run.timeout} \ + "{run.root}/programs/{run.solver}" {run.root} {run.file} {run.args} + +touch .finished + diff --git a/benchmarks/results/asprilo-abc/afw__h-24__n-1/afw__h-24__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-24__n-1/afw__h-24__n-1.beval new file mode 100644 index 0000000..48c41e8 --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-24__n-1/afw__h-24__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-24__n-1/afw__h-24__n-1.error b/benchmarks/results/asprilo-abc/afw__h-24__n-1/afw__h-24__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/afw__h-25__n-1/afw__h-25__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-25__n-1/afw__h-25__n-1.beval new file mode 100644 index 0000000..bf10821 --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-25__n-1/afw__h-25__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-25__n-1/afw__h-25__n-1.error b/benchmarks/results/asprilo-abc/afw__h-25__n-1/afw__h-25__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/afw__h-26__n-1/afw__h-26__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-26__n-1/afw__h-26__n-1.beval new file mode 100644 index 0000000..8b4ebdd --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-26__n-1/afw__h-26__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-26__n-1/afw__h-26__n-1.error b/benchmarks/results/asprilo-abc/afw__h-26__n-1/afw__h-26__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/afw__h-27__n-1/afw__h-27__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-27__n-1/afw__h-27__n-1.beval new file mode 100644 index 0000000..5bd4ffa --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-27__n-1/afw__h-27__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-27__n-1/afw__h-27__n-1.error b/benchmarks/results/asprilo-abc/afw__h-27__n-1/afw__h-27__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/afw__h-28__n-1/afw__h-28__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-28__n-1/afw__h-28__n-1.beval new file mode 100644 index 0000000..7d620df --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-28__n-1/afw__h-28__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-28__n-1/afw__h-28__n-1.error b/benchmarks/results/asprilo-abc/afw__h-28__n-1/afw__h-28__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/afw__h-29__n-1/afw__h-29__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-29__n-1/afw__h-29__n-1.beval new file mode 100644 index 0000000..bf45d24 --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-29__n-1/afw__h-29__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-29__n-1/afw__h-29__n-1.error b/benchmarks/results/asprilo-abc/afw__h-29__n-1/afw__h-29__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/afw__h-30__n-1/afw__h-30__n-1.beval b/benchmarks/results/asprilo-abc/afw__h-30__n-1/afw__h-30__n-1.beval new file mode 100644 index 0000000..4848b6f --- /dev/null +++ b/benchmarks/results/asprilo-abc/afw__h-30__n-1/afw__h-30__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/afw__h-30__n-1/afw__h-30__n-1.error b/benchmarks/results/asprilo-abc/afw__h-30__n-1/afw__h-30__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.beval new file mode 100644 index 0000000..70a7fd8 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.error new file mode 100644 index 0000000..8f979a1 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-24__n-1/dfa-mso__h-24__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-24__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-24__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.beval new file mode 100644 index 0000000..46b855d --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.error new file mode 100644 index 0000000..66b18ea --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-25__n-1/dfa-mso__h-25__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-25__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-25__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.beval new file mode 100644 index 0000000..7689d3d --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.error new file mode 100644 index 0000000..14f01e9 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-26__n-1/dfa-mso__h-26__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-26__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-26__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.beval new file mode 100644 index 0000000..4390ecb --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.error new file mode 100644 index 0000000..9ed79d6 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-27__n-1/dfa-mso__h-27__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-27__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-27__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.beval new file mode 100644 index 0000000..410612d --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.error new file mode 100644 index 0000000..fd4674e --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-28__n-1/dfa-mso__h-28__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-28__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-28__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.beval new file mode 100644 index 0000000..78a8380 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.error new file mode 100644 index 0000000..c47f358 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-29__n-1/dfa-mso__h-29__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-29__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-29__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.beval b/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.beval new file mode 100644 index 0000000..b923a2d --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.error b/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.error new file mode 100644 index 0000000..a91ba5a --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-mso__h-30__n-1/dfa-mso__h-30__n-1.error @@ -0,0 +1,2 @@ +*** ERROR: Run output/asprilo-abc/dfa-mso__h-30__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp/run1 failed with unrecognized status or error! +*** ERROR: Run output/asprilo-abc/dfa-mso__h-30__n-1/temporal-automata/komputer/results/asprilo-abc-benchmark/general_compute-1-d3/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp/run1 failed with unrecognized status or error! diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-24__n-1/dfa-stm__h-24__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-24__n-1/dfa-stm__h-24__n-1.beval new file mode 100644 index 0000000..ac61832 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-24__n-1/dfa-stm__h-24__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-24__n-1/dfa-stm__h-24__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-24__n-1/dfa-stm__h-24__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-25__n-1/dfa-stm__h-25__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-25__n-1/dfa-stm__h-25__n-1.beval new file mode 100644 index 0000000..cd08adb --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-25__n-1/dfa-stm__h-25__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-25__n-1/dfa-stm__h-25__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-25__n-1/dfa-stm__h-25__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-26__n-1/dfa-stm__h-26__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-26__n-1/dfa-stm__h-26__n-1.beval new file mode 100644 index 0000000..ca99199 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-26__n-1/dfa-stm__h-26__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-26__n-1/dfa-stm__h-26__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-26__n-1/dfa-stm__h-26__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-27__n-1/dfa-stm__h-27__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-27__n-1/dfa-stm__h-27__n-1.beval new file mode 100644 index 0000000..91b106b --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-27__n-1/dfa-stm__h-27__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-27__n-1/dfa-stm__h-27__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-27__n-1/dfa-stm__h-27__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-28__n-1/dfa-stm__h-28__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-28__n-1/dfa-stm__h-28__n-1.beval new file mode 100644 index 0000000..531c06e --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-28__n-1/dfa-stm__h-28__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-28__n-1/dfa-stm__h-28__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-28__n-1/dfa-stm__h-28__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-29__n-1/dfa-stm__h-29__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-29__n-1/dfa-stm__h-29__n-1.beval new file mode 100644 index 0000000..94a2504 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-29__n-1/dfa-stm__h-29__n-1.beval @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-29__n-1/dfa-stm__h-29__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-29__n-1/dfa-stm__h-29__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-30__n-1/dfa-stm__h-30__n-1.beval b/benchmarks/results/asprilo-abc/dfa-stm__h-30__n-1/dfa-stm__h-30__n-1.beval new file mode 100644 index 0000000..121ec88 --- /dev/null +++ b/benchmarks/results/asprilo-abc/dfa-stm__h-30__n-1/dfa-stm__h-30__n-1.beval @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/dfa-stm__h-30__n-1/dfa-stm__h-30__n-1.error b/benchmarks/results/asprilo-abc/dfa-stm__h-30__n-1/dfa-stm__h-30__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-24__n-1/nc__h-24__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-24__n-1/nc__h-24__n-1.beval new file mode 100644 index 0000000..864660c --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-24__n-1/nc__h-24__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-24__n-1/nc__h-24__n-1.error b/benchmarks/results/asprilo-abc/nc__h-24__n-1/nc__h-24__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-25__n-1/nc__h-25__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-25__n-1/nc__h-25__n-1.beval new file mode 100644 index 0000000..40a6520 --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-25__n-1/nc__h-25__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-25__n-1/nc__h-25__n-1.error b/benchmarks/results/asprilo-abc/nc__h-25__n-1/nc__h-25__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-26__n-1/nc__h-26__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-26__n-1/nc__h-26__n-1.beval new file mode 100644 index 0000000..d4ca12b --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-26__n-1/nc__h-26__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-26__n-1/nc__h-26__n-1.error b/benchmarks/results/asprilo-abc/nc__h-26__n-1/nc__h-26__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-27__n-1/nc__h-27__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-27__n-1/nc__h-27__n-1.beval new file mode 100644 index 0000000..b26a1ba --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-27__n-1/nc__h-27__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-27__n-1/nc__h-27__n-1.error b/benchmarks/results/asprilo-abc/nc__h-27__n-1/nc__h-27__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-28__n-1/nc__h-28__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-28__n-1/nc__h-28__n-1.beval new file mode 100644 index 0000000..90ecea8 --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-28__n-1/nc__h-28__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-28__n-1/nc__h-28__n-1.error b/benchmarks/results/asprilo-abc/nc__h-28__n-1/nc__h-28__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-29__n-1/nc__h-29__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-29__n-1/nc__h-29__n-1.beval new file mode 100644 index 0000000..fea8bf0 --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-29__n-1/nc__h-29__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-29__n-1/nc__h-29__n-1.error b/benchmarks/results/asprilo-abc/nc__h-29__n-1/nc__h-29__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/nc__h-30__n-1/nc__h-30__n-1.beval b/benchmarks/results/asprilo-abc/nc__h-30__n-1/nc__h-30__n-1.beval new file mode 100644 index 0000000..6f30fd7 --- /dev/null +++ b/benchmarks/results/asprilo-abc/nc__h-30__n-1/nc__h-30__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/nc__h-30__n-1/nc__h-30__n-1.error b/benchmarks/results/asprilo-abc/nc__h-30__n-1/nc__h-30__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/summary.txt b/benchmarks/results/asprilo-abc/summary.txt new file mode 100644 index 0000000..5bf87db --- /dev/null +++ b/benchmarks/results/asprilo-abc/summary.txt @@ -0,0 +1,27 @@ +-------------------- +Summary +-------------------- +Successful: + all-afw__h-13__n-0 + all-dfa-mso__h-13__n-0 + all-dfa-mso__h-12__n-0 + all-dfa-stm__h-14__n-0 + all-telingo__h-13__n-0 + all-dfa-stm__h-12__n-0 + all-telingo__h-14__n-0 + all-telingo__h-12__n-0 + all-nc__h-12__n-0 + all-afw__h-14__n-0 + all-nc__h-13__n-0 + all-dfa-mso__h-14__n-0 + all-dfa-stm__h-13__n-0 + all-nc__h-14__n-0 + all-afw__h-12__n-0 +Error: + dfa-mso__h-28__n-1 + dfa-mso__h-24__n-1 + dfa-mso__h-25__n-1 + dfa-mso__h-30__n-1 + dfa-mso__h-26__n-1 + dfa-mso__h-29__n-1 + dfa-mso__h-27__n-1 diff --git a/benchmarks/results/asprilo-abc/telingo__h-24__n-1/telingo__h-24__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-24__n-1/telingo__h-24__n-1.beval new file mode 100644 index 0000000..774c585 --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-24__n-1/telingo__h-24__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-24__n-1/telingo__h-24__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-24__n-1/telingo__h-24__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/telingo__h-25__n-1/telingo__h-25__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-25__n-1/telingo__h-25__n-1.beval new file mode 100644 index 0000000..5c0b971 --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-25__n-1/telingo__h-25__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-25__n-1/telingo__h-25__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-25__n-1/telingo__h-25__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/telingo__h-26__n-1/telingo__h-26__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-26__n-1/telingo__h-26__n-1.beval new file mode 100644 index 0000000..9eb68db --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-26__n-1/telingo__h-26__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-26__n-1/telingo__h-26__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-26__n-1/telingo__h-26__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/telingo__h-27__n-1/telingo__h-27__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-27__n-1/telingo__h-27__n-1.beval new file mode 100644 index 0000000..f7407e2 --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-27__n-1/telingo__h-27__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-27__n-1/telingo__h-27__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-27__n-1/telingo__h-27__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/telingo__h-28__n-1/telingo__h-28__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-28__n-1/telingo__h-28__n-1.beval new file mode 100644 index 0000000..3110e65 --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-28__n-1/telingo__h-28__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-28__n-1/telingo__h-28__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-28__n-1/telingo__h-28__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/telingo__h-29__n-1/telingo__h-29__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-29__n-1/telingo__h-29__n-1.beval new file mode 100644 index 0000000..3cf030a --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-29__n-1/telingo__h-29__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-29__n-1/telingo__h-29__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-29__n-1/telingo__h-29__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/asprilo-abc/telingo__h-30__n-1/telingo__h-30__n-1.beval b/benchmarks/results/asprilo-abc/telingo__h-30__n-1/telingo__h-30__n-1.beval new file mode 100644 index 0000000..c418fb0 --- /dev/null +++ b/benchmarks/results/asprilo-abc/telingo__h-30__n-1/telingo__h-30__n-1.beval @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/results/asprilo-abc/telingo__h-30__n-1/telingo__h-30__n-1.error b/benchmarks/results/asprilo-abc/telingo__h-30__n-1/telingo__h-30__n-1.error new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv new file mode 100644 index 0000000..2101ea5 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv @@ -0,0 +1,5 @@ +,dfa-stm,afw,dfa-mso +final_state,8,0,8 +initial_state,8,8,8 +state,32,16,32 +delta,104,72,104 diff --git a/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex new file mode 100644 index 0000000..7a08378 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex @@ -0,0 +1,10 @@ +\begin{tabular}{lrrr} +\toprule +{} & dfa-stm & afw & dfa-mso \\ +\midrule +final\_state & 8 & 0 & 8 \\ +initial\_state & 8 & 8 & 8 \\ +state & 32 & 16 & 32 \\ +delta & 104 & 72 & 104 \\ +\bottomrule +\end{tabular} diff --git a/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv new file mode 100644 index 0000000..86843f6 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv @@ -0,0 +1,5 @@ +,dfa-stm,afw,dfa-mso +final_state,18,0,18 +initial_state,18,18,18 +state,72,36,72 +delta,216,162,234 diff --git a/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex new file mode 100644 index 0000000..d3fed53 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d1/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex @@ -0,0 +1,10 @@ +\begin{tabular}{lrrr} +\toprule +{} & dfa-stm & afw & dfa-mso \\ +\midrule +final\_state & 18 & 0 & 18 \\ +initial\_state & 18 & 18 & 18 \\ +state & 72 & 36 & 72 \\ +delta & 216 & 162 & 234 \\ +\bottomrule +\end{tabular} diff --git a/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv new file mode 100644 index 0000000..fed5500 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv @@ -0,0 +1,5 @@ +,dfa-stm,afw,dfa-mso +final_state,16,0,16 +initial_state,2,2,2 +state,34,16,34 +delta,288,40,260 diff --git a/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex new file mode 100644 index 0000000..665eb3f --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex @@ -0,0 +1,10 @@ +\begin{tabular}{lrrr} +\toprule +{} & dfa-stm & afw & dfa-mso \\ +\midrule +final\_state & 16 & 0 & 16 \\ +initial\_state & 2 & 2 & 2 \\ +state & 34 & 16 & 34 \\ +delta & 288 & 40 & 260 \\ +\bottomrule +\end{tabular} diff --git a/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv new file mode 100644 index 0000000..64a82ec --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv @@ -0,0 +1,5 @@ +,dfa-stm,afw,dfa-mso +final_state,24,0,24 +initial_state,3,3,3 +state,51,24,51 +delta,471,60,390 diff --git a/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex new file mode 100644 index 0000000..4c956ae --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d2/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex @@ -0,0 +1,10 @@ +\begin{tabular}{lrrr} +\toprule +{} & dfa-stm & afw & dfa-mso \\ +\midrule +final\_state & 24 & 0 & 24 \\ +initial\_state & 3 & 3 & 3 \\ +state & 51 & 24 & 51 \\ +delta & 471 & 60 & 390 \\ +\bottomrule +\end{tabular} diff --git a/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv new file mode 100644 index 0000000..c14bc85 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.csv @@ -0,0 +1,5 @@ +,dfa-stm,afw +final_state,46,0 +initial_state,2,2 +state,248,30 +delta,19832,126 diff --git a/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex new file mode 100644 index 0000000..3a93b1d --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001/size.tex @@ -0,0 +1,10 @@ +\begin{tabular}{lrr} +\toprule +{} & dfa-stm & afw \\ +\midrule +final\_state & 46 & 0 \\ +initial\_state & 2 & 2 \\ +state & 248 & 30 \\ +delta & 19832 & 126 \\ +\bottomrule +\end{tabular} diff --git a/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv new file mode 100644 index 0000000..854557a --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.csv @@ -0,0 +1,5 @@ +,dfa-stm,afw +final_state,69,0 +initial_state,3,3 +state,372,45 +delta,16503,189 diff --git a/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex new file mode 100644 index 0000000..04ac386 --- /dev/null +++ b/benchmarks/results/tables/asprilo-abc/d3/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001/size.tex @@ -0,0 +1,10 @@ +\begin{tabular}{lrr} +\toprule +{} & dfa-stm & afw \\ +\midrule +final\_state & 69 & 0 \\ +initial\_state & 3 & 3 \\ +state & 372 & 45 \\ +delta & 16503 & 189 \\ +\bottomrule +\end{tabular} diff --git a/benchmarks/run_bm.sh b/benchmarks/run_bm.sh new file mode 100755 index 0000000..c495c59 --- /dev/null +++ b/benchmarks/run_bm.sh @@ -0,0 +1,149 @@ +#!/bin/bash +R=`tput setaf 1` +G=`tput setaf 2` +Y=`tput setaf 3` +B=`tput setaf 5` +C=`tput setaf 6` +NC=`tput sgr0` + +set -e +export PATH="$HOME/temporal-automata/stage_asp_gitlab/tools/MONA/Front:$PATH" + +DOM=$1 +APPROACH=$2 +HORIZON=$3 +MODELS=$4 +PREFIX=$5 +CLINGO_ARGS=$6 +: ${CLINGO_ARGS:=''} +: ${PREFIX:=''} + + +NAME=${PREFIX}${APPROACH}__h-${HORIZON}__n-${MODELS} + +MACHINE=komputer # Value in $RUNSCRIPT_PATH + + +# Results directory +echo "$Y Removing old result directory $NC" +mkdir -p $dir/results/$DOM +RES_DIR=$dir/results/$DOM/$NAME +rm -rf $RES_DIR +mkdir -p $RES_DIR + +# Move to benchmark tool +echo "$Y Moving to benchmarks-tool directory " +echo "$B $BT_PATH $NC" +cd $BT_PATH + + +#Output directory inside benchmark-tool is the value in +OUTPUT_DIR=output/$DOM/${APPROACH}__h-${HORIZON}__n-${MODELS}/$PROJECT +echo "$Y Calling ./bgen$NC" +./bgen $RUNSCRIPT_PATH + +#Running start file +if [ "$mode" = "py" ]; then + echo "$Y Running python start file " + echo "$B $BT_PATH/$OUTPUT_DIR/$MACHINE/start.py $NC" + ./$OUTPUT_DIR/$MACHINE/start.py + echo "Python done " +else + echo "$Y Running sh start file " + echo "$B $BT_PATH/$OUTPUT_DIR/$MACHINE/start.sh $NC" + ./$OUTPUT_DIR/$MACHINE/start.sh + sleep 3 + SEC=0 + while squeue | grep -q $USERNAME; do + if !(( $SEC % 5 )); then + echo "$B Waiting for all slurm process to finish..." + fi + sleep 1 + SEC=($SEC+1) + done + echo "$G Slurm queue is now empty $NC" +fi + + +# Clean outputs in runsuolver.solver and check errors +for f in $(find ./$OUTPUT_DIR/$MACHINE/results/$DOM-benchmark -type f -name "*runsolver.solver"); +do + if grep -q 'fail' $f; then + if grep -q 'INTERRUPTED' $f; then + # echo "$R Found word failed in file $f$NC" + # cat $f + # cat $f > $RES_DIR/$NAME.error + # exit 1 + echo "$B TIMEOUT: $f" + fi + else + #Ignore the rest of the resut and saave only stats + #echo $f + echo "$(tail -34 $f)" > $f + fi +done + +# Get evealuation from runsolver results +echo "$Y beval...$NC" +if ! ./beval $RUNSCRIPT_PATH > $RES_DIR/$NAME.beval 2> $RES_DIR/$NAME.error ; then + # Analize errors during evaluation + echo "$R Error during evaluation" + cat $RES_DIR/$NAME.error + echo "$NC" + exit 1 +fi + +# Analize eval error when reading a strange runsolver.solver file +grep 'failed with unrecognized status or error!' $RES_DIR/$NAME.error | head -1 | sed -e 's#.*Run \(\)#\1#' | sed -e 's# failed.*\(\)#\1#' > fault_runsolver.txt +LINE_ERR=$(cat fault_runsolver.txt) +if [ ! -z $LINE_ERR ] +then + echo "$R Found error inside output of runsolver" + LINE_ERR=$LINE_ERR/runsolver.solver + echo $LINE_ERR + cat $LINE_ERR + echo "$NC" + #exit 1 +fi + +echo "$G Evaluation results saved in " +echo "$B $RES_DIR/$NAME.beval$NC" + +################ Clean beval output an generate ods file +sed -i 's/partition="short" partition="short"/partition="short"/g' $RES_DIR/$NAME.beval + + +echo "$G Done $NAME$NC" + diff --git a/benchmarks/runscripts/runscript_asprilo-md.xml b/benchmarks/runscripts/runscript_asprilo-md.xml new file mode 100755 index 0000000..5262c66 --- /dev/null +++ b/benchmarks/runscripts/runscript_asprilo-md.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/runscripts/runscript_cl_asprilo-abc.xml b/benchmarks/runscripts/runscript_cl_asprilo-abc.xml new file mode 100755 index 0000000..eba2ef0 --- /dev/null +++ b/benchmarks/runscripts/runscript_cl_asprilo-abc.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/runscripts/runscript_elevator.xml b/benchmarks/runscripts/runscript_elevator.xml new file mode 100755 index 0000000..19c19e8 --- /dev/null +++ b/benchmarks/runscripts/runscript_elevator.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/runscripts/runscript_hanoi.xml b/benchmarks/runscripts/runscript_hanoi.xml new file mode 100755 index 0000000..d0098c8 --- /dev/null +++ b/benchmarks/runscripts/runscript_hanoi.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/runscripts/runscript_py_asprilo-abc.xml b/benchmarks/runscripts/runscript_py_asprilo-abc.xml new file mode 100755 index 0000000..e2326d8 --- /dev/null +++ b/benchmarks/runscripts/runscript_py_asprilo-abc.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/size-table.py b/benchmarks/size-table.py new file mode 100644 index 0000000..c76d769 --- /dev/null +++ b/benchmarks/size-table.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# libraries and data +import sys +import pandas as pd +import os +import clingo +import argparse +parser = argparse.ArgumentParser(description='Get automata sizes',formatter_class=argparse.ArgumentDefaultsHelpFormatter) +parser.add_argument("--plot_type", type=str, default='bar', + help="Plot type, bar or line" ) +parser.add_argument("--approach", type=str, action='append', + help="Approach to be plotted awf, asp, nc or dfa. Can pass multiple") +parser.add_argument("--constraint", type=str, action='append', + help="Contraint to be plotted, if non is passed all constraints will be plotted. Can pass multiple") +parser.add_argument("--dom",type=str, default='asprilo-abc', + help="Name of domain, asprilo or elevator" ) +args = parser.parse_args() + +#PARAMS +approaches = args.approach +constraints = args.constraint +dom = args.dom + + + +directory= "../outputs" +# itrate over files in +# that directory +results = {} +def save(dom,app,cons,instance,model): + sizes = {} + for s in model.symbols(shown=True): + sizes[str(s.arguments[0])]=s.arguments[1].number + + name= f"{dom}/{cons}/{instance}" + results.setdefault(name,{}) + results[name][app]= sizes + +for root, dirs, files in os.walk(directory): + split_root = root.split("/") + if len(split_root)!=6: + continue + dom = split_root[2] + app = split_root[3] + cons = split_root[4] + instance = split_root[5] + automata_file_name =f"{app}_automata.lp" + if not automata_file_name in files: + print(f"No automata file for {root}") + continue + if app=="telingo": + continue + file_path = os.path.join(root, automata_file_name) + ctl = clingo.Control([0]) + ctl.load(file_path) + ctl.load("../encodings/size.lp") + ctl.ground([('base',[])]) + ctl.solve(on_model= lambda m: save(dom,app,cons,instance,m)) + + # print(dirs) + # print("") + # for filename in files: + # print(os.path.join(root, filename)) + + +for dom,val in results.items(): + file_name_csv = f'results/tables/{dom}/size.csv'.format(dom) + file_name_tex_csv = f'results/tables/{dom}/size.tex'.format(dom) + os.makedirs(os.path.dirname(f'results/tables/{dom}/size.csv'), exist_ok=True) + df = pd.DataFrame(val) + df.to_csv(file_name_csv,float_format='%.0f') + tex_table = df.to_latex(float_format='%.0f') + f = open(file_name_tex_csv, "w") + f.write(tex_table) + f.close() + print("Saved {}".format(file_name_csv)) + print("Saved {}".format(file_name_tex_csv)) + +# if args.table: +# file_name_csv = 'plots/tables/{}-{}.csv'.format(prefix,column) +# file_name_tex_csv = 'plots/tables/{}-{}.tex'.format(prefix,column) +# reduced_df = reduced_df.rename(index={idx:i for idx,i in enumerate(instances)}) + + +# # ELEVATOR +# table_df = pd.DataFrame(columns = args.approach, index=["h-{}".format(h) for h in horizons]) + +# for s in reduced_df.columns: +# s_split=s.split("__") +# # h= int(s_split[1].split("-")[1]) +# table_df[s_split[0]][s_split[1]]=reduced_df[s][0].astype(int) + +# table_df.to_csv(file_name_csv,float_format='%.0f') +# tex_table = table_df.to_latex(float_format='%.0f') + +# # reduced_df.to_csv(file_name_csv,float_format='%.0f') +# # tex_table = reduced_df.to_latex(float_format='%.0f') + + +# f = open(file_name_tex_csv, "w") +# f.write(tex_table) +# f.close() +# print("Saved {}".format(file_name_csv)) +# print("Saved {}".format(file_name_tex_csv)) + diff --git a/benchmarks/telingo b/benchmarks/telingo new file mode 160000 index 0000000..11d3daa --- /dev/null +++ b/benchmarks/telingo @@ -0,0 +1 @@ +Subproject commit 11d3daa35d9f8a97f466a33261a6c840cddef85a diff --git a/dom/asprilo-abc/extra.lp b/dom/asprilo-abc/extra.lp new file mode 100644 index 0000000..79578f7 --- /dev/null +++ b/dom/asprilo-abc/extra.lp @@ -0,0 +1,7 @@ + +move_atlingo(R,T):-move(R,D,T). +pickup_atlingo(R,T):-pickup(R,S,T). +putdown_atlingo(R,T):-putdown(R,S,T). +carries_atlingo(R,T):-carries(R,S,T). +process_atlingo(R,T):-process(S,T),carries(R,S,T-1). +process_atlingo(R,S,T):-process(S,T),carries(R,S,T-1). \ No newline at end of file diff --git a/dom/asprilo-abc/glue.lp b/dom/asprilo-abc/glue.lp new file mode 100644 index 0000000..c51b3b6 --- /dev/null +++ b/dom/asprilo-abc/glue.lp @@ -0,0 +1,24 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Mapping for atoms into holds predicate +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Actions start at time point 1!!! + + +% One rule for each type of predicate used in the formula +trace(ID,T) :- move_atlingo(robot(N),T), prop(ID,("move_atlingo",("robot",N))). +trace(ID,T) :- pickup_atlingo(robot(N),T), prop(ID,("pickup_atlingo",("robot",N))). +trace(ID,T) :- putdown_atlingo(robot(N),T), prop(ID,("putdown_atlingo",("robot",N))). +trace(ID,T) :- carries_atlingo(robot(N),T), prop(ID,("carries_atlingo",("robot",N))). +trace(ID,T) :- process_atlingo(robot(N),T), prop(ID,("process_atlingo",("robot",N))). +trace(ID,T) :- process_atlingo(robot(N),shelf(S),T), prop(ID,("process_atlingo",("robot",N),("shelf",S))). + + +trace(ID,T) :- waits(robot(N),T), prop(ID,("waits",("robot",N))). +trace(ID,T) :- move(robot(N),(X,Y),T), prop(ID,("move",("robot",N),("",X,Y))). +trace(ID,T) :- pickup(robot(N),shelf(S),T), prop(ID,("pickup",("robot",N),("shelf",S))). +trace(ID,T) :- putdown(robot(N),shelf(S),T), prop(ID,("putdown",("robot",N),("shelf",S))). + + +% trace(ID,T) :- move(robot(N),T),prop(ID,("move",("robot",N),(X,Y))). diff --git a/dom/asprilo-abc/instances/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp b/dom/asprilo-abc/instances/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp new file mode 100644 index 0000000..d72020e --- /dev/null +++ b/dom/asprilo-abc/instances/robots/x7_y7_n49_r2_s4_ps2_pr4_u4_o4_l4_N001.lp @@ -0,0 +1,129 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% = Command-line Arguments ================================= +% -x 7 -y 7 -s 4 -p 2 -r 2 -H -P 4 -u 4 -o 4 -d dom/asprilo-abc/instances --spr 1 --prs 1 +% +% = Instance Statistics ==================================== +% Grid Size X: 7 +% Grid Size Y: 7 +% Number of Nodes: 49 +% Number of Highway Nodes: 37 +% Number of Robots: 2 +% Number of Shelves: 4 +% Number of Picking Stations: 2 +% Number of Products: 4 +% Number of Product Units in Total: 4 +% Number of Orders: 4 +% Number of Orders Lines: 4 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#program base. + +% init +init(object(highway,1),value(at,(1,1))). +init(object(highway,2),value(at,(2,1))). +init(object(highway,4),value(at,(4,1))). +init(object(highway,5),value(at,(5,1))). +init(object(highway,7),value(at,(7,1))). +init(object(highway,8),value(at,(1,2))). +init(object(highway,9),value(at,(2,2))). +init(object(highway,10),value(at,(3,2))). +init(object(highway,11),value(at,(4,2))). +init(object(highway,12),value(at,(5,2))). +init(object(highway,13),value(at,(6,2))). +init(object(highway,14),value(at,(7,2))). +init(object(highway,15),value(at,(1,3))). +init(object(highway,18),value(at,(4,3))). +init(object(highway,21),value(at,(7,3))). +init(object(highway,22),value(at,(1,4))). +init(object(highway,25),value(at,(4,4))). +init(object(highway,28),value(at,(7,4))). +init(object(highway,29),value(at,(1,5))). +init(object(highway,30),value(at,(2,5))). +init(object(highway,31),value(at,(3,5))). +init(object(highway,32),value(at,(4,5))). +init(object(highway,33),value(at,(5,5))). +init(object(highway,34),value(at,(6,5))). +init(object(highway,35),value(at,(7,5))). +init(object(highway,36),value(at,(1,6))). +init(object(highway,37),value(at,(2,6))). +init(object(highway,38),value(at,(3,6))). +init(object(highway,39),value(at,(4,6))). +init(object(highway,40),value(at,(5,6))). +init(object(highway,41),value(at,(6,6))). +init(object(highway,42),value(at,(7,6))). +init(object(highway,45),value(at,(3,7))). +init(object(highway,46),value(at,(4,7))). +init(object(highway,47),value(at,(5,7))). +init(object(highway,48),value(at,(6,7))). +init(object(highway,49),value(at,(7,7))). +init(object(node,1),value(at,(1,1))). +init(object(node,2),value(at,(2,1))). +init(object(node,3),value(at,(3,1))). +init(object(node,4),value(at,(4,1))). +init(object(node,5),value(at,(5,1))). +init(object(node,6),value(at,(6,1))). +init(object(node,7),value(at,(7,1))). +init(object(node,8),value(at,(1,2))). +init(object(node,9),value(at,(2,2))). +init(object(node,10),value(at,(3,2))). +init(object(node,11),value(at,(4,2))). +init(object(node,12),value(at,(5,2))). +init(object(node,13),value(at,(6,2))). +init(object(node,14),value(at,(7,2))). +init(object(node,15),value(at,(1,3))). +init(object(node,16),value(at,(2,3))). +init(object(node,17),value(at,(3,3))). +init(object(node,18),value(at,(4,3))). +init(object(node,19),value(at,(5,3))). +init(object(node,20),value(at,(6,3))). +init(object(node,21),value(at,(7,3))). +init(object(node,22),value(at,(1,4))). +init(object(node,23),value(at,(2,4))). +init(object(node,24),value(at,(3,4))). +init(object(node,25),value(at,(4,4))). +init(object(node,26),value(at,(5,4))). +init(object(node,27),value(at,(6,4))). +init(object(node,28),value(at,(7,4))). +init(object(node,29),value(at,(1,5))). +init(object(node,30),value(at,(2,5))). +init(object(node,31),value(at,(3,5))). +init(object(node,32),value(at,(4,5))). +init(object(node,33),value(at,(5,5))). +init(object(node,34),value(at,(6,5))). +init(object(node,35),value(at,(7,5))). +init(object(node,36),value(at,(1,6))). +init(object(node,37),value(at,(2,6))). +init(object(node,38),value(at,(3,6))). +init(object(node,39),value(at,(4,6))). +init(object(node,40),value(at,(5,6))). +init(object(node,41),value(at,(6,6))). +init(object(node,42),value(at,(7,6))). +init(object(node,43),value(at,(1,7))). +init(object(node,44),value(at,(2,7))). +init(object(node,45),value(at,(3,7))). +init(object(node,46),value(at,(4,7))). +init(object(node,47),value(at,(5,7))). +init(object(node,48),value(at,(6,7))). +init(object(node,49),value(at,(7,7))). +init(object(order,1),value(line,(3,1))). +init(object(order,1),value(pickingStation,1)). +init(object(order,2),value(line,(2,1))). +init(object(order,2),value(pickingStation,2)). +init(object(order,3),value(line,(1,1))). +init(object(order,3),value(pickingStation,2)). +init(object(order,4),value(line,(4,1))). +init(object(order,4),value(pickingStation,1)). +init(object(pickingStation,1),value(at,(3,1))). +init(object(pickingStation,2),value(at,(6,1))). +init(object(product,1),value(on,(3,1))). +init(object(product,2),value(on,(4,1))). +init(object(product,3),value(on,(1,1))). +init(object(product,4),value(on,(2,1))). +init(object(robot,1),value(at,(1,7))). +init(object(robot,2),value(at,(2,7))). +init(object(shelf,1),value(at,(3,3))). +init(object(shelf,2),value(at,(2,4))). +init(object(shelf,3),value(at,(3,4))). +init(object(shelf,4),value(at,(5,4))). diff --git a/dom/asprilo-abc/instances/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp b/dom/asprilo-abc/instances/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp new file mode 100644 index 0000000..0c32f73 --- /dev/null +++ b/dom/asprilo-abc/instances/robots/x7_y7_n49_r3_s6_ps3_pr6_u6_o6_l6_N001.lp @@ -0,0 +1,137 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% = Command-line Arguments ================================= +% -d dom/asprilo-abc/instances -x 7 -y 7 -s 6 -p 3 -r 3 -H -P 6 -u 6 -o 6 --spr 1 --prs 1 +% +% = Instance Statistics ==================================== +% Grid Size X: 7 +% Grid Size Y: 7 +% Number of Nodes: 49 +% Number of Highway Nodes: 35 +% Number of Robots: 3 +% Number of Shelves: 6 +% Number of Picking Stations: 3 +% Number of Products: 6 +% Number of Product Units in Total: 6 +% Number of Orders: 6 +% Number of Orders Lines: 6 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#program base. + +% init +init(object(highway,1),value(at,(1,1))). +init(object(highway,3),value(at,(3,1))). +init(object(highway,5),value(at,(5,1))). +init(object(highway,7),value(at,(7,1))). +init(object(highway,8),value(at,(1,2))). +init(object(highway,9),value(at,(2,2))). +init(object(highway,10),value(at,(3,2))). +init(object(highway,11),value(at,(4,2))). +init(object(highway,12),value(at,(5,2))). +init(object(highway,13),value(at,(6,2))). +init(object(highway,14),value(at,(7,2))). +init(object(highway,15),value(at,(1,3))). +init(object(highway,18),value(at,(4,3))). +init(object(highway,21),value(at,(7,3))). +init(object(highway,22),value(at,(1,4))). +init(object(highway,25),value(at,(4,4))). +init(object(highway,28),value(at,(7,4))). +init(object(highway,29),value(at,(1,5))). +init(object(highway,30),value(at,(2,5))). +init(object(highway,31),value(at,(3,5))). +init(object(highway,32),value(at,(4,5))). +init(object(highway,33),value(at,(5,5))). +init(object(highway,34),value(at,(6,5))). +init(object(highway,35),value(at,(7,5))). +init(object(highway,36),value(at,(1,6))). +init(object(highway,37),value(at,(2,6))). +init(object(highway,38),value(at,(3,6))). +init(object(highway,39),value(at,(4,6))). +init(object(highway,40),value(at,(5,6))). +init(object(highway,41),value(at,(6,6))). +init(object(highway,42),value(at,(7,6))). +init(object(highway,46),value(at,(4,7))). +init(object(highway,47),value(at,(5,7))). +init(object(highway,48),value(at,(6,7))). +init(object(highway,49),value(at,(7,7))). +init(object(node,1),value(at,(1,1))). +init(object(node,2),value(at,(2,1))). +init(object(node,3),value(at,(3,1))). +init(object(node,4),value(at,(4,1))). +init(object(node,5),value(at,(5,1))). +init(object(node,6),value(at,(6,1))). +init(object(node,7),value(at,(7,1))). +init(object(node,8),value(at,(1,2))). +init(object(node,9),value(at,(2,2))). +init(object(node,10),value(at,(3,2))). +init(object(node,11),value(at,(4,2))). +init(object(node,12),value(at,(5,2))). +init(object(node,13),value(at,(6,2))). +init(object(node,14),value(at,(7,2))). +init(object(node,15),value(at,(1,3))). +init(object(node,16),value(at,(2,3))). +init(object(node,17),value(at,(3,3))). +init(object(node,18),value(at,(4,3))). +init(object(node,19),value(at,(5,3))). +init(object(node,20),value(at,(6,3))). +init(object(node,21),value(at,(7,3))). +init(object(node,22),value(at,(1,4))). +init(object(node,23),value(at,(2,4))). +init(object(node,24),value(at,(3,4))). +init(object(node,25),value(at,(4,4))). +init(object(node,26),value(at,(5,4))). +init(object(node,27),value(at,(6,4))). +init(object(node,28),value(at,(7,4))). +init(object(node,29),value(at,(1,5))). +init(object(node,30),value(at,(2,5))). +init(object(node,31),value(at,(3,5))). +init(object(node,32),value(at,(4,5))). +init(object(node,33),value(at,(5,5))). +init(object(node,34),value(at,(6,5))). +init(object(node,35),value(at,(7,5))). +init(object(node,36),value(at,(1,6))). +init(object(node,37),value(at,(2,6))). +init(object(node,38),value(at,(3,6))). +init(object(node,39),value(at,(4,6))). +init(object(node,40),value(at,(5,6))). +init(object(node,41),value(at,(6,6))). +init(object(node,42),value(at,(7,6))). +init(object(node,43),value(at,(1,7))). +init(object(node,44),value(at,(2,7))). +init(object(node,45),value(at,(3,7))). +init(object(node,46),value(at,(4,7))). +init(object(node,47),value(at,(5,7))). +init(object(node,48),value(at,(6,7))). +init(object(node,49),value(at,(7,7))). +init(object(order,1),value(line,(2,1))). +init(object(order,1),value(pickingStation,1)). +init(object(order,2),value(line,(1,1))). +init(object(order,2),value(pickingStation,1)). +init(object(order,3),value(line,(4,1))). +init(object(order,3),value(pickingStation,1)). +init(object(order,4),value(line,(5,1))). +init(object(order,4),value(pickingStation,1)). +init(object(order,5),value(line,(3,1))). +init(object(order,5),value(pickingStation,1)). +init(object(order,6),value(line,(6,1))). +init(object(order,6),value(pickingStation,1)). +init(object(pickingStation,1),value(at,(2,1))). +init(object(pickingStation,2),value(at,(4,1))). +init(object(pickingStation,3),value(at,(6,1))). +init(object(product,1),value(on,(5,1))). +init(object(product,2),value(on,(3,1))). +init(object(product,3),value(on,(6,1))). +init(object(product,4),value(on,(2,1))). +init(object(product,5),value(on,(1,1))). +init(object(product,6),value(on,(4,1))). +init(object(robot,1),value(at,(1,7))). +init(object(robot,2),value(at,(2,7))). +init(object(robot,3),value(at,(3,7))). +init(object(shelf,1),value(at,(2,3))). +init(object(shelf,2),value(at,(3,3))). +init(object(shelf,3),value(at,(5,3))). +init(object(shelf,4),value(at,(6,3))). +init(object(shelf,5),value(at,(2,4))). +init(object(shelf,6),value(at,(3,4))). diff --git a/dom/asprilo-abc/instances/small/x5_y5_n25_r1_s1_ps1_pr1_u1_o1_l1_N001.lp b/dom/asprilo-abc/instances/small/x5_y5_n25_r1_s1_ps1_pr1_u1_o1_l1_N001.lp new file mode 100644 index 0000000..05bf69d --- /dev/null +++ b/dom/asprilo-abc/instances/small/x5_y5_n25_r1_s1_ps1_pr1_u1_o1_l1_N001.lp @@ -0,0 +1,75 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% = Command-line Arguments ================================= +% -x 5 -y 5 -s 1 -p 1 -r 1 -P 1 -u 1 -o 1 -H +% +% = Instance Statistics ==================================== +% Grid Size X: 5 +% Grid Size Y: 5 +% Number of Nodes: 25 +% Number of Highway Nodes: 21 +% Number of Robots: 1 +% Number of Shelves: 1 +% Number of Picking Stations: 1 +% Number of Products: 1 +% Number of Product Units in Total: 1 +% Number of Orders: 1 +% Number of Orders Lines: 1 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#program base. + +% init +init(object(highway,1),value(at,(1,1))). +init(object(highway,2),value(at,(2,1))). +init(object(highway,4),value(at,(4,1))). +init(object(highway,5),value(at,(5,1))). +init(object(highway,6),value(at,(1,2))). +init(object(highway,7),value(at,(2,2))). +init(object(highway,8),value(at,(3,2))). +init(object(highway,9),value(at,(4,2))). +init(object(highway,10),value(at,(5,2))). +init(object(highway,11),value(at,(1,3))). +init(object(highway,14),value(at,(4,3))). +init(object(highway,15),value(at,(5,3))). +init(object(highway,16),value(at,(1,4))). +init(object(highway,17),value(at,(2,4))). +init(object(highway,18),value(at,(3,4))). +init(object(highway,19),value(at,(4,4))). +init(object(highway,20),value(at,(5,4))). +init(object(highway,22),value(at,(2,5))). +init(object(highway,23),value(at,(3,5))). +init(object(highway,24),value(at,(4,5))). +init(object(highway,25),value(at,(5,5))). +init(object(node,1),value(at,(1,1))). +init(object(node,2),value(at,(2,1))). +init(object(node,3),value(at,(3,1))). +init(object(node,4),value(at,(4,1))). +init(object(node,5),value(at,(5,1))). +init(object(node,6),value(at,(1,2))). +init(object(node,7),value(at,(2,2))). +init(object(node,8),value(at,(3,2))). +init(object(node,9),value(at,(4,2))). +init(object(node,10),value(at,(5,2))). +init(object(node,11),value(at,(1,3))). +init(object(node,12),value(at,(2,3))). +init(object(node,13),value(at,(3,3))). +init(object(node,14),value(at,(4,3))). +init(object(node,15),value(at,(5,3))). +init(object(node,16),value(at,(1,4))). +init(object(node,17),value(at,(2,4))). +init(object(node,18),value(at,(3,4))). +init(object(node,19),value(at,(4,4))). +init(object(node,20),value(at,(5,4))). +init(object(node,21),value(at,(1,5))). +init(object(node,22),value(at,(2,5))). +init(object(node,23),value(at,(3,5))). +init(object(node,24),value(at,(4,5))). +init(object(node,25),value(at,(5,5))). +init(object(order,1),value(line,(1,1))). +init(object(order,1),value(pickingStation,1)). +init(object(pickingStation,1),value(at,(3,1))). +init(object(product,1),value(on,(1,1))). +init(object(robot,1),value(at,(1,5))). +init(object(shelf,1),value(at,(3,3))). diff --git a/dom/asprilo-abc/instances/x7_y7_n49_r4_s8_ps4_pr8_u8_o8_l8_N001.lp b/dom/asprilo-abc/instances/x7_y7_n49_r4_s8_ps4_pr8_u8_o8_l8_N001.lp new file mode 100644 index 0000000..2bff1e5 --- /dev/null +++ b/dom/asprilo-abc/instances/x7_y7_n49_r4_s8_ps4_pr8_u8_o8_l8_N001.lp @@ -0,0 +1,145 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% = Command-line Arguments ================================= +% -d dom/asprilo-abc/instances -x 7 -y 7 -s 8 -p 4 -r 4 -H -P 8 -u 8 -o 8 --spr 1 --prs 1 +% +% = Instance Statistics ==================================== +% Grid Size X: 7 +% Grid Size Y: 7 +% Number of Nodes: 49 +% Number of Highway Nodes: 33 +% Number of Robots: 4 +% Number of Shelves: 8 +% Number of Picking Stations: 4 +% Number of Products: 8 +% Number of Product Units in Total: 8 +% Number of Orders: 8 +% Number of Orders Lines: 8 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#program base. + +% init +init(object(highway,2),value(at,(2,1))). +init(object(highway,4),value(at,(4,1))). +init(object(highway,6),value(at,(6,1))). +init(object(highway,8),value(at,(1,2))). +init(object(highway,9),value(at,(2,2))). +init(object(highway,10),value(at,(3,2))). +init(object(highway,11),value(at,(4,2))). +init(object(highway,12),value(at,(5,2))). +init(object(highway,13),value(at,(6,2))). +init(object(highway,14),value(at,(7,2))). +init(object(highway,15),value(at,(1,3))). +init(object(highway,18),value(at,(4,3))). +init(object(highway,21),value(at,(7,3))). +init(object(highway,22),value(at,(1,4))). +init(object(highway,25),value(at,(4,4))). +init(object(highway,28),value(at,(7,4))). +init(object(highway,29),value(at,(1,5))). +init(object(highway,30),value(at,(2,5))). +init(object(highway,31),value(at,(3,5))). +init(object(highway,32),value(at,(4,5))). +init(object(highway,33),value(at,(5,5))). +init(object(highway,34),value(at,(6,5))). +init(object(highway,35),value(at,(7,5))). +init(object(highway,36),value(at,(1,6))). +init(object(highway,37),value(at,(2,6))). +init(object(highway,38),value(at,(3,6))). +init(object(highway,39),value(at,(4,6))). +init(object(highway,40),value(at,(5,6))). +init(object(highway,41),value(at,(6,6))). +init(object(highway,42),value(at,(7,6))). +init(object(highway,47),value(at,(5,7))). +init(object(highway,48),value(at,(6,7))). +init(object(highway,49),value(at,(7,7))). +init(object(node,1),value(at,(1,1))). +init(object(node,2),value(at,(2,1))). +init(object(node,3),value(at,(3,1))). +init(object(node,4),value(at,(4,1))). +init(object(node,5),value(at,(5,1))). +init(object(node,6),value(at,(6,1))). +init(object(node,7),value(at,(7,1))). +init(object(node,8),value(at,(1,2))). +init(object(node,9),value(at,(2,2))). +init(object(node,10),value(at,(3,2))). +init(object(node,11),value(at,(4,2))). +init(object(node,12),value(at,(5,2))). +init(object(node,13),value(at,(6,2))). +init(object(node,14),value(at,(7,2))). +init(object(node,15),value(at,(1,3))). +init(object(node,16),value(at,(2,3))). +init(object(node,17),value(at,(3,3))). +init(object(node,18),value(at,(4,3))). +init(object(node,19),value(at,(5,3))). +init(object(node,20),value(at,(6,3))). +init(object(node,21),value(at,(7,3))). +init(object(node,22),value(at,(1,4))). +init(object(node,23),value(at,(2,4))). +init(object(node,24),value(at,(3,4))). +init(object(node,25),value(at,(4,4))). +init(object(node,26),value(at,(5,4))). +init(object(node,27),value(at,(6,4))). +init(object(node,28),value(at,(7,4))). +init(object(node,29),value(at,(1,5))). +init(object(node,30),value(at,(2,5))). +init(object(node,31),value(at,(3,5))). +init(object(node,32),value(at,(4,5))). +init(object(node,33),value(at,(5,5))). +init(object(node,34),value(at,(6,5))). +init(object(node,35),value(at,(7,5))). +init(object(node,36),value(at,(1,6))). +init(object(node,37),value(at,(2,6))). +init(object(node,38),value(at,(3,6))). +init(object(node,39),value(at,(4,6))). +init(object(node,40),value(at,(5,6))). +init(object(node,41),value(at,(6,6))). +init(object(node,42),value(at,(7,6))). +init(object(node,43),value(at,(1,7))). +init(object(node,44),value(at,(2,7))). +init(object(node,45),value(at,(3,7))). +init(object(node,46),value(at,(4,7))). +init(object(node,47),value(at,(5,7))). +init(object(node,48),value(at,(6,7))). +init(object(node,49),value(at,(7,7))). +init(object(order,1),value(line,(6,1))). +init(object(order,1),value(pickingStation,4)). +init(object(order,2),value(line,(3,1))). +init(object(order,2),value(pickingStation,4)). +init(object(order,3),value(line,(7,1))). +init(object(order,3),value(pickingStation,4)). +init(object(order,4),value(line,(5,1))). +init(object(order,4),value(pickingStation,4)). +init(object(order,5),value(line,(2,1))). +init(object(order,5),value(pickingStation,4)). +init(object(order,6),value(line,(8,1))). +init(object(order,6),value(pickingStation,4)). +init(object(order,7),value(line,(4,1))). +init(object(order,7),value(pickingStation,4)). +init(object(order,8),value(line,(1,1))). +init(object(order,8),value(pickingStation,4)). +init(object(pickingStation,1),value(at,(1,1))). +init(object(pickingStation,2),value(at,(3,1))). +init(object(pickingStation,3),value(at,(5,1))). +init(object(pickingStation,4),value(at,(7,1))). +init(object(product,1),value(on,(8,1))). +init(object(product,2),value(on,(3,1))). +init(object(product,3),value(on,(7,1))). +init(object(product,4),value(on,(6,1))). +init(object(product,5),value(on,(5,1))). +init(object(product,6),value(on,(2,1))). +init(object(product,7),value(on,(4,1))). +init(object(product,8),value(on,(1,1))). +init(object(robot,1),value(at,(1,7))). +init(object(robot,2),value(at,(2,7))). +init(object(robot,3),value(at,(3,7))). +init(object(robot,4),value(at,(4,7))). +init(object(shelf,1),value(at,(2,3))). +init(object(shelf,2),value(at,(3,3))). +init(object(shelf,3),value(at,(5,3))). +init(object(shelf,4),value(at,(6,3))). +init(object(shelf,5),value(at,(2,4))). +init(object(shelf,6),value(at,(3,4))). +init(object(shelf,7),value(at,(5,4))). +init(object(shelf,8),value(at,(6,4))). diff --git a/dom/asprilo-abc/telingo_choices.lp b/dom/asprilo-abc/telingo_choices.lp new file mode 100644 index 0000000..a912c37 --- /dev/null +++ b/dom/asprilo-abc/telingo_choices.lp @@ -0,0 +1,15 @@ +{move_atlingo(robot(N))} :- robot(N). +{pickup_atlingo(robot(N))} :- robot(N). +{putdown_atlingo(robot(N))} :- robot(N). +{carries_atlingo(robot(N))} :- robot(N). +{process_atlingo(robot(N))} :- robot(N). +{process_atlingo(robot(N),shelf(S))} :- robot(N),shelf(S). + + +{pickup(robot(N),shelf(S))} :- robot(N),shelf(S). +{putdown(robot(N),shelf(S))} :- robot(N),shelf(S). +{waits(robot(N))} :- robot(N). +{move(robot(N),(1,0))} :- robot(N). +{move(robot(N),(-1,0))} :- robot(N). +{move(robot(N),(0,1))} :- robot(N). +{move(robot(N),(0,-1))} :- robot(N). \ No newline at end of file diff --git a/dom/asprilo-abc/temporal_constraints/d1.lp b/dom/asprilo-abc/temporal_constraints/d1.lp new file mode 100644 index 0000000..afeda0c --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/d1.lp @@ -0,0 +1,10 @@ +:- not &del{ + (* &t) .>* % Always + ?pickup(robot(R),shelf(S)) .>* %If picks up + *(&t ;; ?move_atlingo(robot(R)) + ?waits(robot(R))) %Move or wait + ;; ?process_atlingo(robot(R),shelf(S)) .>? %Untill process + &true}, + robot(R), shelf(S). + + +% [T*] [pickup?] T \ No newline at end of file diff --git a/dom/asprilo-abc/temporal_constraints/d2.lp b/dom/asprilo-abc/temporal_constraints/d2.lp new file mode 100644 index 0000000..8c93493 --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/d2.lp @@ -0,0 +1,10 @@ +:- not &del{ + *( *(&t ;; ?move_atlingo(robot(R))) ;; %Move towards shelve + &t ;; ?pickup_atlingo(robot(R)) ;; %Pickup + *(&t ;; ?move_atlingo(robot(R))) ;; %Move towards pick station + &t ;; ?process_atlingo(robot(R));; ?waits(robot(R)) ;; %Deliver + *(&t ;; ?move_atlingo(robot(R)));; %Move to dropping place + &t ;; ?putdown_atlingo(robot(R))) %Move putdown shelve + ;; *(&t ;; ?waits(robot(R))) %End with waiting + .>? &t.>* &false }, + robot(R). \ No newline at end of file diff --git a/dom/asprilo-abc/temporal_constraints/d3.lp b/dom/asprilo-abc/temporal_constraints/d3.lp new file mode 100644 index 0000000..e4c3079 --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/d3.lp @@ -0,0 +1,34 @@ +right((1,0)). +left((-1,0)). +up((0,-1)). +down((0,1)). + +:- not &del{ + *( *(&t ;; ?waits(robot(R))) ;; %Waits before starting sequence + + ( *(&t ;; (?move(robot(R),RIGHT))) + %Move horizonatally in one direction + *(&t ;; (?move(robot(R),LEFT))) + ) ;; + *(&t ;; ?move(robot(R),UP) ) ;; %Move up + + &t ;; ?pickup_atlingo(robot(R)) ;; %Pickup + + ( *(&t ;; (?move(robot(R),RIGHT))) + %Move horizonatally in one direction + *(&t ;; (?move(robot(R),LEFT))) + ) ;; + *(&t ;; ?move(robot(R),UP) ) ;; %Move up + + &t ;; ?process_atlingo(robot(R));; ?waits(robot(R)) ;; %Deliver + + ( *(&t ;; (?move(robot(R),RIGHT))) + %Move horizonatally in one direction + *(&t ;; (?move(robot(R),LEFT))) + ) ;; + *(&t ;; ?move(robot(R),DOWN) ) ;; %Move down + + &t ;; ?putdown_atlingo(robot(R))) %Move putdown shelve + ;; *(&t ;; ?waits(robot(R))) %End with waiting + .>? &t.>* &false }, + robot(R), up(UP), right(RIGHT), left(LEFT), down(DOWN). + + +% < * (wait* ;; (right* + left*) ;; up* ;; pickup ;; (right* + left*) ;; up* ;; deliver ;; (right* + left*) ;; down* ;; putdown) > L \ No newline at end of file diff --git a/dom/asprilo-abc/temporal_constraints/other/best_plus_move.lp b/dom/asprilo-abc/temporal_constraints/other/best_plus_move.lp new file mode 100644 index 0000000..3675ee3 --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/other/best_plus_move.lp @@ -0,0 +1,57 @@ +% right((1,0)). +% left((-1,0)). +% up((0,-1)). +% down((0,1)). + +right((1,0)). +left((-1,0)). +up((0,-1)). +down((0,1)). + +:- not &del{ + *( *(&t ;; ?move_atlingo(robot(R))) ;; %Move towards shelve + *(&t ;; ?pickup_atlingo(robot(R))) ;; %Pickup + *(&t ;; ?move_atlingo(robot(R))) ;; %Move towards pick station + &t ;; ?process_atlingo(robot(R));; ?waits(robot(R)) ;; %Deliver + *(&t ;; ?move_atlingo(robot(R)));; %Move to dropping place + &t ;; ?putdown_atlingo(robot(R))) %Move putdown shelve + ;; *(&t ;; ?waits(robot(R))) %End with waiting + .>? &t.>* &false }, + robot(R). + + +:- not &del{ * &t .>* % Always + ?move(robot(R),D_R) ;; &t .>* %Goining right implies + *( ? ~ move(robot(R),D_L);; &t) .>? % Not going left + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) %Until can change + .>? &true + + }, + robot(R),right(D_R),left(D_L). + +:- not &del{ * &t .>* % Always + ?move(robot(R),D_L) ;; &t .>* %Goining right implies + *( ? ~ move(robot(R),D_R);; &t) .>? % Not going left + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) %Until can change + .>? &true + + }, + robot(R),right(D_R),left(D_L). + +:- not &del{ * &t .>* + ?move(robot(R),D_U) ;; &t .>* + *( ? ~ move(robot(R),D_D);; &t) .>? + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) + .>? &true + + }, + robot(R),up(D_U),down(D_D). + +:- not &del{ * &t .>* + ?move(robot(R),D_D) ;; &t .>* + *( ? ~ move(robot(R),D_U);; &t) .>? + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) + .>? &true + + }, + robot(R),up(D_U),down(D_D). \ No newline at end of file diff --git a/dom/asprilo-abc/temporal_constraints/other/no_dir_change.lp b/dom/asprilo-abc/temporal_constraints/other/no_dir_change.lp new file mode 100644 index 0000000..99e799c --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/other/no_dir_change.lp @@ -0,0 +1,40 @@ +right((1,0)). +left((-1,0)). +up((0,-1)). +down((0,1)). + +:- not &del{ * &t .>* % Always + ?move(robot(R),D_R) ;; &t .>* %Goining right implies + *( ? ~ move(robot(R),D_L);; &t) .>? % Not going left + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) %Until can change + .>? &true + + }, + robot(R),right(D_R),left(D_L). + +:- not &del{ * &t .>* % Always + ?move(robot(R),D_L) ;; &t .>* %Goining right implies + *( ? ~ move(robot(R),D_R);; &t) .>? % Not going left + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) %Until can change + .>? &true + + }, + robot(R),right(D_R),left(D_L). + +:- not &del{ * &t .>* + ?move(robot(R),D_U) ;; &t .>* + *( ? ~ move(robot(R),D_D);; &t) .>? + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) + .>? &true + + }, + robot(R),up(D_U),down(D_D). + +:- not &del{ * &t .>* + ?move(robot(R),D_D) ;; &t .>* + *( ? ~ move(robot(R),D_U);; &t) .>? + (?pickup_atlingo(robot(R)) + ?process_atlingo(robot(R)) + ?putdown_atlingo(robot(R))) + .>? &true + + }, + robot(R),up(D_U),down(D_D). \ No newline at end of file diff --git a/dom/asprilo-abc/temporal_constraints/other/wait_end.lp b/dom/asprilo-abc/temporal_constraints/other/wait_end.lp new file mode 100644 index 0000000..e0f1536 --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/other/wait_end.lp @@ -0,0 +1,5 @@ +:- not &del{ + (* &t) ;; ?waits(robot(R)) .>? + &t .>* &false + }, + robot(R). diff --git a/dom/asprilo-abc/temporal_constraints/other/wait_start.lp b/dom/asprilo-abc/temporal_constraints/other/wait_start.lp new file mode 100644 index 0000000..42bcc4e --- /dev/null +++ b/dom/asprilo-abc/temporal_constraints/other/wait_start.lp @@ -0,0 +1,3 @@ +:- not &del{ &t ;; ?waits(robot(R)) ;; &t ;; ?waits(robot(R)) ;; &t ;; ?waits(robot(R)) + .>? &true }, + robot(R). diff --git a/dom/asprilo-md/glue.lp b/dom/asprilo-md/glue.lp new file mode 100644 index 0000000..89bc646 --- /dev/null +++ b/dom/asprilo-md/glue.lp @@ -0,0 +1,17 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Mapping for atoms into holds predicate +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Actions start at time point 1!!! + + +% One rule for each type of predicate used in the formula +trace(ID,T) :- move(robot(N),(X,Y),T),prop(ID,("move",("robot",N),("",X,Y))). +trace(ID,T) :- position(robot(N),(X,Y),T),prop(ID,("position",("robot",N),("",X,Y))). + +% Additional predicates used +trace(ID,T) :- move(robot(N),T),prop(ID,("move",("robot",N))). + + +move(R, T) :- move(R, _, T). diff --git a/dom/asprilo-md/telingo_choices.lp b/dom/asprilo-md/telingo_choices.lp new file mode 100644 index 0000000..7ff8a64 --- /dev/null +++ b/dom/asprilo-md/telingo_choices.lp @@ -0,0 +1,12 @@ +{move(robot(N),(0..1,0..1))}:-robot(N). +{position(robot(N),(0..1,0..1))}:-robot(N). +{move(robot(N))}:-robot(N). +{move(robot(N))}:-robot(N). +% {following(robot(N),robot(M)}:-robot(N,M). +{no_move_right(robot(N))}:-robot(N). +{no_move_left(robot(N))}:-robot(N). +{no_move_up(robot(N))}:-robot(N). +{no_move_down(robot(N))}:-robot(N). +{move_horizontally(robot(N))}:-robot(N). +{no_move_vertically(robot(N))}:-robot(N). +{no_move_horizontally(robot(N))}:-robot(N). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/d_d_done.lp b/dom/asprilo-md/temporal_constraints/d_d_done.lp new file mode 100644 index 0000000..aebaf7b --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/d_d_done.lp @@ -0,0 +1,11 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- not &del{(* &t) .>? + (?move_d(robot(X)) ;; &t ;; ?move_d(robot(X)) ;; &t).>? + (*(&t).>* ( ?move_v(robot(X)) + ?move_h(robot(X))) .>* &false) + + }, robot(X). diff --git a/dom/asprilo-md/temporal_constraints/d_d_last.lp b/dom/asprilo-md/temporal_constraints/d_d_last.lp new file mode 100644 index 0000000..eb15c73 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/d_d_last.lp @@ -0,0 +1,7 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- not &del{(* &t) .>? (?move_d(robot(X)) ;; &t ;; ?move_d(robot(X)) ;; &t).>? (&t.>* &false)}, robot(X). diff --git a/dom/asprilo-md/temporal_constraints/follow_mutually.extra.lp b/dom/asprilo-md/temporal_constraints/follow_mutually.extra.lp new file mode 100644 index 0000000..f7c3275 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/follow_mutually.extra.lp @@ -0,0 +1 @@ +#include "../following.lp". diff --git a/dom/asprilo-md/temporal_constraints/follow_mutually.lp b/dom/asprilo-md/temporal_constraints/follow_mutually.lp new file mode 100644 index 0000000..f9f9517 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/follow_mutually.lp @@ -0,0 +1,19 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- not &del{(* &t) .>? ( + ?following(robot(X),robot(Y)) ;; &t ;; ?following(robot(Y),robot(X)) ;; &t ;; + ?following(robot(X),robot(Y)) ;; &t ;; ?following(robot(Y),robot(X)) ;; &t ;; + ?following(robot(X),robot(Y)) ;; &t ;; ?following(robot(Y),robot(X)) ;; &t + +% *(?following(robot(X),robot(Y)) ;; &t) ;; + +% ?following(robot(Y),robot(X)) ;; &t ;; + +% *(?following(robot(Y),robot(X)) ;; &t) + +.>? &true)}, robot(X), robot(Y), Y!=X. +% :- not &del{(* &t) .>? (?move_d(robot(X)) ;; &t ;; ?move_d(robot(X)) ;; &t).>? (*(&t).>* ( move_v(robot(X)) + ?move_h(robot(X))) .>* &false)}, robot(X). diff --git a/dom/asprilo-md/temporal_constraints/following.lp b/dom/asprilo-md/temporal_constraints/following.lp new file mode 100644 index 0000000..a555f10 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/following.lp @@ -0,0 +1,2 @@ +following(robot(N),robot(M),T):-position(robot(M),(X,Y),T), position(robot(N),(X,Y),T-1). +trace(I,T) :- following(robot(N),robot(M),T),prop(I,("following",("robot",N),("robot",M))). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/horizontally_before_vertically.extra.lp b/dom/asprilo-md/temporal_constraints/horizontally_before_vertically.extra.lp new file mode 100644 index 0000000..bad3b36 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/horizontally_before_vertically.extra.lp @@ -0,0 +1,2 @@ +#include "../wait.lp". +#include "../no_vertical_horizontal.lp". diff --git a/dom/asprilo-md/temporal_constraints/horizontally_before_vertically.lp b/dom/asprilo-md/temporal_constraints/horizontally_before_vertically.lp new file mode 100644 index 0000000..1006a54 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/horizontally_before_vertically.lp @@ -0,0 +1,31 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where robots move horizontally and then vertically +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% :- not &del{ +% ( +% * ( &t ;; ( ? move_horizontally(robot(R)) + ? wait(robot(R)))) ;; +% * ( &t ;; ( ? move_vertically(robot(R)) + ? wait(robot(R)))) +% ) .>? +% (&t.>* &false) }, robot(R). + + +% :- not &del{ +% (* ( ( ? no_move_vertically(robot(R)) ) ;; &t )) .>? +% ( (* &t ) .>* no_move_horizontally(robot(R)) ) +% }, robot(R). + +% :- not &del{ +% &t .>? (* ( ( ? no_move_vertically(robot(R)) ) ;; &t )) .>? +% ( (* &t ) .>* no_move_horizontally(robot(R)) ) +% }, robot(R). + +:- not &del{ + (* ( ( ? no_move_vertically(robot(R)) ) ;; &t )) .>? + ( (* &t ) .>* no_move_horizontally(robot(R)) ) +}, robot(R). + +% :- not &del{ +% (* ( ( ? no_move_vertically(robot(1)) ) ;; &t )) .>? +% ( (* &t ) .>* no_move_horizontally(robot(1)) ) +% }. \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/never_both_directions.extra.lp b/dom/asprilo-md/temporal_constraints/never_both_directions.extra.lp new file mode 100644 index 0000000..8c95e10 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/never_both_directions.extra.lp @@ -0,0 +1,2 @@ +#include "../no_right_left_up_down.lp". +% #include "../wait.lp". \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/never_both_directions.lp b/dom/asprilo-md/temporal_constraints/never_both_directions.lp new file mode 100644 index 0000000..529c0ee --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/never_both_directions.lp @@ -0,0 +1,18 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where robots move horizontally and then vertically +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% :- not &del{ +% *(&t ;; ((? move_right(robot(N))) + (? move_up(robot(N))) + (? wait(robot(N))) )) + +% *(&t ;; ((? move_left(robot(N))) + (? move_up(robot(N))) + (? wait(robot(N))) )) +% .>? +% (&t.>* &false) }, robot(N). + +:- not &del{ + *(&t ;; ? no_move_right(robot(N))) + + *(&t ;; ? no_move_left(robot(N))) .>? + (&t.>* &false) }, robot(N). + +:- not &del{ + *(&t ;; ? no_move_down(robot(N))) + + *(&t ;; ? no_move_up(robot(N))) .>? + (&t.>* &false) }, robot(N). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/no_right_left_up_down.lp b/dom/asprilo-md/temporal_constraints/no_right_left_up_down.lp new file mode 100644 index 0000000..63aca07 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/no_right_left_up_down.lp @@ -0,0 +1,17 @@ +#include "right_left_up_down.lp". + +no_move_right(robot(N), T) :- not move(robot(N), R, T), right(R), time(T), robot(N). +no_move_right(robot(N),0):-robot(N). +trace(I,T) :- no_move_right(robot(N),T),prop(I,("no_move_right",("robot",N))). + +no_move_left(robot(N), T) :- not move(robot(N), R, T), left(R), time(T), robot(N). +no_move_left(robot(N),0):-robot(N). +trace(I,T) :- no_move_left(robot(N),T),prop(I,("no_move_left",("robot",N))). + +no_move_up(robot(N), T) :- not move(robot(N), R, T), up(R), time(T), robot(N). +no_move_up(robot(N),0):-robot(N). +trace(I,T) :- no_move_up(robot(N),T),prop(I,("no_move_up",("robot",N))). + +no_move_down(robot(N), T) :- not move(robot(N), R, T), down(R), time(T), robot(N). +no_move_down(robot(N),0):-robot(N). +trace(I,T) :- no_move_down(robot(N),T),prop(I,("no_move_down",("robot",N))). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/no_vertical_horizontal.lp b/dom/asprilo-md/temporal_constraints/no_vertical_horizontal.lp new file mode 100644 index 0000000..3fa4293 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/no_vertical_horizontal.lp @@ -0,0 +1,12 @@ +#include "vertical_horizontal.lp". + +no_move_vertically(robot(N), T) :- not move_vertically(robot(N), T), robot(N), time(T). +:- move_vertically(R, T), no_move_vertically(R, T). +no_move_vertically(robot(N), 0) :- robot(N). + +no_move_horizontally(robot(N), T) :- not move_horizontally(robot(N), T), robot(N), time(T). +:- move_horizontally(R, T), no_move_horizontally(R, T). +no_move_horizontally(robot(N), 0) :- robot(N). + +trace(I,T) :- no_move_vertically(robot(N),T),prop(I,("no_move_vertically",("robot",N))). +trace(I,T) :- no_move_horizontally(robot(N),T),prop(I,("no_move_horizontally",("robot",N))). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/paper.extra.lp b/dom/asprilo-md/temporal_constraints/paper.extra.lp new file mode 100644 index 0000000..f37e001 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/paper.extra.lp @@ -0,0 +1 @@ +#include "../wait.lp". \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/paper.lp b/dom/asprilo-md/temporal_constraints/paper.lp new file mode 100644 index 0000000..fba4b72 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/paper.lp @@ -0,0 +1,5 @@ +#include "../right_left_up_down.lp". +:- not &del{ *( &t ;; ?move(robot(R),UP)) ;; + *( &t ;; ?move(robot(R),RIGHT)) ;; + *( &t ;; ?wait(robot(R))) .>? (&t.>* &false) }, + robot(R), right(RIGHT), up(UP). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/r_r_r.lp b/dom/asprilo-md/temporal_constraints/r_r_r.lp new file mode 100644 index 0000000..8bc2452 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/r_r_r.lp @@ -0,0 +1,7 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% :- not &del{(&t ;; ?move(robot(1),(1,0)) ).>? &t}. +:- not &del{( &t ;; ?move(robot(1),(1,0)) ;; &t ;; ?move(robot(1),(1,0))).>? &true}. +% :- not &del{( &t ;; ?move(robot(R),(1,0)) ;; &t ;; ?move(robot(R),(1,0))).>? &true}, robot(R). diff --git a/dom/asprilo-md/temporal_constraints/right_left_up_down.lp b/dom/asprilo-md/temporal_constraints/right_left_up_down.lp new file mode 100644 index 0000000..7752a33 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/right_left_up_down.lp @@ -0,0 +1,4 @@ +right((1,0)). +left((-1,0)). +up((0,-1)). +down((0,1)). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/star-right-right-right.lp b/dom/asprilo-md/temporal_constraints/star-right-right-right.lp new file mode 100644 index 0000000..5ee8951 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/star-right-right-right.lp @@ -0,0 +1,11 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- not &del{* (?move(robot(X),(1,0)) ;; &t;; ? ~ move(robot(X),(1,0));; &t).>? &t .>* &false}, robot(X). + +% :- not &del{?move(robot(X),(1,0)) ;; &t;; ? wait(robot(X));; &t ;; * (?move(robot(X),(1,0)) ;; &t;; ? wait(robot(X))) .>? (&t .>* &false)}, robot(X). + +% :- not &del{&t}. diff --git a/dom/asprilo-md/temporal_constraints/true.lp b/dom/asprilo-md/temporal_constraints/true.lp new file mode 100644 index 0000000..072ed92 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/true.lp @@ -0,0 +1,7 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- not &del{&true}, robot(X). diff --git a/dom/asprilo-md/temporal_constraints/v_h_alternated.lp b/dom/asprilo-md/temporal_constraints/v_h_alternated.lp new file mode 100644 index 0000000..66c77d1 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/v_h_alternated.lp @@ -0,0 +1,41 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where the last tree moves of all robost +% % are moving right +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- not &del{*( + + ?move_v(robot(R)) ;; &t ;; *(?no_move(robot(R)) ;; &t) ;; + ?move_h(robot(R)) ;; &t ;; *(?no_move(robot(R)) ;; &t) ) + + .>? &t .>* &false} + +, robot(R). + +% :- not &del{*( + +% ?move_h(robot(R)) ;; &t ;; +% ?move_v(robot(R)) ;; &t) + +% .>? &t .>* &false} + +% , robot(R). + +% :- not &del{*( + +% ?move_h(robot(R)) ;; &t ;; +% ?move_v(robot(R)) ;; &t) + +% .>? *(?no_move(robot(R));; &t).>? &t .>* &false} + +% , robot(R). + +% :- not &del{*( + +% ?move_h(robot(R)) ;; &t ;; +% ?move_v(robot(R)) ;; &t) + +% .>? &t} + +% , robot(R). diff --git a/dom/asprilo-md/temporal_constraints/vertical_horizontal.lp b/dom/asprilo-md/temporal_constraints/vertical_horizontal.lp new file mode 100644 index 0000000..e76dd3c --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/vertical_horizontal.lp @@ -0,0 +1,6 @@ +move_vertically(R, T) :- move(R, (0,_), T). + +move_horizontally(R, T) :- move(R, (_,0), T). + +trace(I,T) :- move_horizontally(robot(N),T),prop(I,("move_horizontally",("robot",N))). +trace(I,T) :- move_vertically(robot(N),T),prop(I,("move_vertically",("robot",N))). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/vertically_before_horizontally.extra.lp b/dom/asprilo-md/temporal_constraints/vertically_before_horizontally.extra.lp new file mode 100644 index 0000000..bad3b36 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/vertically_before_horizontally.extra.lp @@ -0,0 +1,2 @@ +#include "../wait.lp". +#include "../no_vertical_horizontal.lp". diff --git a/dom/asprilo-md/temporal_constraints/vertically_before_horizontally.lp b/dom/asprilo-md/temporal_constraints/vertically_before_horizontally.lp new file mode 100644 index 0000000..56fe7e8 --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/vertically_before_horizontally.lp @@ -0,0 +1,15 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Example where robots move horizontally and then vertically +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% :- not &del{ +% ( +% * ( &t ;; ( ? move_vertically(robot(R)) + ? wait(robot(R)))) ;; +% * ( &t ;; ( ? move_horizontally(robot(R)) + ? wait(robot(R)))) +% ) .>? +% (&t.>* &false) }, robot(R). + +:- not &del{ + (* ( ( ? no_move_horizontally(robot(R)) ) ;; &t )) .>? + ( (* &t ) .>* no_move_vertically(robot(R)) ) +}, robot(R). \ No newline at end of file diff --git a/dom/asprilo-md/temporal_constraints/wait.lp b/dom/asprilo-md/temporal_constraints/wait.lp new file mode 100644 index 0000000..65c6abe --- /dev/null +++ b/dom/asprilo-md/temporal_constraints/wait.lp @@ -0,0 +1,3 @@ +wait(robot(N), T) :- not move(robot(N), _, T), robot(N), time(T). +trace(I,T) :- wait(robot(N),T),prop(I,("wait",("robot",N))). +wait(robot(N),0):-robot(N). \ No newline at end of file diff --git a/dom/asprilo-md/traces/asprilo_trace_explicit_invalid.lp b/dom/asprilo-md/traces/asprilo_trace_explicit_invalid.lp new file mode 100644 index 0000000..c7c933c --- /dev/null +++ b/dom/asprilo-md/traces/asprilo_trace_explicit_invalid.lp @@ -0,0 +1,9 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Invalid trace for constraint del_robot_move +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +move(robot(1),(1,0),1). +move(robot(1),(1,0),2). +move(robot(1),(1,0),3). +move(robot(1),(1,1),4). \ No newline at end of file diff --git a/dom/asprilo-md/traces/asprilo_trace_explicit_valid_1.lp b/dom/asprilo-md/traces/asprilo_trace_explicit_valid_1.lp new file mode 100644 index 0000000..57faead --- /dev/null +++ b/dom/asprilo-md/traces/asprilo_trace_explicit_valid_1.lp @@ -0,0 +1,8 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Valid trace for constraint del_robot_move +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +move(robot(1),(1,0),1). +move(robot(1),(1,0),2). +move(robot(1),(1,0),3). \ No newline at end of file diff --git a/dom/asprilo-md/traces/asprilo_trace_explicit_valid_2.lp b/dom/asprilo-md/traces/asprilo_trace_explicit_valid_2.lp new file mode 100644 index 0000000..398d2b9 --- /dev/null +++ b/dom/asprilo-md/traces/asprilo_trace_explicit_valid_2.lp @@ -0,0 +1,8 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Valid trace for constraint del_robot_move +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +move(robot(1),(1,1),1). +move(robot(1),(1,0),2). +move(robot(1),(1,0),3). +move(robot(1),(1,0),4). \ No newline at end of file diff --git a/dom/elevator/encoding.lp b/dom/elevator/encoding.lp new file mode 100644 index 0000000..00d3fca --- /dev/null +++ b/dom/elevator/encoding.lp @@ -0,0 +1,26 @@ +#const horizon=7. +time(0..horizon). + +{wait(T); up(T) ; down(T); serve(T)}=1 :- time(T+1),time(T). +:- up(T), at(X,T), not floor(X+1), time(T). +:- down(T), at(X,T), not floor(X-1), time(T). + +at(X+1,T+1):- up(T), at(X,T), time(T). +at(X-1,T+1):- down(T), at(X,T), time(T). +at(X, T+1) :- at(X,T), not up(T), not down(T), time(T). +served(X, T) :- at(X,T), serve(T). +called(X,T+1):- called(X,T), time(T), not served(X, T). + +ready(T) :- called(X,T), at(X,T). + +:- called(X,T), not time(T). + +% #show called/2. +% #show time/1. +#show serve/1. +% #show served/2. +% #show at/2. +#show up/1. +#show wait/1. +#show down/1. +% #show prop/2. \ No newline at end of file diff --git a/dom/elevator/general_instance.lp b/dom/elevator/general_instance.lp new file mode 100644 index 0000000..e5805d8 --- /dev/null +++ b/dom/elevator/general_instance.lp @@ -0,0 +1,5 @@ +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/dom/elevator/glue.lp b/dom/elevator/glue.lp new file mode 100644 index 0000000..1fb323b --- /dev/null +++ b/dom/elevator/glue.lp @@ -0,0 +1,10 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Mapping for atoms into holds predicate +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% One rule for each type of predicate used in the formula +trace(ID,T) :- up(T),prop(ID,("up")). +trace(ID,T) :- down(T),prop(ID,("down")). +trace(ID,T) :- serve(T),prop(ID,("serve")). +trace(ID,T) :- wait(T),prop(ID,("wait")). +trace(ID,T) :- ready(T),prop(ID,("ready")). diff --git a/dom/elevator/instances/11_floors.lp b/dom/elevator/instances/11_floors.lp new file mode 100644 index 0000000..cbdac5d --- /dev/null +++ b/dom/elevator/instances/11_floors.lp @@ -0,0 +1,6 @@ +#const floors=11. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/dom/elevator/instances/5_floors.lp b/dom/elevator/instances/5_floors.lp new file mode 100644 index 0000000..e03ba47 --- /dev/null +++ b/dom/elevator/instances/5_floors.lp @@ -0,0 +1,6 @@ +#const floors=5. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/dom/elevator/instances/7_floors.lp b/dom/elevator/instances/7_floors.lp new file mode 100644 index 0000000..ad78d8b --- /dev/null +++ b/dom/elevator/instances/7_floors.lp @@ -0,0 +1,6 @@ +#const floors=7. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/dom/elevator/instances/9_floors.lp b/dom/elevator/instances/9_floors.lp new file mode 100644 index 0000000..ad124a5 --- /dev/null +++ b/dom/elevator/instances/9_floors.lp @@ -0,0 +1,6 @@ +#const floors=9. +floor(1..floors). + +at((floors+1)/2,0). +called(floors,0). +called(1,0). \ No newline at end of file diff --git a/dom/elevator/telingo_choices.lp b/dom/elevator/telingo_choices.lp new file mode 100644 index 0000000..f6e7781 --- /dev/null +++ b/dom/elevator/telingo_choices.lp @@ -0,0 +1,5 @@ +{up}. +{down}. +{serve}. +{wait}. +{ready}. \ No newline at end of file diff --git a/dom/elevator/temporal_constraints/best.lp b/dom/elevator/temporal_constraints/best.lp new file mode 100644 index 0000000..d00abfe --- /dev/null +++ b/dom/elevator/temporal_constraints/best.lp @@ -0,0 +1,2 @@ +:- not &del{ *( (*(?up ;; &t) + *(?down ;; &t)) ;; ?ready;; ?serve;; &t) + ;; *(?wait ;; &t) .>? &t.>* &false }. \ No newline at end of file diff --git a/dom/elevator/temporal_constraints/upup.lp b/dom/elevator/temporal_constraints/upup.lp new file mode 100644 index 0000000..b02a517 --- /dev/null +++ b/dom/elevator/temporal_constraints/upup.lp @@ -0,0 +1,3 @@ +% :- not &del{ *( (*(?up ;; &t) + *(?down ;; &t)) ;; ?ready;; ?serve;; &t) +:- not &del{ ?up ;; &t;; ?up .>? &true }. +% :- not &del{ &t }. \ No newline at end of file diff --git a/dom/elevator/temporal_constraints/wait.lp b/dom/elevator/temporal_constraints/wait.lp new file mode 100644 index 0000000..d40686e --- /dev/null +++ b/dom/elevator/temporal_constraints/wait.lp @@ -0,0 +1,3 @@ +% :- not &del{ *( (*(?up ;; &t) + *(?down ;; &t)) ;; ?ready;; ?serve;; &t) +% :- not &del{ ( *(?up ;; &t) ;; ?serve ;; &t ;; ?down ;; &t ;; ?down ;; &t ;; ?down ;; &t ;; ?down ;; &t ;; ?serve ;; &t) .>? &t .>* &false}. +:- not &del{ * &t .>? wait}. \ No newline at end of file diff --git a/dom/hanoi/encoding.lp b/dom/hanoi/encoding.lp new file mode 100644 index 0000000..831d7ad --- /dev/null +++ b/dom/hanoi/encoding.lp @@ -0,0 +1,30 @@ +#const horizon=10. +time(1..horizon). +on(D,P,0) :- init_on(D,P). + +{ move(D,P,T) : disk(D), peg(P) } 1 :- time(T). + +move(D,T) :- move(D,P,T), time(T). +on(D,P,T) :- move(D,P,T), time(T). +on(D,P,T) :- on(D,P,T-1), not move(D,T), time(T). + +% D cant move from P in T +blocked(D+1,P,T) :- on(D,P,T-1), time(T). +blocked(D+1,P,T) :- blocked(D,P,T), disk(D), time(T). + + +% Cant move a blocked disk to a pile with a higher disk on top +:- move(D,P,T), blocked(D+1,P,T), time(T). + +% Cant move a blocked disk in a pile beacause it has something on top +:- move(D,T), on(D,P,T-1), blocked(D,P,T), time(T). +:- not 1 { on(D,P,T) } 1, disk(D), time(T). + +:- goal_on(D,P), not on(D,P,horizon). + +% Used for the constraints +smallestfree(D,T) :- disk(D); time(T); not blocked(D,_,T), #false : disk(D'), not blocked(D',_,T), D'? + &t .>* &false %Final state + }. + \ No newline at end of file diff --git a/dom/hanoi/temporal_constraints/idea-pooling.lp b/dom/hanoi/temporal_constraints/idea-pooling.lp new file mode 100644 index 0000000..1257825 --- /dev/null +++ b/dom/hanoi/temporal_constraints/idea-pooling.lp @@ -0,0 +1,21 @@ +% :- not &del{ &true ;; %One step tp start in 1 +% * ( ?move(D) : disk(D) ;; &true) .>? &true +% }. + +% Instance +disk(1). +disk(2). +disk(3). + +% What one can do only to get theory elements but I cant use inside a formula +:- not &del{ ?move(D) : disk(D) }. +:- not &del{ ?move(1); ?move(2); ?move(3) }. + + +% What I would like to have pool inside the expressions, perhaps appling an operator like '+'.join([move(1),move(2),move(3)]) +:- not &del{ +{?move(D) : disk(D)} .>? &true}. +:- not &del{ ?move(1) + ?move(2) + ?move(3) .>? &true}. + + +% :- not &del{ {move(D) : disk(D)}[+] .>? &true}. +% :- not &del{ move(1) + move(2) + move(3) .>? &true}. \ No newline at end of file diff --git a/dom/hanoi/temporal_constraints/move-smallest.lp b/dom/hanoi/temporal_constraints/move-smallest.lp new file mode 100644 index 0000000..8dc50c2 --- /dev/null +++ b/dom/hanoi/temporal_constraints/move-smallest.lp @@ -0,0 +1,10 @@ +:- not &del{ &t ;; %One step tp start in 1 + *( ?move(1) ;; &t ;; %Move disk 1 + ? ~smallestfree(D) + + (? smallestfree(D) ;; ?move(D)) ;; &t %Move another disk + ) ;; + * (? ~move ;; &t) % Dont move + .>? + &t .>* &false %Final state + }, + disk(D), D!=1. \ No newline at end of file diff --git a/dom/river/encoding-asp.lp b/dom/river/encoding-asp.lp new file mode 100644 index 0000000..5bde67e --- /dev/null +++ b/dom/river/encoding-asp.lp @@ -0,0 +1,41 @@ +% -------- Constraints +at(X,r,0):-thing(X). + +% Cant be in both sides at the same time +:- at(X,S,T), at(X,S',T), side(S), side(S'), S!=S', thing(X), time(T). +% Cant be in none of the sides +:- not at(X,S,T), not at(X,S',T), side(S), side(S'), S!=S', thing(X), time(T). + + +% Boat always moves +:- not take(boat,T), time(T), time(T+1). + +% Can only take things that are on your side +:- take(X,T), at(boat,S,T), not at(X,S,T), thing(X). + +% Cant take more than one thing +:- take(f,T), take(c,T). +:- take(f,T), take(g,T). +:- take(c,T), take(g,T). + +% Consecuence of taking +:- take(X,T), at(X,r,T), not at(X,l,T+1), thing(X), time(T+1). +:- take(X,T), at(X,l,T), not at(X,r,T+1), thing(X), time(T+1). + +% Inertia +:- at(X,S,T), not take(X,T), not at(X,S,T+1), thing(X), time(T+1). +% :- at(X,S,T), not take(X,T), at(X,S',T), thing(T). + +% Conditions of eating +:- at(f,S,T), at(c,S,T), not at(boat,S,T), side(S). +:- at(c,S,T), at(g,S,T), not at(boat,S,T), side(S). + +% Goal +:- not at(c,l,horizon). +:- not at(f,l,horizon). +:- not at(g,l,horizon). + + +#show take/2. +% #show take(X,T) :take(X,T), not X=boat. +% #show at/3. \ No newline at end of file diff --git a/dom/river/encoding.lp b/dom/river/encoding.lp new file mode 100644 index 0000000..d6e6e62 --- /dev/null +++ b/dom/river/encoding.lp @@ -0,0 +1,8 @@ +#const horizon=9. +time(0..horizon). + + +% -------- choose (classical) +{at(X,S,T)}:-side(S),thing(X),time(T). +{at(boat,S,T)}:-side(S),time(T). +{take(X,T)}:-side(S),thing(X),time(T),time(T+1). \ No newline at end of file diff --git a/dom/river/glue.lp b/dom/river/glue.lp new file mode 100644 index 0000000..d78cbd2 --- /dev/null +++ b/dom/river/glue.lp @@ -0,0 +1,20 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Mapping for atoms into holds predicate +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% One rule for each type of predicate used in the formula +trace(ID,T) :- at(f,l,T),prop(ID,("at","f","l")). +trace(ID,T) :- at(c,l,T),prop(ID,("at","c","l")). +trace(ID,T) :- at(g,l,T),prop(ID,("at","g","l")). +trace(ID,T) :- at(boat,l,T),prop(ID,("at","boat","l")). + +trace(ID,T) :- at(f,r,T),prop(ID,("at","f","r")). +trace(ID,T) :- at(c,r,T),prop(ID,("at","c","r")). +trace(ID,T) :- at(g,r,T),prop(ID,("at","g","r")). +trace(ID,T) :- at(boat,r,T),prop(ID,("at","boat","r")). + +trace(ID,T) :- take(f,T),prop(ID,("take","f")). +trace(ID,T) :- take(c,T),prop(ID,("take","c")). +trace(ID,T) :- take(g,T),prop(ID,("take","g")). +trace(ID,T) :- take(boat,T),prop(ID,("take","boat")). + diff --git a/dom/river/instances/simple.lp b/dom/river/instances/simple.lp new file mode 100644 index 0000000..cdb6696 --- /dev/null +++ b/dom/river/instances/simple.lp @@ -0,0 +1,6 @@ +thing(f). +thing(c). +thing(g). +thing(boat). +side(l). +side(r). \ No newline at end of file diff --git a/dom/test/glue.lp b/dom/test/glue.lp new file mode 100644 index 0000000..1b703d2 --- /dev/null +++ b/dom/test/glue.lp @@ -0,0 +1,15 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Mapping for atoms into holds predicate +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% One rule for each type of predicate used in the formula +trace(ID,T) :- p(T),prop(ID,"p"). +trace(ID,T) :- q(T),prop(ID,"q"). +trace(ID,T) :- r(T),prop(ID,"r"). +trace(ID,T) :- s(T),prop(ID,"s"). +trace(ID,T) :- a(T),prop(ID,"a"). +trace(ID,T) :- b(T),prop(ID,"b"). +trace(ID,T) :- b(T),prop(ID,"b"). +trace(ID,T) :- c(T),prop(ID,"c"). +trace(ID,T) :- b(1,T),prop(ID,("b",1)). +trace(ID,T) :- b(2,T),prop(ID,("b",2)). \ No newline at end of file diff --git a/dom/test/instances/delex_sat.lp b/dom/test/instances/delex_sat.lp new file mode 100644 index 0000000..7cbb3c9 --- /dev/null +++ b/dom/test/instances/delex_sat.lp @@ -0,0 +1,7 @@ +a(1). +b(0). +b(1). +b(2). +b(3). +#show a/1. +#show b/1. \ No newline at end of file diff --git a/dom/test/instances/delex_unsat.lp b/dom/test/instances/delex_unsat.lp new file mode 100644 index 0000000..d166082 --- /dev/null +++ b/dom/test/instances/delex_unsat.lp @@ -0,0 +1,6 @@ +a(1). +b(0). +b(2). +b(3). +#show a/1. +#show b/1. \ No newline at end of file diff --git a/dom/test/instances/empty.lp b/dom/test/instances/empty.lp new file mode 100644 index 0000000..c0bbe5a --- /dev/null +++ b/dom/test/instances/empty.lp @@ -0,0 +1,2 @@ +% p(1). +% q(1). \ No newline at end of file diff --git a/dom/test/instances/instance_tmp.lp b/dom/test/instances/instance_tmp.lp new file mode 100644 index 0000000..e69de29 diff --git a/dom/test/instances/test.lp b/dom/test/instances/test.lp new file mode 100644 index 0000000..1e2b1d8 --- /dev/null +++ b/dom/test/instances/test.lp @@ -0,0 +1,12 @@ +% p(2). +% p(3). +% p(1). +% q(1). +% q(2). +% p(0). +time(0..horizon). +{p(T)}:-time(T). +{q(T)}:-time(T). + +#show p/1. +#show q/1. \ No newline at end of file diff --git a/dom/test/telingo_choices.lp b/dom/test/telingo_choices.lp new file mode 100644 index 0000000..88601f1 --- /dev/null +++ b/dom/test/telingo_choices.lp @@ -0,0 +1,7 @@ +{p}. +{q}. +{r}. +{s}. +{a}. +{b}. +{b(1)}. \ No newline at end of file diff --git a/dom/test/temporal_constraints/cons_tmp.lp b/dom/test/temporal_constraints/cons_tmp.lp new file mode 100644 index 0000000..7e3ba08 --- /dev/null +++ b/dom/test/temporal_constraints/cons_tmp.lp @@ -0,0 +1 @@ +:-not &del{ * &t .>* ? ~p .>* ~q}. \ No newline at end of file diff --git a/dom/test/temporal_constraints/delex.lp b/dom/test/temporal_constraints/delex.lp new file mode 100644 index 0000000..85b7a53 --- /dev/null +++ b/dom/test/temporal_constraints/delex.lp @@ -0,0 +1,2 @@ +:- not &del{ ? (* &t .>* b) ;; &t .>? a }. + diff --git a/dom/yale/encoding-asp.lp b/dom/yale/encoding-asp.lp new file mode 100644 index 0000000..d7e077a --- /dev/null +++ b/dom/yale/encoding-asp.lp @@ -0,0 +1,41 @@ +alive(0). + +#const horizon=9. +time(0..horizon). + + +% -------- fluents +{alive(T)}:-time(T). +{loaded(T)}:-time(T). + +% -------- actions +{shoot(T)}:-time(T),T* + ( + ? (?load .>* ~shoot) ;; + ? (?shoot.>* ~load) ;; + + ? (?shoot ;; ?loaded ;; &t .>* ~alive) ;; + ? (?shoot ;; &t .>* ~loaded) ;; + + ? (?load ;; &t .>* loaded) ;; + + ? (? ~alive ;; &t .>* ~alive) ;; + ? (? alive ;; ? ~shoot + ? ~loaded ;; &t .>* alive) ;; + ? (? ~loaded ;; ? ~load ;; &t .>* ~loaded);; + ? (?( &t .>* &false) .>* ~alive) + ) + + .>? &true +}. diff --git a/dom/yale/temporal_constraints/definition.lp b/dom/yale/temporal_constraints/definition.lp new file mode 100644 index 0000000..e2e7c11 --- /dev/null +++ b/dom/yale/temporal_constraints/definition.lp @@ -0,0 +1,24 @@ +:- not &del{alive}. +:- not &del{~loaded}. + +% Single action per timepoint +:- not &del{ * &t .>* ?load .>* ~shoot}. +:- not &del{ * &t .>* ?shoot.>* ~load}. + +% Efect of shoot +:- not &del{ * &t .>* ?shoot ;; ?loaded ;; &t .>* ~alive}. +:- not &del{ * &t .>* ?shoot ;; &t .>* ~loaded}. + +% Efect of load +:- not &del{ * &t .>* ?load ;; &t .>* loaded}. + +% Intertia +:- not &del{ * &t .>* ? ~alive ;; &t .>* ~alive}. +:- not &del{ * &t .>* ? alive ;; ? ~shoot + ? ~loaded ;; &t .>* alive}. +:- not &del{ * &t .>* ? ~loaded ;; ? ~load ;; &t .>* ~loaded}. + + +% force dead +:- not &del{ * &t .>* ?( &t .>* &false) .>* ~alive }. +% force never load +:- not &del{ * &t .>* ~load }. \ No newline at end of file diff --git a/encodings/automata_run/run.lp b/encodings/automata_run/run.lp new file mode 100644 index 0000000..858d417 --- /dev/null +++ b/encodings/automata_run/run.lp @@ -0,0 +1,29 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Run: +% % Computes runs for a trace +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +#include "./trace.lp". %Last holds in horizon and true holds in all time steps + + +node(ID,0) :- initial_state(ID). + +1{select(C,Q,T):delta(Q,C)}1 :- node(Q,T),T<=horizon. + +node(Q',T+1) :- select(C,Q,T), delta(Q,C,Q'). + +:- select(C,Q,T), delta(Q,C,in,A), not trace(A,T). +:- select(C,Q,T), delta(Q,C,out,A), trace(A,T). + +:- node(ID,horizon+1), not final_state(ID). + +% #show holds_map/2. +% #show trace/2. +% #show node/2. +% #show select/3. +% #show select/3. +% #show node/2. +% #show delta/2. +% #show initial_state/1. +% #show horizon/1. \ No newline at end of file diff --git a/encodings/automata_run/trace.lp b/encodings/automata_run/trace.lp new file mode 100644 index 0000000..deddd47 --- /dev/null +++ b/encodings/automata_run/trace.lp @@ -0,0 +1,19 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Trace: +% % Creates the last time step of the trace where nothing +% % can hold after +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% %-------------------- "last" holds in last timestep ------------------------ + +#const horizon = 8. %Passed as a parameter equal to lambda -1 +% Last holds in horizon +% last(horizon). +trace(ID,horizon):-prop(ID,"last"). + +% %-------------------- True holds in all time steps ------------------------ +% trace(true,0..horizon). %Now in run + +% %-------------------- Used to better visualize traces ------------------------ +holds_map(T,MAP):- trace(ID,T), prop(ID,MAP). diff --git a/encodings/automata_run/trace_generator.lp b/encodings/automata_run/trace_generator.lp new file mode 100644 index 0000000..f7da79c --- /dev/null +++ b/encodings/automata_run/trace_generator.lp @@ -0,0 +1,6 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Trace generator: +% % Generates possible traces +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +{trace(ID,0..horizon)} :- prop(ID,PROP), PROP!="last". \ No newline at end of file diff --git a/encodings/empty.lp b/encodings/empty.lp new file mode 100644 index 0000000..08b055b --- /dev/null +++ b/encodings/empty.lp @@ -0,0 +1,53 @@ +% -------------- Assert no branching and no contradictions -------------- % +error_branching :- delta(ID,C,ID_NEXT1), + delta(ID,C,ID_NEXT2), + ID_NEXT1 != ID_NEXT2. + +error_contradiction :- delta(ID,C,T1,P), + delta(ID,C,T2,P), + T1!=T2. + +% :- error_contradiction. +% :- error_branching. + +% -------------- Find reachable states that do not expect 'last' -------------- % + +reachable_state(ID) :- initial_state(ID). + + +reachable_state(ID_NEXT) :- reachable_state(ID); + delta(ID,C,ID_NEXT); + prop(PROP_LAST,"last"); + + #false :delta(ID,C,in,PROP_LAST); + + #false :delta(ID,C,ID_NEXT2), + ID_NEXT2!=ID_NEXT. + +% -------------- Check if null or final from reachable states when maybe 'last'-------------- % + +%Hit null at any point +sat :- reachable_state(null). + +%Hit final state without excluding last +sat :- reachable_state(ID), + delta(ID,C,ID_NEXT), + final_state(ID_NEXT), + prop(PROP_LAST,"last"), + #false: delta(ID,C,out,PROP_LAST). + +%Hit nulls without excluding last +sat :- reachable_state(ID); + prop(PROP_LAST,"last"); + delta(ID,C); + #false: delta(ID,C,N); + #false: delta(ID,C,out,PROP_LAST). + +% unsat :- not sat. +% :- not sat. + +#show not_empty: sat. +#show empty: not sat. +#show unsat/0. +#show error_branching/0. +#show error_contradiction/0. \ No newline at end of file diff --git a/encodings/size.lp b/encodings/size.lp new file mode 100644 index 0000000..91a2d20 --- /dev/null +++ b/encodings/size.lp @@ -0,0 +1,5 @@ +size(delta,M):-#count{1,S,N:delta(S,N)}=M. +size(state,M):-#count{1,S:state(ID,S)}=M. +size(initial_state,M):-#count{1,S:initial_state(S)}=M. +size(final_state,M):-#count{1,S:final_state(S)}=M. +#show size/2. \ No newline at end of file diff --git a/encodings/translations/afw2nfa.lp b/encodings/translations/afw2nfa.lp new file mode 100644 index 0000000..01915cc --- /dev/null +++ b/encodings/translations/afw2nfa.lp @@ -0,0 +1,165 @@ + + +% ------- States + +% Power set of afw states +bin(ID,2**(ID)):-state(ID,Q). +number_states(N):-#count{ID:state(ID,_)}=N. +state_nfa_set(0..2**N-1):- number_states(N). + +state_nfa_set(X,N):- state_nfa_set(X), X-B>=0, bin(N,B), number_states(N). +state_nfa_set(X,N):- state_nfa_set(X), X-T-B>=0, bin(N,B), + #sum{B':state_nfa_set(X,N'),bin(N',B'),N'>N}=T. + +% Size of the set +state_nfa_set_size(X,D):- state_nfa_set(X), #count{N: state_nfa_set(X,N)}=D. + +% Assign an idex D to every element in the set +state_nfa_set_indexed(X,N,D) :- state_nfa_set(X,N), + #count{N': state_nfa_set(X,N'), NC, delta_nfa_reachable(ID,(C',_,_),_)}=N. + +% True sinking state +delta_nfa_final(ID,0) :- state_nfa(ID,()). +delta_nfa_final(ID,0,ID) :- state_nfa(ID,()). +final_state_nfa(ID) :- state_nfa(ID,()). + + + +#show state(X,L) : state_nfa(X,L). +#show initial_state(ID) : initial_state_nfa(ID). +#show delta(ID,C) : delta_nfa_final(ID,C). +#show delta(ID,C,N) : delta_nfa_final(ID,C,N). +#show delta(ID,C,T,P) : delta_nfa_final(ID,C,T,P). +#show prop/2. +#show final_state(ID) : final_state_nfa(ID). + +% #show delta_nfa_final/3. +% #show delta_nfa_set/3. +% #show delta_nfa_set/4. +% #show delta_nfa_set/5. +% % #show state_nfa_set/2. +% #show state_nfa_set_size/1. +% #show state_nfa_reachable/1. +% #show state_nfa_reachable/3. +% #show contradiction/2. \ No newline at end of file diff --git a/encodings/translations/afw_clean.lp b/encodings/translations/afw_clean.lp new file mode 100644 index 0000000..d3f1f12 --- /dev/null +++ b/encodings/translations/afw_clean.lp @@ -0,0 +1,42 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Clean up: +% % Keep reachable states and map to ids +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% -------------------- Remove contradicting cases: (C,in,A) and (C,out,A) +drop_delta(Q,C):- + delta_full(Q,C,NotOpt,P), + delta_full(Q,C,Opt,P), + NotOpt!=Opt. + +drop_delta(Q,C):- + delta_full(Q,C,bottom). + +% -------------------- Define reachable states +reachable(F) :- initial_state_full(F). +reachable(Q') :- delta_full(Q,C,Q'), reachable(Q), not drop_delta(Q,C). + +% -------------------- Assign ids to states +state(0,Q) :- initial_state_full(Q), #count{1,Q':initial_state_full(Q'),Q'Q', reachable(Q'), not state(0,Q')}=N. + +initial_state(ID):-initial_state_full(F),state(ID,F). + + +% -------------------- Assing id to cases +delta_case_id(Q,C,N) :- + delta_full(Q,C), not drop_delta(Q,C), + #count{Q,C2: delta_full(Q,C2), not drop_delta(Q,C2), C2>C}=N. +% delta_case_id(Q,C,C) :- +% delta(Q,C). + +% -------------------- Keep deltas from reachable states + +delta(Q_ID,C_ID) :- delta_full(Q,C), state(Q_ID,Q), not drop_delta(Q,C), delta_case_id(Q,C,C_ID). +delta(Q_ID,C_ID,T,P) :- delta(Q_ID,C_ID), delta_full(Q,C,T,P), state(Q_ID,Q), delta_case_id(Q,C,C_ID). +delta(Q_ID,C_ID,Q_ID') :- delta(Q_ID,C_ID), delta_full(Q,C,Q'), state(Q_ID,Q), state(Q_ID',Q'), delta_case_id(Q,C,C_ID). + + diff --git a/encodings/translations/afw_delta.lp b/encodings/translations/afw_delta.lp new file mode 100644 index 0000000..07eb39e --- /dev/null +++ b/encodings/translations/afw_delta.lp @@ -0,0 +1,209 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Delta: +% % Computes transtion for states +% % delta_full USES PREDICATES +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%----------------- Axiliary to copy all conditions and successor states +% copy_all +delta_full(Q2,C):- + copy_all(Q1,Q2), + delta_full(Q1,C). +copy_case((Q1,C),(Q2,C)):- + copy_all(Q1,Q2), + delta_full(Q1,C). +% copy_case +delta_full(Q2,C2,T,P):- + copy_case((Q1,C1),(Q2,C2)), + delta_full(Q1,C1,T,P). +delta_full(Q2,C2,Q'):- + copy_case((Q1,C1),(Q2,C2)), + delta_full(Q1,C1,Q'). + +%----------------- Prop +delta_full(prop(A),0):- + state_full(prop(A)). +delta_full(prop(A),0,in,A):- + state_full(prop(A)). + +%----------------- Neg +delta_full(neg(prop(A)),0):- + state_full(neg(prop(A))). +delta_full(neg(prop(A)),0,out,A):- + state_full(neg(prop(A))). + +%----------------- Boolean +delta_full(top,0):- + state_full(top). + +%----------------- Diamond + +%-------------------------------------- +% diamond(test(F1),F2) +%-------------------------------------- + + +% Conditions from F1 +delta_full(diamond(test(F1),F2),(CF1,CF2)) :- + state_full(diamond(test(F1),F2)), + delta_full(F1,CF1), + delta_full(F2,CF2). + +copy_case((F1,CF1),(diamond(test(F1),F2),(CF1,CF2))) :- + delta_full(diamond(test(F1),F2),(CF1,CF2)). +copy_case((F2,CF2),(diamond(test(F1),F2),(CF1,CF2))) :- + delta_full(diamond(test(F1),F2),(CF1,CF2)). + +%-------------------------------------- +% diamond(stp,F) +%-------------------------------------- + +%If not last then F +delta_full(diamond(stp,F),0) :- + state_full(diamond(stp,F)). +% Conditions +delta_full(diamond(stp,F),0,out,LAST) :- + prop(LAST,"last"), + delta_full(diamond(stp,F),0). +% Next +delta_full(diamond(stp,F),0,F) :- + delta_full(diamond(stp,F),0). + +%-------------------------------------- +% diamond(sequence(P1,P2),F) +%-------------------------------------- +copy_all(diamond(P1,diamond(P2,F)),diamond(sequence(P1,P2),F)) :- + state_full(diamond(sequence(P1,P2),F)), + state_full(diamond(P1,diamond(P2,F))). + +%-------------------------------------- +% diamond(choice(P1,P2),F) +%-------------------------------------- + +delta_full(diamond(choice(P1,P2),F),(0,CP1)):- + state_full(diamond(choice(P1,P2),F)), + delta_full(diamond(P1,F),CP1). +delta_full(diamond(choice(P1,P2),F),(1,CP2)):- + state_full(diamond(choice(P1,P2),F)), + delta_full(diamond(P2,F),CP2). + +copy_case((diamond(P1,F),CP1),(diamond(choice(P1,P2),F),(0,CP1))) :- + delta_full(diamond(choice(P1,P2),F),(0,CP1)). + +copy_case((diamond(P2,F),CP2),(diamond(choice(P1,P2),F),(1,CP2))) :- + delta_full(diamond(choice(P1,P2),F),(1,CP2)). + +%-------------------------------------- +% diamond(star(P1),F) +%-------------------------------------- + + +is_test(test(P)):-state_full(diamond(star(test(P)),F)). +% Test case +copy_all(F,diamond(star(test(P)),F)):- + state_full(diamond(star(test(P)),F)). + +% No Test case + +delta_full(diamond(star(P),F),(0,C)) :- + state_full(diamond(star(P),F)), not is_test(P), + delta_full(diamond(P,diamond(star(P),F)),C). + +delta_full(diamond(star(P),F),(1,C)) :- + state_full(diamond(star(P),F)), not is_test(P), + delta_full(F,C). + +copy_case((diamond(P,diamond(star(P),F)),C),(diamond(star(P),F),(0,C))):- + delta_full(diamond(star(P),F),(0,C)), not is_test(P). + +copy_case((F,C),(diamond(star(P),F),(1,C))):- + delta_full(diamond(star(P),F),(1,C)), not is_test(P). + +%----------------- Box + +%-------------------------------------- +% box(test(F1),F2) +%-------------------------------------- + + +delta_full(box(test(F1),F2),(0,CF1)):- + state_full(box(test(F1),F2)), + delta_full(F1',CF1), + nnf(neg(F1),F1'). +delta_full(box(test(F1),F2),(1,CF2)):- + state_full(box(test(F1),F2)), + delta_full(F2,CF2). + +copy_case((F1',CF1),(box(test(F1),F2),(0,CF1))):- + delta_full(box(test(F1),F2),(0,CF1)), + nnf(neg(F1),F1'). + +copy_case((F2,CF2),(box(test(F1),F2),(1,CF2))):- + delta_full(box(test(F1),F2),(1,CF2)). + +%-------------------------------------- +% box(stp,F) +%-------------------------------------- + +%If last then null +delta_full(box(stp,F),0) :- + state_full(box(stp,F)). +delta_full(box(stp,F),0,in,LAST) :- + prop(LAST,"last"), + delta_full(box(stp,F),0). + + +%If not last then F +delta_full(box(stp,F),1) :- + state_full(box(stp,F)). +delta_full(box(stp,F),1,out,LAST) :- + prop(LAST,"last"), + delta_full(box(stp,F),1). +delta_full(box(stp,F),1,F) :- + delta_full(box(stp,F),1). + +%-------------------------------------- +% box(sequence(P1,P2),F) +%-------------------------------------- + +copy_all(box(P1,box(P2,F)),box(sequence(P1,P2),F)) :- + state_full(box(sequence(P1,P2),F)), + state_full(box(P1,box(P2,F))). + + +%-------------------------------------- +% box(choice(P1,P2),F) +%-------------------------------------- + +delta_full(box(choice(P1,P2),F),(CP1,CP2)):- + state_full(box(choice(P1,P2),F)), + delta_full(box(P1,F),CP1), + delta_full(box(P2,F),CP2). + +copy_case((box(P1,F),CP1),(box(choice(P1,P2),F),(CP1,CP2))):- + delta_full(box(choice(P1,P2),F),(CP1,CP2)). + +copy_case((box(P2,F),CP2),(box(choice(P1,P2),F),(CP1,CP2))):- + delta_full(box(choice(P1,P2),F),(CP1,CP2)). + +%-------------------------------------- +% box(star(P1),F) +%-------------------------------------- + +is_test(test(P)):-state_full(box(star(test(P)),F)). + +copy_all(F,box(star(test(P)),F)):- + state_full(box(star(test(P)),F)). + +% No Test case + +delta_full(box(star(P),F),(C,CF)) :- + state_full(box(star(P),F)), not is_test(P), + delta_full(box(P,box(star(P),F)),C), + delta_full(F,CF). + +copy_case((box(P,box(star(P),F)),C),(box(star(P),F),(C,CF))):- + delta_full(box(star(P),F),(C,CF)), not is_test(P). + +copy_case((F,CF),(box(star(P),F),(C,CF))):- + delta_full(box(star(P),F),(C,CF)), not is_test(P). diff --git a/encodings/translations/afw_prop.lp b/encodings/translations/afw_prop.lp new file mode 100644 index 0000000..5abe3ee --- /dev/null +++ b/encodings/translations/afw_prop.lp @@ -0,0 +1,61 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Propositional atoms: +% % Gets the ids for all atomic propositions in the formula +% % used to generate the alphabet +% % +% % prop(ID,PROP) +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%TEL Operators +operator("~"). operator(">"). operator(">:"). +operator(">?"). operator(">*"). operator("&"). +operator("|"). operator(">?"). + +%DEL Operators +operator(";;"). operator("+"). operator("?"). +operator("*"). operator("~"). operator("&"). +operator(".>?"). operator(".>*"). + +reserved_words("holds"). +reserved_words("trace"). +reserved_words("last"). +reserved_words("true"). +reserved_words("t"). +reserved_words("false"). + +pos_prop_id(ID) :- theory_function(ID,ID_O,ID_T), + theory_string(ID_O,P), + not operator(P), + not reserved_words(P). + +pos_prop_id(ID) :- theory_string(ID,P), + not operator(P), + not reserved_words(P). + +% Remove arguments of atoms from the prop: +% Example: Remove robot(1) when only appearing in move(robot(1)). +prop_id(ID) :- pos_prop_id(ID), + #count{1,ID_PARENT: theory_function(ID_PARENT, _, ID_T), + theory_tuple(ID_T,0..MAX,ID), + not pos_prop_id(ID_PARENT)} > 0, + #max{D:theory_tuple(_,D,_)}=MAX. + +% Include also proposition when the whole formula is a proposition +prop_id(ID) :- pos_prop_id(ID), + theory_atom(ID_A,ID_O,ID_E), + theory_element(ID_E,ID_T,_), + theory_tuple(ID_T,0,ID). + +% Creates special proposition "last" +used_id(ID) :- theory_string(ID,Q), Q!="last". +used_id(ID) :- theory_function(ID,IDS,_), theory_string(IDS,Q), Q!= "last". +last_id(MID+1):- #max{ID:used_id(ID)}=MID. + + +% Mappings from ids to readable format +#include "id_map.lp". + + +prop(ID,PROP):-id_map(ID,PROP), prop_id(ID). +prop(ID,"last"):- last_id(ID). + diff --git a/encodings/translations/afw_states.lp b/encodings/translations/afw_states.lp new file mode 100644 index 0000000..b702640 --- /dev/null +++ b/encodings/translations/afw_states.lp @@ -0,0 +1,152 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % States: +% % Computes all states for automaton using +% % fisher lander closure and negation normal form +% % state_full USES PREDICATES +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%-------------------- Initial state -------------------------- +initial_state_full(F) :- theory_atom(ID_A,ID_O,ID_E), + theory_string(ID_O,"del"), + theory_element(ID_E,ID_T,_), + theory_tuple(ID_T,0,ID), + theory_id_to_predicate(ID,F). + +%-------------------- Fish lander closure to define states ------ + +%%%%%% Transforming theory ids into nested predicate + +% Proposition +theory_id_to_predicate(ID,prop(ID)) :- + prop_id(ID). + +% Step +theory_id_to_predicate(ID,stp) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"&"), + theory_tuple(ID_T,0,ID_L), + theory_string(ID_L,"t"). + +% Top +theory_id_to_predicate(ID,top) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"&"), + theory_tuple(ID_T,0,ID_L), + theory_string(ID_L,"true"). + +% Bottom +theory_id_to_predicate(ID,bottom) :- theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"&"), + theory_tuple(ID_T,0,ID_L), + theory_string(ID_L,"false"). + +% Negation +theory_id_to_predicate(ID,neg(FL)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"~"), + theory_tuple(ID_T,0,ID_L), + theory_id_to_predicate(ID_L,FL). + +% Diamond +theory_id_to_predicate(ID,diamond(FL,FR)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,".>?"), + theory_tuple(ID_T,0,ID_L), + theory_tuple(ID_T,1,ID_R), + theory_id_to_predicate(ID_L,FL), + theory_id_to_predicate(ID_R,FR). + +% Box +theory_id_to_predicate(ID,box(FL,FR)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,".>*"), + theory_tuple(ID_T,0,ID_L), + theory_tuple(ID_T,1,ID_R), + theory_id_to_predicate(ID_L,FL), + theory_id_to_predicate(ID_R,FR). + +%%%%%%%%%% Paths + +% Test +theory_id_to_predicate(ID,test(FL)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"?"), + theory_tuple(ID_T,0,ID_L), + theory_id_to_predicate(ID_L,FL). + +% Sequence +theory_id_to_predicate(ID,sequence(FL,FR)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,";;"), + theory_tuple(ID_T,0,ID_L), + theory_tuple(ID_T,1,ID_R), + theory_id_to_predicate(ID_L,FL), + theory_id_to_predicate(ID_R,FR). + +% Choice +theory_id_to_predicate(ID,choice(FL,FR)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"+"), + theory_tuple(ID_T,0,ID_L), + theory_tuple(ID_T,1,ID_R), + theory_id_to_predicate(ID_L,FL), + theory_id_to_predicate(ID_R,FR). + +% Star +theory_id_to_predicate(ID,star(FL)) :- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"*"), + theory_tuple(ID_T,0,ID_L), + theory_id_to_predicate(ID_L,FL). + +%Keep only formulas and not paths + +dynamic_formula(prop(ID)) :- theory_id_to_predicate(_,prop(ID)). +dynamic_formula(neg(F)) :- theory_id_to_predicate(_,neg(F)). +dynamic_formula(top) :- theory_id_to_predicate(_,top). +dynamic_formula(bottom) :- theory_id_to_predicate(_,bottom). +dynamic_formula(diamond(FL,FR)) :- theory_id_to_predicate(_,diamond(FL,FR)). +dynamic_formula(box(FL,FR)) :- theory_id_to_predicate(_,box(FL,FR)). + +%Generate Fisher-Lander closure from predicates + +closure(F) :- dynamic_formula(F). + +closure(X) :- closure(neg(X)). +closure(neg(prop(ID))) :- closure(prop(ID)). +closure(neg(bottom)) :- closure(bottom). +closure(neg(top)) :- closure(top). +closure(neg(diamond(X,Z))) :- closure(diamond(X,Z)). +closure(neg(box(X,Z))) :- closure(box(X,Z)). + +closure(diamond(X,Z)) :- closure(diamond(choice(X,Y),Z)). +closure(diamond(Y,Z)) :- closure(diamond(choice(X,Y),Z)). +closure(diamond(X,diamond(Y,Z))) :- closure(diamond(sequence(X,Y),Z)). +closure(diamond(X,diamond(star(X),Z))) :- closure(diamond(star(X),Z)). +closure(Z) :- closure(diamond(_,Z)). + +closure(box(X,Z)) :- closure(box(choice(X,Y),Z)). +closure(box(Y,Z)) :- closure(box(choice(X,Y),Z)). +closure(box(X,box(Y,Z))) :- closure(box(sequence(X,Y),Z)). +closure(box(X,box(star(X),Z))) :- closure(box(star(X),Z)). +closure(Z) :- closure(box(_,Z)). + +%Negation normal form for formulas in the closure +nnf(neg(neg(X)),X):-closure(neg(X)). +nnf(neg(bottom),top). +nnf(neg(top),bottom). +nnf(neg(prop(ID)),neg(prop(ID))) :- closure(neg(prop(ID))). +nnf(neg(diamond(X,Z)),box(X,Z')) :- closure(neg(diamond(X,Z))),nnf(neg(Z),Z'). +nnf(neg(box(X,Z)),diamond(X,Z')) :- closure(neg(box(X,Z))),nnf(neg(Z),Z'). + +nnf(top,top). +nnf(bottom,bottom). +nnf(prop(ID),prop(ID)) :- closure(prop(ID)). +nnf(diamond(X,Z),diamond(X,Z)) :- closure(diamond(X,Z)). +nnf(box(X,Z),box(X,Z)) :- closure(box(X,Z)). + + + +%State predicate +state_full(X') :- closure(X), nnf(X,X'). diff --git a/encodings/translations/grammar.lp b/encodings/translations/grammar.lp new file mode 100644 index 0000000..46b7c16 --- /dev/null +++ b/encodings/translations/grammar.lp @@ -0,0 +1,19 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Theory: +% % Defines the syntax for the formulas +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +#theory del { + formula_body { + & : 7, unary; % prefix for Boolean constants + ~ : 5, unary; % negation + ? : 4, unary; % test + * : 3, unary; % kleene star + + : 2, binary, left; % choice + ;; : 1, binary, left; % sequence + .>? : 0, binary, right; % diamond (eventually) + .>* : 0, binary, right % box (always) + }; + &del/0 : formula_body, body +}. + diff --git a/encodings/translations/id_map.lp b/encodings/translations/id_map.lp new file mode 100644 index 0000000..7467868 --- /dev/null +++ b/encodings/translations/id_map.lp @@ -0,0 +1,96 @@ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Id map: +% % Maps ids used in reified formula and into predicates +% % to visualize propositions +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +id_map(ID,(P)):- + theory_string(ID,P). + +id_map(ID,(P)):- + theory_number(ID,P). + + +% ------- Sequence + +% Arity 1 +id_map(ID,("",MAP_0)):- + theory_sequence(ID,tuple,ID_T), + theory_tuple(ID_T,0,ID_0), + not theory_tuple(ID_T,1,_), + id_map(ID_0,MAP_0). + +% Arity 2 +id_map(ID,("",MAP_0,MAP_1)):- + theory_sequence(ID,tuple,ID_T), + theory_tuple(ID_T,0,ID_0), + theory_tuple(ID_T,1,ID_1), + not theory_tuple(ID_T,2,_), + id_map(ID_0,MAP_0), + id_map(ID_1,MAP_1). + +% Arity 3 +id_map(ID,("",MAP_0,MAP_1,MAP_2)):- + theory_sequence(ID,tuple,ID_T), + theory_tuple(ID_T,0,ID_0), + theory_tuple(ID_T,1,ID_1), + theory_tuple(ID_T,2,ID_2), + not theory_tuple(ID_T,3,_), + id_map(ID_0,MAP_0), + id_map(ID_1,MAP_1), + id_map(ID_2,MAP_2). + + +% ------- Function + +% Arity 1 +id_map(ID,-MAP_0):- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,"-"), + theory_tuple(ID_T,0,ID_0), + not theory_tuple(ID_T,1,_), + id_map(ID_0,MAP_0). + +% Arity 1 +id_map(ID,(P,MAP_0)):- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,P), P!="-", + theory_tuple(ID_T,0,ID_0), + not theory_tuple(ID_T,1,_), + id_map(ID_0,MAP_0). + +% Arity 2 +id_map(ID,(P,MAP_0,MAP_1)):- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,P), + theory_tuple(ID_T,0,ID_0), + theory_tuple(ID_T,1,ID_1), + not theory_tuple(ID_T,2,_), + id_map(ID_0,MAP_0), + id_map(ID_1,MAP_1). + +% Arity 3 +id_map(ID,(P,MAP_0,MAP_1,MAP_2)):- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,P), + theory_tuple(ID_T,0,ID_0), + theory_tuple(ID_T,1,ID_1), + theory_tuple(ID_T,2,ID_2), + not theory_tuple(ID_T,3,_), + id_map(ID_0,MAP_0), + id_map(ID_1,MAP_1), + id_map(ID_2,MAP_2). + +% Arity 4 +id_map(ID,(P,MAP_0,MAP_1,MAP_2,MAP_3)):- + theory_function(ID,ID_O,ID_T), + theory_string(ID_O,P), + theory_tuple(ID_T,0,ID_0), + theory_tuple(ID_T,1,ID_1), + theory_tuple(ID_T,2,ID_2), + theory_tuple(ID_T,3,ID_3), + not theory_tuple(ID_T,4,_), + id_map(ID_0,MAP_0), + id_map(ID_1,MAP_1), + id_map(ID_2,MAP_2), + id_map(ID_3,MAP_3). diff --git a/encodings/translations/joinafw.lp b/encodings/translations/joinafw.lp new file mode 100644 index 0000000..1b2918e --- /dev/null +++ b/encodings/translations/joinafw.lp @@ -0,0 +1,114 @@ + + +%--- diamond(test(F1),F2) + +initial_state_new(N):-#count{1,Q:state(Q,QNAME)}=N. +state_new(N,box(stp,top)):-initial_state_new(N). + +% join_initial(Q,(Q,())):-initial_state(Q), #count{1,Q2:initial_state(Q2),Q>Q2}=0. + +next_initial(Q,null):-initial_state(Q), #false :initial_state(Q2), QQ, #false :initial_state(Q2), Q2Q. + +cases(Q,M):- #count{1,C: delta(Q,(C,_,_),_)}=M, initial_state(Q). + +% Cases from base + +delta_join(Q,C):- + next_initial(Q,null), + delta(Q,C). +delta_join(Q,C,Q'):- + next_initial(Q,null), + delta(Q,C,Q'). +delta_join(Q,C,T,P):- + next_initial(Q,null), + delta(Q,C,T,P). + + +% Join base with next + +delta_join1(Q2,(CF1,CF2)) :- + delta_join(Q1,CF1), + delta(Q2,CF2), + next_initial(Q2,Q1). + +delta_join1(Q2,(CF1,CF2),Q') :- + delta_join(Q1,CF1), + delta(Q2,CF2,Q'), + next_initial(Q2,Q1). + +delta_join1(Q2,(CF1,CF2),Q') :- + delta_join(Q1,CF1,Q'), + delta(Q2,CF2), + next_initial(Q2,Q1). + +delta_join1(Q2,(CF1,CF2),T,P) :- + delta_join(Q1,CF1), + delta(Q2,CF2,T,P), + next_initial(Q2,Q1). + +delta_join1(Q2,(CF1,CF2),T,P) :- + delta_join(Q1,CF1,T,P), + delta(Q2,CF2), + next_initial(Q2,Q1). + +% -------------------- Remove contradicting cases: (C,in,A) and (C,out,A) +delta_join(Q,C):- delta_join1(Q,C), not drop_delta(C,Q). +delta_join(Q,C,Opt,A):- delta_join1(Q,C,Opt,A), not drop_delta(C,Q). +delta_join(Q,C,Q'):- delta_join1(Q,C,Q'), not drop_delta(C,Q). + +drop_delta(C,Q):- + delta_join1(Q,C,Opt,A), + delta_join1(Q,C,NotOpt,A), + NotOpt!=Opt. + +% -------------------- Idea to Remove cases contained in others + +% drop_delta(C,Q):- +% delta_join(Q,(C,_,_),Q'), +% delta_join(Q,(C2,_,_),_), +% C /dev/null 2>&1 + + @ printf "$(G)Pdf saved in $(PATH_OUT)/$(APP)_automata.pdf $(NC)\n";\ + + open $(PATH_OUT)/$(APP)_automata.pdf + +viz-png: + @ printf "$BVisualizing APP=$(APP) DOM=$(DOM) CONSTRAINT=$(CONSTRAINT)$ INSTANCE=$(NAME_INSTANCE) HORIZON=$(HORIZON) $(NC)\n" + + python scripts/viz.py --app=$(APP) --dom=$(DOM) --instance=$(NAME_INSTANCE) --constraint=$(CONSTRAINT) --instance_path=$(INSTANCE) + + @ printf "$(G)PNG saved in $(PATH_OUT) $(NC)\n";\ + + open $(PATH_OUT)/$(APP)_automata.png + + +tests: + @ printf "$(B)Running 'del' tests...$(NC)" + @ python -m unittest tests.del_test + +stats: + tail -32 $(PATH_OUT)/plan_h-$(HORIZON)_n-$(MODELS).txt + +translate: + + @ printf "$BTranslating APP=$(APP) DOM=$(DOM) CONSTRAINT=$(CONSTRAINT) INSTANCE=$(NAME_INSTANCE) $(NC)\n" + + @ make translate-$(APP) + + @if [ -s $(PATH_OUT)/$(APP)_automata.lp ]; then\ + printf "$(G)Translation to $(APP) successfull. \nOutput saved in $(PATH_OUT)/$(APP)_automata.lp $(NC)\n";\ + else \ + printf "$(R) Translation to $(APP) failed no output automata\n";\ + exit 1;\ + fi; + +empty: + + @make translate; + + clingo $(PATH_OUT)/$(APP)_automata.lp encodings/empty.lp --warn=none + + +run: + + @ printf "$BRunning APP=$(APP) DOM=$(DOM) CONSTRAINT=$(CONSTRAINT)$ INSTANCE=$(NAME_INSTANCE) HORIZON=$(HORIZON) $(NC)\n" + + @rm -f $(PATH_OUT)/plan_h-$(HORIZON)_n-$(MODELS).txt + + clingo $(PATH_OUT)/$(APP)_automata.lp $(INSTANCE) $(RUN_APP_FILES_$(APP)) $(RUN_DOM_FILES_$(DOM)) $(EXTRA) -c horizon=$(HORIZON) -n $(MODELS) | tee $(PATH_OUT)/plan_h-$(HORIZON)_n-$(MODELS).txt + +translate-run: + + @if [ "$(APP)" = "nc" ]; then\ + echo "$(Y)No constrain option$(NC)";\ + clingo --stats $(INSTANCE) $(RUN_DOM_FILES_$(DOM)) -c horizon=$(HORIZON) -n $(MODELS) | tee $(PATH_OUT)/plan_h-$(HORIZON)_n-$(MODELS).txt;\ + exit 1;\ + fi + @if [ "$(FORCE_TRANSLATE)" = "1" ]; then \ + make translate;\ + elif [ "$(APP)" = "telingo" ]; then\ + make translate;\ + else\ + if [ -s $(PATH_OUT)/$(APP)_automata.lp ]; then\ + echo "$(Y)Skipping translation$(NC)";\ + else\ + echo "$(Y)Making translation since file is missing$(NC)";\ + make translate;\ + fi;\ + fi + + # @ make translate + + @ make run + + +###################### AFW ######################## + +translate-afw: + + @if [ "$(APP)" = "afw" ]; then echo ""; else echo "$(R)Inconsistency APP should be afw$(NC)"; fi + + @ printf "$BReifying constraint... $(NC)\n" + + gringo encodings/translations/grammar.lp $(PATH_INPUT).lp $(INSTANCE) $(TRANSLATE_FILES_$(DOM)) --output=reify > $(PATH_OUT)/reified.lp + + + @if grep theory_atom $(PATH_OUT)/reified.lp -q; then\ + printf "$(G)Reification successfull $(NC)\n";\ + else \ + printf "$(R)Reification failed, theory was not reified\n";\ + exit 1;\ + fi; + + @ printf "$(B)Translating.... $(NC)\n" + clingo $(PATH_OUT)/reified.lp ./encodings/translations/ldlf2afw.lp -n 0 --outf=0 -V0 --out-atomf=%s. --warn=none | head -n1 | tr ". " ".\n" > $(PATH_OUT)/afw_automata.lp + + + @if [ "$(JOIN)" = "1" ]; then \ + printf "$(Y)Joining afw... $(NC)\n";\ + clingo encodings/translations/joinafw.lp $(PATH_OUT)/afw_automata.lp -n 0 --outf=0 -V0 --out-atomf=%s. --warn=none | head -n1 | tr ". " ".\n" > $(PATH_OUT)/tmp_afw_automata.lp ;\ + cat $(PATH_OUT)/tmp_afw_automata.lp > $(PATH_OUT)/afw_automata.lp;\ + rm $(PATH_OUT)/tmp_afw_automata.lp;\ + printf "$(G)Join afw successfull $(NC)\n";\ + fi; + + + + + +###################### TELINGO ######################## + +translate-telingo: + $(eval TELINGO_TRANSLATE_FILES = ) + + $(foreach n,$(TRANSLATE_FILES_$(DOM)),$(if $(n),$(eval TELINGO_TRANSLATE_FILES=$(TELINGO_TRANSLATE_FILES) $(PATH_FROM_TELINGO)/$(n) ))) + + (cd benchmarks/telingo ; python telingo/program_observer.py --h=$(HORIZON) --out-file=$(PATH_FROM_TELINGO)/$(PATH_OUT)/telingo_automata.lp --extra-files="$(TELINGO_TRANSLATE_FILES)" --choices-file=$(PATH_FROM_TELINGO)/dom/$(DOM)/telingo_choices.lp --instance-file=$(PATH_FROM_TELINGO)/$(INSTANCE) --constraint-file=$(PATH_FROM_TELINGO)/$(PATH_INPUT).lp ) + + +###################### DFA ######################## + + +translate-dfa-mso: + + + python ./scripts/translater.py --input=ldlf --app=dfa-mso --out-file=$(PATH_OUT)/dfa-mso_automata.lp --in-files='./$(PATH_INPUT).lp $(TRANSLATE_FILES_$(DOM)) $(INSTANCE)' $(PY_PARAMS) + + +translate-dfa-stm: + + + python ./scripts/translater.py --input=ldlf --app=dfa-stm --out-file=$(PATH_OUT)/dfa-stm_automata.lp --in-files="./$(PATH_INPUT).lp $(TRANSLATE_FILES_$(DOM)) $(INSTANCE)" $(PY_PARAMS) + +###################### NFA ######################## + + +translate-nfa: + + @ make translate-afw APP=afw CONSTRAINT=$(CONSTRAINT) INSTANCE=$(INSTANCE) DOM=$(DOM) TRANSLATE_FILES=$(TRANSLATE_FILES_$(APP)) $(PY_PARAMS) + + python ./scripts/translater.py --input=afw --app=nfa --out-file=$(PATH_OUT)/nfa_automata.lp --in-files=./outputs/$(DOM)/afw/$(CONSTRAINT)/$(NAME_INSTANCE)/afw_automata.lp + +translate-nfa-afw: + + @ make translate-afw APP=afw CONSTRAINT=$(CONSTRAINT) INSTANCE=$(INSTANCE) DOM=$(DOM) TRANSLATE_FILES=$(TRANSLATE_FILES_$(APP)) $(PY_PARAMS) + + clingo ./outputs/$(DOM)/afw/$(CONSTRAINT)/$(NAME_INSTANCE)/afw_automata.lp ./encodings/translations/afw2nfa.lp -n 0 --outf=0 -V0 --out-atomf=%s. --warn=none | head -n1 | tr ". " ".\n" > $(PATH_OUT)/nfa-afw_automata.lp + +###################### ASPRILO EXTRA ################### + +viz-asprilo: + sed -n "4,5p" $(PATH_OUT)/plan_h-$(HORIZON)_n-$(MODELS).txt | viz + diff --git a/pystructures/automata.py b/pystructures/automata.py new file mode 100644 index 0000000..518592b --- /dev/null +++ b/pystructures/automata.py @@ -0,0 +1,403 @@ +import json +import re +from graphviz import Digraph, Source +import clingo as _clingo +import itertools +import dot2tex + +def de_tuple_str_symbol(term): + if (term.type == _clingo.SymbolType.String): + return str(term) + elif (term.type == _clingo.SymbolType.Number): + return str(term) + elif (term.type == _clingo.SymbolType.Function): + args = term.arguments + assert term.name=="" and len(args)>0 + args_str = ",".join([de_tuple_str_symbol(a) for a in args[1:]]) + return f"{str(args[0])}({args_str})".replace('"',"") + else: + print("Found an invalid form of prop") + assert False + +class State(): + def __init__(self, s_id, label): + self._label = label + self._id = int(s_id) + + def __str__(self): + return str(self._label) + +class Condition(): + def __init__(self, included, not_included): + self._included = included + self._not_included = not_included + + @classmethod + def from_str(cls, s, prop2id): + s = s.strip('"') + included = [] + not_included = [] + s = s.split(" & ") + for c in s: + next_id = len(prop2id) + if c[0]=="~": + p_name=c[1:] + prop2id.setdefault(p_name,next_id) + not_included.append(prop2id[p_name]) + else: + p_name=c + prop2id.setdefault(p_name,next_id) + included.append(prop2id[p_name]) + return cls(included, not_included) + + def get_props(self): + return set(self._included+self._not_included) + + def str_names(self,names): + elems = [] + if len(self._included)>0: + elems.append("& ".join([names[i] for i in self._included])) + if len(self._not_included)>0: + elems.append("& ".join(["~ "+ names[i] for i in self._not_included])) + + return "& ".join(elems).replace('"','') + + def is_taut(self): + return len(self._included)+len(self._not_included)==0 + + def __str__(self): + not_included = "" + if len(self._not_included)>0: + not_included = "& ~".join([""]+[str(i) for i in self._not_included]) + return "& ".join([str(i) for i in self._included]) + not_included + +class Automata(): + + def __init__(self, props, states, transitions, initial_states_ids, final_states_ids, dot = None): + self._props = {i:p.replace('"',"").replace("'","") for i,p in props.items()} + self._states = states + self._transitions = transitions + self._initial_states_ids = initial_states_ids + self._final_states_ids = final_states_ids + + @property + def initial_states(self): + return [self._states[s] for s in self._initial_states_ids] + + def tikz(self): + pass + + def to_dic(self): + j = { + 'props': self._props, + 'states': {i:str(s) for i, s in self._states.items()}, + 'initial_states': self._initial_states_ids, + 'transition': {i : {str(c) : n for c, n in v.items()} for i, v in self._transitions.items()}, + 'final_states': list(self._final_states_ids), + } + return j + + @classmethod + def from_lp(cls, files=[], inline_data=""): + from pystructures.ldlf import LDLfFormula + + ctl = _clingo.Control([], message_limit=0) + ctl.add("base", [], "") + for f in files: + ctl.load(f) + ctl.add("base", [], inline_data) + ctl.ground([("base", [])]) + states = {} + trans = {} + initial_states = [] + final_states = [] + id2prop = {} + cases = {} + for sa in ctl.symbolic_atoms: + s = sa.symbol + i = s.arguments[0].number + n_args = len(s.arguments) + if s.name == 'initial_state': + initial_states.append(i) + elif s.name == 'prop': + id2prop[i] = de_tuple_str_symbol(s.arguments[1]).replace('"','') + elif s.name == 'state': + formula = LDLfFormula.from_symbol(s.arguments[1],id2prop) + states[i] = State(i,str(formula)) + elif s.name == 'delta': + case = str(s.arguments[1]) + trans.setdefault(i,{}).setdefault(case,[]) + cases.setdefault(i,{}).setdefault(case,([],[])) + # if n_args==2: + if n_args==3: + n_to = s.arguments[2].number + trans[i][case].append(n_to) + elif n_args==4: + pos = 0 if s.arguments[2].name == "in" else 1 + prop = s.arguments[3].number + cases[i][case][pos].append(prop) + elif n_args!=2: + raise RuntimeError("Invalid format in predicate " + str(s)) + + elif s.name == "final_state": + final_states.append(i) + + cases_classes = {} + for s_from, dic_c in cases.items(): + cases_classes[s_from] = {} + for c_id, tup in dic_c.items(): + cases_classes[s_from][c_id]=Condition(tup[0],tup[1]) + + transitions = {} + for s_from, dic_c in trans.items(): + transitions[s_from]={} + for c_id,s2 in dic_c.items(): + con = cases_classes[s_from][c_id] + transitions[s_from].setdefault(con,[]).append(s2) + + return cls(id2prop,states,transitions,initial_states,set(final_states),"") + + + def dot(self, latex = False, labels =True): + dot = 'digraph ATLINGO {\n' + dot += 'rankdir = LR;\n' + dot += 'center = true;\n' + dot += 'size = "50,50";\n' + # General def + dot += 'edge [fontname = Courier arrowhead=vee arrowsize=0.5 penwidth= .8 lblstyle="font=\\tiny"];\n' + dot += 'node [height = .5, width = .5];\n' + # Nodes + for i, s in self._states.items(): + label = s._label if labels else s._id + if labels and latex: + label = label.replace("<","\\deventually{").replace("[","\\dalways{") + label = label.replace("&t","\\stp") + label = label.replace("&true","\\top") + label = label.replace("&false","\\bot") + label = label.replace("~","\\neg") + label = label.replace(";;",";").replace("*","^*") + label = label.replace("]","}").replace(">","}") + label = "q_{{{}}}".format(label) + shape= 'circle' + if s._id in self._final_states_ids: + shape = 'doublecircle' + dot += 'node [shape = {} label= "{}"] {};\n'.format(shape, label,s._id) + dot += 'init [shape = plaintext, label = " "];\n' + + branch_format = 'shape = point width = .05 height = .05 label=" " ' + # True transition for AFW + if isinstance(self,AFW): + if latex: + branch_format = 'color=white shape = circle width = .3 height = .3 label="\\forall"' + # Initial Node + for init_i in self._initial_states_ids: + dot += f'init -> {init_i};\n' + # Transitions + and_id=0 + for s_from, v in self._transitions.items(): + for c, s_tos in v.items(): + label = c.str_names(self._props) + if latex: + label = label.replace("&","\\wedge") + label = label.replace("~","-") + for s_to in s_tos: + if isinstance(s_to,int) or len(s_to)==1: + s_to_int = s_to if isinstance(s_to,int) else s_to[0] + dot += '{} -> {} [label="{}"];\n'.format(s_from, s_to_int, label) + continue + dot += 'and{} [{}];\n'.format(and_id,branch_format) + dot += '{} -> and{} [label="{}" arrowhead=none];\n'.format(s_from, and_id, label) + for s in s_to: + dot += "and{} -> {};\n".format(and_id, s) + and_id+=1 + + dot += '}' + return dot + + def to_tex(self, file="./outputs/automata.tex", labels=False): + testgraph = self.dot(latex=True,labels=labels) + texcode = dot2tex.dot2tex(testgraph, format='tikz', texmode='math',crop=True,margin="20pt") + with open(file,'w') as f: + macros = """ + \\newcommand{\\dalways}[1]{\\ensuremath{[#1]\\,}} + \\newcommand{\\deventually}[1]{\\ensuremath{\\langle#1\\rangle\\,}} + \\newcommand{\\stp}{\\ensuremath{\\tau}} + """ + f.write(macros) + f.write(texcode.replace("wedge","\\wedge").replace("join=bevel,","join=bevel,scale=0.4")) + + def save_png(self, file="outputs/automata_viz",labels =True, latex=False): + dot = self.dot(labels=labels,latex=latex) + s = Source(dot) + s.render(file, format="png") + + def __str__(self): + return json.dumps(self.to_dic(),indent=4) + + +class NFA(Automata): + + def __init__(self, *args): + super(NFA,self).__init__(*args) + + @classmethod + def from_mona(cls, mona, n_old_states=0, state_prefix="", id2prop=None, mona2prop=None): + if mona == False: + print("Error in mona: \n{}".format(mona)) + raise TimeoutError(mona) + if "Execution aborted" in mona: + print("Error in mona: \n{}".format(mona)) + raise TimeoutError(mona) + if "BDD too large " in mona[:20]: + print("Error in mona: \n{}".format(mona)) + raise TimeoutError(mona) + + + id2prop = {} if id2prop is None else id2prop + states = {} + + def get_state(state_name): + s_id = int(state_name)+n_old_states + if s_id not in states: + states[s_id] = State(s_id, f"{state_prefix}{state_name}") + return states[s_id] + + # Alphabet + vrs = re.findall(r'(?<=DFA for formula with free variables:\s).*?(?=\s\n)',mona) + vrs = vrs[0].split(" ") if len(vrs)>0 else [] + id2prop = id2prop + prop2id = {v:k for k,v in id2prop.items()} + newid2oldid = {} + + for new_id,prop in enumerate(vrs): + prop = mona2prop[prop] + if prop in prop2id: + newid2oldid[new_id]=prop2id[prop] + else: + next_id = len(id2prop) + id2prop[next_id]=prop + newid2oldid[new_id]=next_id + if not "last" in prop2id: + id2prop[len(id2prop)]="last" + + # Final states + f_states = re.findall(r'(?<=Accepting states:\s).*?(?=\s\n)',mona) + final = [get_state(f_id)._id for f_id in f_states[0].split(" ")] if len(f_states)>0 else [] + + # Transitions and states + trans = re.findall(r'(?<=State\s).*?(?=\n)',mona) + t_reg = r'(\d+):\s([X01]*)\s\->\sstate\s(.+)' + transitions = {} + for t in trans[1:]: + res = re.match(t_reg,t).groups() + n_from = get_state(res[0]) + n_to = get_state(res[2]) + in_prop = [newid2oldid[i] for i,v in enumerate(res[1]) if v=='1'] + out_prop = [newid2oldid[i] for i,v in enumerate(res[1]) if v=='0'] + c = Condition(in_prop,out_prop) + transitions.setdefault(n_from._id,{})[c]=[n_to._id] + + initial_states_ids = [n_old_states+1] + return cls(id2prop,states,transitions,initial_states_ids,set(final),"") + + def to_lp(self, state_prefix = ""): + def tos(s_id): + return state_prefix+str(s_id) + p = "" + for i, prop in self._props.items(): + p+=('prop({},"{}").\n').format(i,prop) + # p+=('prop({},"last").\n').format(len(self._props)) + + for i, s in self._states.items(): + p+=('state({},"{}").\n').format(tos(s._id),s._label) + for init_i in self._initial_states_ids: + p+=('initial_state({}).\n').format(tos(init_i)) + + for s_from, v in self._transitions.items(): + c_id = 0 + for c, s_tos in v.items(): + p+=('delta({},{}).\n').format(tos(s_from),c_id) + for s_to in s_tos: + p+=('delta({},{},{}).\n').format(tos(s_from),c_id,tos(s_to)) + for prop_in in c._included: + p+=('delta({},{},in,{}).\n').format(tos(s_from),c_id,prop_in) + for prop_in in c._not_included: + p+=('delta({},{},out,{}).\n').format(tos(s_from),c_id,prop_in) + + c_id=c_id+1 + for s in self._final_states_ids: + p+=('final_state({}).\n').format(tos(s)) + + p+=('%------- Definition of trace --------.\n') + for i, prop in self._props.items(): + if prop == "null": + continue + if prop[-1]==")": + p_with_t = prop[:-1]+",T)" + else: + p_with_t = prop+"(T)" + p+=('trace({},T):- {}.\n').format(i,p_with_t) + + return p + + +class AFW(Automata): + + def __init__(self, *args): + super(AFW,self).__init__(*args) + + + def to_nfa(self): + id2state = {} + tuple2state = {} + new_states = set([]) + + def get_state(l): + l.sort() + t = tuple(l) + if not t in tuple2state: + s = State(len(tuple2state),t) + new_states.add(s) + tuple2state[t]=s + return tuple2state[t] + + final = get_state([])._id + initial_states = [get_state([i]) for i in self._initial_states_ids] + transitions = {} + while not len(new_states)==0: + + s=new_states.pop() + + options_per_state = [[] for i in s._label] + for i, s_afw in enumerate(s._label): + if s_afw == "null" or not s_afw in self._transitions: + continue + options_per_state[i]=[] + for c,s_nexts in self._transitions[s_afw].items(): + for s_next in s_nexts: + options_per_state[i].append((c,s_next)) + combinations = list(itertools.product(*options_per_state)) + + for comb_t in combinations: + in_p = [] + out_p = [] + next_l = [] + for c, s_next in comb_t: + in_p=in_p+c._included + out_p=out_p+c._not_included + next_l = next_l + s_next + + contradict = any(p in out_p for p in in_p) + if contradict: + continue + s_to = get_state(next_l) + case = Condition(in_p,out_p) + transitions.setdefault(s._id,{}).setdefault(case,[]).append(s_to._id) + + for i, state in tuple2state.items(): + state._label = "{{ {} }}".format(", ".join([str(x) for x in state._label])) + + id2state = {s._id:s for s in tuple2state.values()} + print(id2state) + return NFA({i:p for i,p in self._props.items()},id2state,transitions,[i._id for i in initial_states],set([final]),"") + diff --git a/pystructures/ldlf.py b/pystructures/ldlf.py new file mode 100644 index 0000000..4c1ba9f --- /dev/null +++ b/pystructures/ldlf.py @@ -0,0 +1,715 @@ +import pathlib +import random +import tempfile +import os +import clingo as _clingo +import sys +from pystructures.automata import NFA, AFW +from subprocess import PIPE, Popen, TimeoutExpired +import os +import signal + +def invoke_mona(name): + command = f"mona -q -w {name}" + process = Popen( + args=command, + stdout=PIPE, + stderr=PIPE, + preexec_fn=os.setsid, + shell=True, + encoding="utf-8", + ) + try: + output, error = process.communicate(timeout=30) + return str(output).strip() + except TimeoutExpired: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) + return False + +# Used in del theory +del_operators = {".>*":'Box', ".>?":'Diamond',"&": "Boolean","~": "Prop"} +path_unary_operators = {"*":'KleeneStar', "?":'Check', "&": "Skip"} +path_binary_operators = {";;":'Sequence', "+":'Choice'} +path_operators = dict(path_unary_operators) +path_operators.update(path_binary_operators) + +# Used in lp encodings of automata +del_operators_names = {"box":'Box', "diamond":'Diamond',"top": "Boolean","bottom": "Boolean","neg": "Prop"} +path_unary_operators_names = {"star":'KleeneStar', "test":'Check', "stp": "Skip"} +path_binary_operators_names = {"sequence":'Sequence', "choice":'Choice'} +path_operators_names = dict(path_unary_operators_names) +path_operators_names.update(path_binary_operators_names) + + +class AuxMSO(): + """ + Auxiliary class to handle second order predicates in the MSO translation + """ + def __init__(self, f_id, f): + self._id = f_id + self._f = f + + def mona_q(self,time,prop2mona): + if not self._f.is_atomic: + return "({} in Q_{})".format(time,self._id) + elif self._f.__class__ == LDLfProp: + return "({} in {})".format(time,self._f.mona_rep(prop2mona)) + elif self._f.__class__ == LDLfBoolean: + return "({})".format(self._f.mona_rep(prop2mona)) + else: + raise Exception("Should be one above") + + # def __str__(self): + # return "ID: {} F:{} MONA:{}".format(self._id,self._f,self.mona_q('x')) + + +# ---------------------- Formulas +class LDLfFormula(): + def __init__(self, rep): + """ + Initializes a formula with the given string representation. + """ + self.__rep = rep + + @property + def _rep(self): + """ + Return the unique string representaiton of the formula. + """ + return self.__rep + + # --------------- Constructors + @classmethod + def from_lp(cls, files=[], inline_data=""): + """ + Creates an LDLfFormula from an lp files containing constraints using the syntax for the theory. + """ + ctl = _clingo.Control([], message_limit=0) + ctl.add("base", [], "") + for f in files: + ctl.load(f) + ctl.load("./encodings/translations/grammar.lp") + ctl.add("base", [], inline_data) + ctl.ground([("base", [])]) + formulas = [] + for t in ctl.theory_atoms: + formula = LDLfFormula.from_theory(t.elements[0].terms[0]) + formulas.append(formula) + return formulas + + @classmethod + def from_theory(cls, term): + """ + Creates an LDLfFormula of a Theory Term grouded from a file using the theory syntax. + """ + if (term.type == _clingo.TheoryTermType.Symbol): + return LDLfProp.from_theory(term) + elif (term.type == _clingo.TheoryTermType.Function): + if term.name in del_operators: + class_name = "LDLf" + del_operators[term.name] + else: + class_name = "LDLfProp" + return getattr(sys.modules[__name__], class_name).from_theory(term) + else: + raise RuntimeError("Invalid term {}".format(term)) + + @classmethod + def from_symbol(cls, symbol, id2prop): + """ + Creates an LDLfFormula from a symbol used in the Automta Encoding. + """ + if symbol.type == _clingo.SymbolType.Function and symbol.name =="": + print("WARNING: Loading unkown symbol, treated as string") + return LDLfFormula(str(symbol)) + if symbol.name in del_operators_names: + class_name = "LDLf" + del_operators_names[symbol.name] + else: + class_name = "LDLfProp" + return getattr(sys.modules[__name__], class_name).from_symbol(symbol,id2prop) + + @classmethod + def join_formulas(cls, formulas): + """ + Returns the conjuction of all the formulas + """ + formula = formulas[0] + for f in formulas[1:]: + formula= LDLfDiamond(CheckPath(f),formula) + return formula + + def closure_main(self): + closure = set([]) + self.closure(closure) + return list(closure) + # --------------- Translations + + def mso_main(self, time_step=0): + """ + Obtains the Monadic Second Order Encoding of the formula as a + string for MONA. For the given timestep + Returns format (ex2 Q1..Qn: Q1(0) & all1 x: (Q1<=>F1 & ... Qn<=>Fn)); + """ + closure = self.closure_main() + + closure.sort(key =lambda x: str(x)) + translations = [] + rep2aux = {f._rep:AuxMSO(i,f) for i, f in enumerate(closure)} + prop2mona = {} + for _, aux_mso in rep2aux.items(): + if not aux_mso._f.is_atomic: + translations.append("( {} <=> ({}) )".format(aux_mso.mona_q('x',prop2mona),aux_mso._f.mso("x",rep2aux,prop2mona))) + else: + aux_mso._f.mona_rep(prop2mona) #call just to add translation to prop2mona + + + mso_string = "\nm2l-str;\n" + + # all_prop_vars = list(set([f.mona_rep for f in closure if f.__class__ == LDLfProp and f.positive])) + all_prop_vars = list(prop2mona.values()) + all_prop_vars.sort() + if len(all_prop_vars)>0: + mso_string += "var2 {};\n".format(", ".join(all_prop_vars)) + + exist_2var = ", ".join(["Q_{}".format(aux_mso._id) for aux_mso in rep2aux.values() if not aux_mso._f.is_atomic]) + if len(translations)>0: + mso_string += "(ex2 {}: {} & all1 x: ({}));\n".format(exist_2var,rep2aux[self._rep].mona_q(time_step, prop2mona)," & ".join(translations)) + else: + mso_string += "{};\n".format(rep2aux[self._rep].mona_q(time_step, prop2mona)) + + mona2prop = {mona:prop for prop,mona in prop2mona.items()} + return mso_string, mona2prop + + def stm_main(self, time_step=0): + """ + Obtains the Standard relational translation for the formula ina given time_step as a string for MONA. + """ + all_prop_vars = set() + all_vars = set() + + mona_p_string = "\nm2l-str;\n" + prop2mona = {} + mona_formula = self.stm(time_step,all_prop_vars,all_vars, prop2mona) + + if len(all_prop_vars)>0: + mona_p_string += "var2 {};\n".format(", ".join(all_prop_vars)) + + mona_p_string += "{};\n".format(mona_formula) + mona2prop = {mona:prop for prop,mona in prop2mona.items()} + return mona_p_string, mona2prop + + + + def dfa(self,translation="stm", n_old_states=0, state_prefix="", id2prop=None): + """ + Obtains the DFA using the defined translation using MONA. + Args: + translation: mso or stm + Returns: + An NFA restricted to DFA + """ + if translation == "mso": + mso_string, mona2prop = self.mso_main() + elif translation == "stm": + mso_string, mona2prop = self.stm_main() + mona_out_path = "./outputs/mona_tmp" + pathlib.Path(mona_out_path).mkdir(parents=True, exist_ok=True) + # if not os.path.exists(mona_out_path): os.makedirs(mona_out_path) + name = f"{mona_out_path}/automa_{state_prefix}{random.randint(0,900000)}.mona" + + with open(name, "w+") as file: + file.write(mso_string) + # print(mso_string) + mona_dfa = invoke_mona(name) + # print(mona_dfa) + + return NFA.from_mona(mona_dfa, n_old_states=n_old_states, state_prefix=state_prefix, id2prop=id2prop, mona2prop=mona2prop) + + # --------------- Subclass specific methods + def stm(self,v_start, all_prop_vars, all_vars,prop2mona): + """ + Obtains the Standard Translation for the formula with in the time given by + the variable v_start. + Args: + v_start: The variable for the timepoint + all_prop_vars: Set gathering the representation of propositions + all_vars: Set gathering all the first order variables + """ + raise NotImplementedError + + def mso(self, time, rep2aux): + """ + Ontains the equivalent function using the subformulas for the mso translation. Only needs to be implemented for non-atomic formulas. + Args: + time: The variable for the time. Usually 'x' + rep2aux: A dictionary mapping subformulas to their Second Order info + as an AuxMSO object + """ + raise NotImplementedError + + + def closure(self, subformulas): + """ + Adds the closure of the formula to the set of subformulas + """ + print("ERROR: {}".format(self) ) + raise NotImplementedError + + def __str__(self): + return self.__rep + +class LDLfBoolean(LDLfFormula): + """ + Formula capturing a Boolean constant. + + Members: + __value -- Truth value of the formula. + """ + + def __init__(self, value): + """ + Initializes the formula with the given value. + + Members: + __value -- Boolean value of the formula. + """ + LDLfFormula.__init__(self, " &true " if value else " &false ") + self.__value = value + + @property + def is_atomic(self): + return True + + def closure(self,subformulas): + subformulas.add(self) + + def mona_rep(self, prop2mona): + return 'true ' if self.__value else 'false ' + + @classmethod + def from_theory(cls, term): + arg = term.arguments[0] + assert(arg.type == _clingo.TheoryTermType.Symbol) + return cls(arg.name == "true") + + @classmethod + def from_symbol(cls, symbol, id2prop): + return cls(symbol.name == "top") + + + def stm(self, v_start, all_prop_vars, all_vars, prop2mona): + return self.mona_rep(prop2mona) + +class LDLfProp(LDLfFormula): + """ + Formula capturing a proposition, including negation. + + Members: + positive -- True if it is negated. + """ + + def __init__(self, name, arguments, positive): + """ + Initializes the formula with the given negated. + + Members: + positive -- Boolean negated of the formula. + """ + self._name = name + args = "" if len(arguments)==0 else "({})".format(",".join([str(a) for a in arguments])) + self._arguments = args + self._args_arr = [str(a) for a in arguments] + rep = "{}{}{}".format("" if positive else "~", + name, args) + LDLfFormula.__init__(self, rep) + self.positive = positive + + @property + def is_atomic(self): + return self.positive + + @property + def positive_version(self): + return LDLfProp(self._name,self._args_arr,True) + + def closure(self,subformulas): + if self in subformulas: + return + subformulas.add(self) + if not self.positive: + positive_version = self.positive_version + subformulas.add(positive_version) + + @classmethod + def from_theory(cls, term): + positive = True + if term.type == _clingo.TheoryTermType.Function and term.name=="~": + positive = False + term = term.arguments[0] + arguments = [] if term.type == _clingo.TheoryTermType.Symbol else term.arguments + o = cls(term.name, arguments, positive) + return o + + @classmethod + def from_symbol(cls, symbol, id2prop): + positive = True + if symbol.name=="neg": + positive = False + symbol = symbol.arguments[0] + prop_id = symbol.arguments[0].number + o =cls(id2prop[prop_id], [], positive) + return o + + def mona_rep(self, prop2mona): + if not str(self) in prop2mona: + prop2mona[str(self)]=f"PROP_{len(prop2mona)}" + return prop2mona[str(self)] + + def mso(self, time, rep2aux, prop2mona): + assert not self.positive + return "~ {}".format(rep2aux[self.positive_version._rep].mona_q(time, prop2mona)) + + + def stm(self, v_start, all_prop_vars, all_vars, prop2mona): + if self.positive: + all_prop_vars.add(self.mona_rep(prop2mona)) + return "({} in {}) ".format(v_start, self.mona_rep(prop2mona)) + else: + pos = self.positive_version + all_prop_vars.add(pos.mona_rep(prop2mona)) + return "~ ({} in {}) ".format(v_start, pos.mona_rep(prop2mona)) + +class LDLfMainOperator(LDLfFormula): + """ + Members: + _op -- The id of the operator. + _path -- The left-hand-side of the temporal operator. + _rhs -- The right-hand-side of the temporal operator. + """ + + def __init__(self, op, path, rhs): + """ + Initializes the formula. + + Arguments: + op -- The id of the operator. + lhs -- The left-hand-side of the operator. + rhs -- The right-hand-side of the operator. + """ + self._op = op + self._path = path + self._rhs = rhs + rep = "{}{}{}{}".format(op[0], path._rep, op[1], rhs._rep) + LDLfFormula.__init__(self, rep) + + @property + def is_atomic(self): + return False + + def closure(self, subformulas): + if self in subformulas: + return + subformulas.add(self) + self._rhs.closure(subformulas) + main_class = self.__class__ + c = self._path.__class__ + if c == CheckPath: + self._path._arg.closure(subformulas) + elif c == ChoicePath: + lhs_ldl = main_class(self._path._lhs,self._rhs) + rhs_ldl = main_class(self._path._rhs,self._rhs) + lhs_ldl.closure(subformulas) + rhs_ldl.closure(subformulas) + elif c == SequencePath: + eq_ldl = main_class(self._path._lhs,main_class(self._path._rhs,self._rhs)) + eq_ldl.closure(subformulas) + elif c == KleeneStarPath: + step_ldl = main_class(self._path._arg,self) + step_ldl.closure(subformulas) + + + @classmethod + def from_theory(cls, term): + path = Path.from_theory(term.arguments[0]) + rhs = LDLfFormula.from_theory(term.arguments[1]) + return cls(path, rhs) + + @classmethod + def from_symbol(cls, symbol, id2prop): + path = Path.from_symbol(symbol.arguments[0], id2prop) + rhs = LDLfFormula.from_symbol(symbol.arguments[1], id2prop) + return cls(path, rhs) + +class LDLfDiamond(LDLfMainOperator): + """ + Members: + _op -- The id of the operator. + _path -- The left-hand-side of the temporal operator. + _rhs -- The right-hand-side of the temporal operator. + """ + + def __init__(self, path, rhs): + """ + Initializes the formula. + + Arguments: + rep -- String representation of the formula. + path -- The left-hand-side of the operator. + rhs -- The right-hand-side of the operator. + """ + LDLfMainOperator.__init__(self, "<>", path, rhs) + + def mso(self, time, rep2aux, prop2mona): + c = self._path.__class__ + if c == SkipPath: + return "ex1 v: v={}+1 & {}".format(time,rep2aux[self._rhs._rep].mona_q('v',prop2mona)) + elif c == CheckPath: + rhs_rep = rep2aux[self._rhs._rep] + lhs_rep = rep2aux[self._path._arg._rep] + return "{} & {}".format(rhs_rep.mona_q(time,prop2mona),lhs_rep.mona_q(time,prop2mona)) + elif c == ChoicePath: + lhs_rep = rep2aux[LDLfDiamond(self._path._lhs,self._rhs)._rep] + rhs_rep = rep2aux[LDLfDiamond(self._path._rhs,self._rhs)._rep] + return "{} | {}".format(rhs_rep.mona_q(time,prop2mona),lhs_rep.mona_q(time,prop2mona)) + elif c == SequencePath: + eq_ldl = LDLfDiamond(self._path._lhs,LDLfDiamond(self._path._rhs,self._rhs)) + eq_rep = rep2aux[eq_ldl._rep] + return "{}".format(eq_rep.mona_q(time,prop2mona)) + + elif c == KleeneStarPath: + rhs_rep = rep2aux[self._rhs._rep] + if self._path._arg.__class__==CheckPath: + return "{}".format(rhs_rep.mona_q(time,prop2mona)) + else: + step_ldl = LDLfDiamond(self._path._arg,self) + step_rep = rep2aux[step_ldl._rep] + return "{} | {}".format(rhs_rep.mona_q(time,prop2mona),step_rep.mona_q(time,prop2mona)) + + + def stm(self, v_start, all_prop_vars, all_vars, prop2mona): + new_var = 'v_{}'.format(len(all_vars)) + all_vars.add(new_var) + st_p = self._path.stp(v_start,new_var,all_prop_vars, all_vars,prop2mona) + st_m = self._rhs.stm(new_var,all_prop_vars, all_vars,prop2mona) + return "(ex1 {}: ( ({}) & {})) ".format(new_var,st_p,st_m) + +class LDLfBox(LDLfMainOperator): + """ + Members: + _op -- The id of the operator. + _path -- The left-hand-side of the temporal operator. + _rhs -- The right-hand-side of the temporal operator. + """ + + def __init__(self, path, rhs): + """ + Initializes the formula. + + Arguments: + rep -- String representation of the formula. + path -- The left-hand-side of the operator. + rhs -- The right-hand-side of the operator. + """ + LDLfMainOperator.__init__(self, "[]", path, rhs) + + def mso(self, time, rep2aux, prop2mona): + c = self._path.__class__ + if c == SkipPath: + return "all1 v: v={}+1 => {}".format(time,rep2aux[self._rhs._rep].mona_q('v',prop2mona)) + elif c == CheckPath: + rhs_rep = rep2aux[self._rhs._rep] + lhs_rep = rep2aux[self._path._arg._rep] + return "{} => {}".format(lhs_rep.mona_q(time,prop2mona),rhs_rep.mona_q(time,prop2mona)) + elif c == ChoicePath: + lhs_rep = rep2aux[LDLfBox(self._path._lhs,self._rhs)._rep] + rhs_rep = rep2aux[LDLfBox(self._path._rhs,self._rhs)._rep] + return "{} & {}".format(rhs_rep.mona_q(time,prop2mona),lhs_rep.mona_q(time,prop2mona)) + elif c == SequencePath: + eq_ldl = LDLfBox(self._path._lhs,LDLfBox(self._path._rhs,self._rhs)) + eq_rep = rep2aux[eq_ldl._rep] + return "{}".format(eq_rep.mona_q(time,prop2mona)) + + elif c == KleeneStarPath: + rhs_rep = rep2aux[self._rhs._rep] + if self._path._arg.__class__==CheckPath: + return "{}".format(rhs_rep.mona_q(time,prop2mona)) + else: + step_ldl = LDLfBox(self._path._arg,self) + step_rep = rep2aux[step_ldl._rep] + return "{} & {}".format(rhs_rep.mona_q(time,prop2mona),step_rep.mona_q(time,prop2mona)) + + def stm(self, v_start, all_prop_vars, all_vars, prop2mona): + new_var = 'v_{}'.format(len(all_vars)) + all_vars.add(new_var) + st_p = self._path.stp(v_start,new_var,all_prop_vars, all_vars,prop2mona) + st_m = self._rhs.stm(new_var,all_prop_vars, all_vars,prop2mona) + return "(all1 {}: ( ({}) => {})) ".format(new_var,st_p,st_m) + +# ---------------------- Paths +class Path(object): + + """ + Base class of all path + + Members: + __rep -- unique string representation of the path + """ + def __init__(self, rep): + """ + Initializes a formula with the given string representation. + """ + self.__rep = rep + + @property + def _rep(self): + """ + Return the unique string representaiton of the formula. + """ + return self.__rep + + + @classmethod + def from_theory(cls, term): + assert term.type == _clingo.TheoryTermType.Function + class_name = path_operators[term.name] + "Path" + return getattr(sys.modules[__name__], class_name).from_theory(term) + + @classmethod + def from_symbol(cls, symbol, id2prop): + class_name = path_operators_names[symbol.name] + "Path" + return getattr(sys.modules[__name__], class_name).from_symbol(symbol, id2prop) + + # --------------- Subclass specific methods + def stp(self,v_start,v_end, all_prop_vars, all_vars,prop2mona): + """ + Obtains the Standard Translation for the path. + Args: + v_start: The variable for the starting timepoint + v_end: The variable for the end timepoint + all_prop_vars: Set gathering the representation of propositions + all_vars: Set gathering all the first order variables + """ + raise NotImplementedError + +class SkipPath(Path): + def __init__(self): + Path.__init__(self, "(&t)") + + @classmethod + def from_theory(cls,term): + assert term.arguments[0].name=="t" + return cls() + + @classmethod + def from_symbol(cls,symbol, id2prop): + assert symbol.name=="stp" + return cls() + + def stp(self, v_start, v_end, all_prop_vars, all_vars,prop2mona): + return "( {} = {}+1) ".format(v_end,v_start) + +class BinaryPath(Path): + """ + Members: + _lhs + _rhs + + """ + def __init__(self, rep, lhs, rhs): + self._lhs = lhs + self._rhs = rhs + Path.__init__(self, rep) + + @classmethod + def from_theory(cls,term): + lhs = Path.from_theory(term.arguments[0]) + rhs = Path.from_theory(term.arguments[1]) + return cls(lhs,rhs) + + @classmethod + def from_symbol(cls,symbol, id2prop): + lhs = Path.from_symbol(symbol.arguments[0], id2prop) + rhs = Path.from_symbol(symbol.arguments[1], id2prop) + return cls(lhs,rhs) + +class ChoicePath(BinaryPath): + + def __init__(self, lhs, rhs): + BinaryPath.__init__(self, "{}+{}".format(lhs._rep, rhs._rep), lhs, rhs) + + def stp(self, v_start, v_end, all_prop_vars, all_vars, prop2mona): + st_p_l = self._lhs.stp(v_start,v_end, all_prop_vars, all_vars, prop2mona) + st_p_r = self._rhs.stp(v_start,v_end, all_prop_vars, all_vars, prop2mona) + return "({} | {}) ".format(st_p_l,st_p_r) + +class SequencePath(BinaryPath): + + def __init__(self, lhs, rhs): + BinaryPath.__init__(self, "{};;{}".format(lhs._rep, rhs._rep), lhs, rhs) + + def stp(self, v_start, v_end, all_prop_vars, all_vars, prop2mona): + new_var = 'v_{}'.format(len(all_vars)) + all_vars.add(new_var) + st_p_l = self._lhs.stp(v_start,new_var, all_prop_vars, all_vars, prop2mona) + st_p_r = self._rhs.stp(new_var,v_end, all_prop_vars, all_vars, prop2mona) + return "(ex1 {}: ({}& {}))".format(new_var, st_p_l,st_p_r) + +class UnaryPath(Path): + """ + Members: + __arg + """ + def __init__(self, rep, arg): + self.__arg = arg + Path.__init__(self, rep) + + @property + def _arg(self): + """ + Return the unique string representaiton of the formula. + """ + return self.__arg + +class CheckPath(UnaryPath): + + def __init__(self, arg): + UnaryPath.__init__(self, "{}?".format(arg._rep), arg) + + @classmethod + def from_theory(cls,term): + arg = LDLfFormula.from_theory(term.arguments[0]) + return cls(arg) + + @classmethod + def from_symbol(cls,symbol, id2prop): + arg = LDLfFormula.from_symbol(symbol.arguments[0], id2prop) + return cls(arg) + + def stp(self, v_start, v_end, all_prop_vars, all_vars,prop2mona): + st_m = self._arg.stm(v_start, all_prop_vars, all_vars,prop2mona) + return "({}& {}={})".format(st_m,v_end,v_start) #ONLY test in prop + +class KleeneStarPath(UnaryPath): + + def __init__(self, arg): + UnaryPath.__init__(self, "({})*".format(arg._rep), arg) + + @classmethod + def from_theory(cls,term): + arg = Path.from_theory(term.arguments[0]) + return cls(arg) + + @classmethod + def from_symbol(cls,symbol, id2prop): + arg = Path.from_symbol(symbol.arguments[0], id2prop) + return cls(arg) + + def stp(self, v_start, v_end, all_prop_vars, all_vars,prop2mona): + conditions = [] + conditions.append("{} in S".format(v_start)) #Initial tp is in the set of starting tps + conditions.append("{} in S".format(v_end)) #Initial tp is in the set of starting tps + conditions.append("all1 r: (r in S) => ({}<=r & r<={})".format(v_start,v_end)) #S<=D + st_p = self._arg.stp('x', 'y', all_prop_vars, all_vars,prop2mona) + # For every two tps in the set that are consecutive rho must hold between them + conditions.append("all1 x, y: ((x {})".format(st_p)) + + return "ex2 S: ({})".format("& ".join(["({})".format(c) for c in conditions])) diff --git a/scripts/translater.py b/scripts/translater.py new file mode 100644 index 0000000..62e079a --- /dev/null +++ b/scripts/translater.py @@ -0,0 +1,76 @@ +from graphviz import Digraph, Source +from pystructures.ldlf import LDLfFormula +from pystructures.automata import AFW +import argparse +import sys +import re + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Translations for LDLf formulas and automatas') + parser.add_argument('--input', type=str, + help='Starting input: afw or ldlf') + parser.add_argument('--app', type=str, + help='Approach name: dfa-mso, dfa-stm, nfa') + parser.add_argument('--out-file', type=str, + help='Path for output automata file') + parser.add_argument('--in-files', type=str, + help='Path for ldlf constraint or afw representation') + + parser.add_argument("--viz", default=False, action='store_true', + help="Save automaton vizualization") + parser.add_argument("--multiple-dfa", default=True, action='store_true', + help="Use multiple DFAs instead of conjunction") + parser.add_argument('--labels', action='store_const', const=True) + parser.add_argument('--latex', action='store_const', const=True) + + args = parser.parse_args() + in_files = args.in_files.split(" ") + in_files = [f for f in in_files if f!=""] + if args.input=="afw": + assert args.app == "nfa" + afw = AFW.from_lp(files = in_files, inline_data= "") + automaton = afw.to_nfa() + automata_lp = automaton.to_lp() + + elif args.input=="ldlf": + assert args.app in ["dfa-mso","dfa-stm"] + ldlfformulas = LDLfFormula.from_lp(files=in_files,inline_data="") + if args.multiple_dfa: + automata_lp="" + id2prop = {} + n_old_states = 0 + for i,f in enumerate(ldlfformulas): + automaton = f.dfa(translation=args.app.split('-')[1],n_old_states=n_old_states, state_prefix=f"a{i}_", id2prop=id2prop) + id2prop = automaton._props + n_old_states = n_old_states+ len(automaton._states) + automata_lp+=f"\n%%%%%%%%%%% Automata {i}\n" + automata_lp+=automaton.to_lp() + else: + conj_formula = LDLfFormula.join_formulas(ldlfformulas) + automaton = conj_formula.dfa(translation=args.app.split('-')[1]) + automata_lp=automaton.to_lp() + + # elif args.input=="telingo": + # program = "" + # for fn in sys.argv[3:]: + # f = open(fn, 'r') + # program += f.read() + # f.close() + # print(program) + # horizon = int(sys.argv[1]) + 1 + # solve(program, imin=horizon, out_file=sys.argv[2], imax=horizon, istop="UNKNOWN") + else: + raise RuntimeError("Invalid input") + + with open(args.out_file, 'w') as f: + f.write(automata_lp) + +# if args.viz: +# print("Saving visualization of automata") +# automaton.save_png(file=args.out_file[:-3]+".png",labels=args.labels,latex=args.latex) +# if(args.latex): +# automaton.to_tex(file=args.out_file[:-3]+".tex",labels=args.labels) + + import sys + sys.exit() + diff --git a/scripts/viz.py b/scripts/viz.py new file mode 100755 index 0000000..0fb49ed --- /dev/null +++ b/scripts/viz.py @@ -0,0 +1,64 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import argparse +import copy +import os +import sys +import networkx as nx +import pygraphviz as pgv +import clingo +import itertools +import pdb +import subprocess +from pystructures.automata import AFW, NFA +from pystructures.ldlf import LDLfFormula +parser = argparse.ArgumentParser(description='Viz automata') + +parser.add_argument('--constraint', help='Constaint name',required=True) +parser.add_argument('--dom', help='Env app: atlingo, test, elevator...',required=True) +parser.add_argument('--app', help='App: afw, dfa, nfa, nfa-afw',required=True) +parser.add_argument('--instance', help='Instance name',required=True) +parser.add_argument('--instance_path', help='Instance path',required=True) +parser.add_argument('--labels', action='store_const', const=True) +parser.add_argument('--latex', action='store_const', const=True) + +args = parser.parse_args() +constraint=args.constraint +dom=args.dom +app=args.app +instance=args.instance +instance_path=args.instance_path +labels= args.labels +latex= args.latex + + +command = 'make translate APP=afw CONSTRAINT={} DOM={} INSTANCE={}'.format(constraint,dom,instance_path) +print(command) +# subprocess.check_output(command.split()) +constraint_path = "dom/{}/temporal_constraints/{}.lp".format(dom,constraint) + +automata_path = "outputs/{}/{}/{}/{}/{}_automata.lp".format(dom, app,constraint,instance,app) + +afw_automata_path = "outputs/{}/afw/{}/{}/afw_automata.lp".format(dom,constraint,instance) + +if app=="afw": + afw = AFW.from_lp(files = [afw_automata_path]) + automaton = afw +elif app in ["dfa-mso","dfa-stm"]: + ldlfformulas = LDLfFormula.from_lp(files=[constraint_path],inline_data="") + # Use translater insted + conj_formula = LDLfFormula.join_formulas(ldlfformulas) + automaton = conj_formula.dfa(translation=args.app.split('-')[1]) +elif app=="nfa": + afw = AFW.from_lp(files = [afw_automata_path]) + automaton = afw.to_nfa() +elif app=="nfa-afw": + automaton = NFA.from_lp(files = [automata_path]) +else: + raise RuntimeError("Invalid approach") +png_path = "outputs/{}/{}/{}/{}/{}_automata".format(dom, app,constraint,instance,app) + +automaton.save_png(file=png_path,labels=labels,latex=latex) +if(latex): + automaton.to_tex(file=png_path+".tex",labels=labels) + \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/del_test.py b/tests/del_test.py new file mode 100644 index 0000000..dd0b88a --- /dev/null +++ b/tests/del_test.py @@ -0,0 +1,804 @@ +import unittest +import os +import sys +import clingo +import subprocess +import itertools +from pystructures.ldlf import LDLfFormula, KleeneStarPath, LDLfBoolean, SkipPath +from pystructures.automata import AFW, NFA + + + + +# define the name of the directory to be created +paths = ["./outputs/test/afw/cons_tmp/instance_tmp", + "./outputs/test/telingo/cons_tmp/instance_tmp", + "./outputs/test/dfa/cons_tmp/instance_tmp", + "./outputs/test/nfa/cons_tmp/instance_tmp" + ] + +try: + for p in paths: + os.makedirs(p,exist_ok=True) +except OSError: + print ("Creation of the directory %s failed" % p) + + +class Context: + def id(self, x): + return x + def seq(self, x, y): + return [x, y] + +def sort_trace(trace): + return list(sorted(trace)) + +def tuple2str(sym): + if str(sym.type)=="Function" and sym.name=="": + args = "({})".format(",".join([tuple2str(s) for s in sym.arguments[1:]])) + return "{}{}".format(str(sym.arguments[0]).strip('"'),"" if args=="()" else args) + else: + return str(sym).strip('"') +def parse_model(m): + ret = [] + for sym in m.symbols(shown=True): + if sym.name=="holds_map": + ret.append((sym.arguments[0].number, '"{}"'.format(tuple2str(sym.arguments[1])) )) + if str(sym) in ["empty","not_empty","error_branching","error_contradiction"]: + ret.append(str(sym)) + + return sort_trace(ret) + +def solve(const=[], files=[],inline_data=[]): + r = [] + imax = 20 + ctl = clingo.Control(['0','--project']+const, message_limit=0) + ctl.add("base", [], "") + for f in files: + ctl.load(f) + for d in inline_data: + ctl.add("base", [], d) + ctl.add("base",[],"#show holds_map/2.") + ctl.ground([("base", [])], context=Context()) + ctl.solve(on_model= lambda m: r.append(parse_model(m))) + return sorted(r) + +def translate(constraint,extra="",app='afw',horizon=3): + cons_file = "dom/test/temporal_constraints/cons_tmp.lp" + with open(cons_file, 'w') as f: + f.write(constraint) + command = 'make translate APP={} CONSTRAINT=cons_tmp DOM=test INSTANCE=dom/test/instances/instance_tmp.lp APP={} HORIZON={} {}'.format(app,app,horizon,extra) + # print(command) + subprocess.check_output(command.split()) + + +def empty_check(constraint,horizon=3,app="afw"): + translate(constraint,app=app,horizon=horizon) + + automata_path = "outputs/test/{}/cons_tmp/instance_tmp/{}_automata.lp".format(app,app) + paths = [automata_path, "encodings/empty.lp"] + + return solve(["--warn=none"],paths,[]) + +def run_check(constraint,trace="",horizon=3,app="afw",generate=False,extra_files=[],extra_args=""): + translate(constraint,app=app,horizon=horizon,extra=extra_args) + + automata_path = "outputs/test/{}/cons_tmp/instance_tmp/{}_automata.lp".format(app,app) + run_files = { + "afw": ['./encodings/automata_run/run.lp',"./dom/test/glue.lp"], + "dfa-mso": ['./encodings/automata_run/run.lp'], + "dfa-stm": ['./encodings/automata_run/run.lp'], + "nfa": ['./encodings/automata_run/run.lp'], + "nfa-afw": ['./encodings/automata_run/run.lp',"./dom/test/glue.lp"], + "telingo": [] + } + paths = [automata_path]+run_files[app]+extra_files + if generate: + paths.append("./encodings/automata_run/trace_generator.lp") + return solve(["-c horizon={}".format(horizon)],paths,[trace]) + +def comapre_apps(constraint,horizon=3,apps=[],test_instance=None): + models = [] + for app in apps: + models.append(run_check(constraint,horizon=horizon,app=app,generate=True)) + # print(apps) + # print(models) + test_instance.assertListEqual(models[0],models[1]) + for i in range(len(models)-1): + # print("{} vs {}".format(apps[i],apps[i+1])) + # print(models[i]) + # print(models[i+1]) + test_instance.assertListEqual(models[i],models[i+1]) + +class TestCase(unittest.TestCase): + longMessage = True + def assert_base(self,base_model,result): + for r in result: + for a in base_model: + self.assertIn(a,r) + + def assert_all(self,expected_models,result): + res = list(result for result,_ in itertools.groupby(result)) + expected_models = map(sort_trace, expected_models) + self.assertCountEqual(expected_models,res) + + def assert_sat(self,result): + self.assertGreater(len(result),0, "Is UNSAT") + + def assert_unsat(self,result): + self.assertEqual(len(result),0, "Is NOT UNSAT. Found model: {}".format(result)) + +class TestMain(TestCase): + + + def test_generation(self): + self.maxDiff=None + + result = run_check(":- not &del{ ?q(1) ;; ?p ;; &t .>? p}.",horizon=1,generate=True) + base_model = [(0,'"q(1)"'),(0,'"p"'),(1,'"p"'),(1,'"last"')] + expected_models = [base_model, base_model+[(1,'"q(1)"')]] + self.assert_all(expected_models,result) + self.assert_base(base_model,result) + + + result = run_check(":- not &del{ ?p ;; &t .>? ~ p}.",horizon=1,generate=True) + expected_models = [[(0,'"p"'),(1,'"last"')]] + self.assert_all(expected_models,result) + + + result = run_check(":- not &del{ ?q(1) ;; ?p ;; &t .>? p}.",horizon=3,generate=True) + base_model = [(0,'"q(1)"'),(0,'"p"'),(1,'"p"'),(3,'"last"')] + self.assert_base(base_model,result) + + result = run_check(":- not &del{ * ( ?p ;; &t ) .>? ?q .>? ~ p}.",horizon=1,generate=True) + expected_models = [[(1,'"last"'),(0,'"q"')], + [(1,'"last"'),(0,'"q"'),(1,'"q"')], + [(1,'"last"'),(0,'"q"'),(1,'"q"'),(1,'"p"')], + [(1,'"last"'),(0,'"q"'),(1,'"p"')], + [(1,'"last"'),(0,'"p"'),(0,'"q"'),(1,'"q"')], + [(1,'"last"'),(0,'"p"'),(1,'"q"')]] + self.assert_all(expected_models,result) + + # UNSAT because horizon has to be in in time point 0 + result = run_check(":- not &del{ &t .>* &false}.",horizon=3,generate=True) + self.assert_unsat(result) + + # UNSAT because horizon has to be in in time point 0 + result = run_check(":- not &del{ &t .>* &false}.",horizon=2,generate=True) + self.assert_unsat(result) + + result = run_check(":- not &del{ &t .>* &false}.",horizon=0,generate=True) + expected_models = [[(0,'"last"')]] + self.assert_all(expected_models,result) + + def test_check(self): + self.maxDiff=None + + ######### Examples using simple env starting actions in timepoint 0. + + # Boolean constats + + result = run_check(":- not &del{ &true }.",trace="p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":- not &del{ &true }.",trace="",horizon=2) + self.assert_sat(result) + + result = run_check(":- not &del{ &true }.",trace="",horizon=0) + self.assert_sat(result) + + result = run_check(":- not &del{ &false }.",trace="p(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":- not &del{ &false }.",trace="",horizon=2) + self.assert_unsat(result) + + result = run_check(":- not &del{ &false }.",trace="",horizon=0) + self.assert_unsat(result) + + + # Atoms + + result = run_check(":- not &del{ p }.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":- not &del{ p }.",trace="p(1).",horizon=2) + self.assert_unsat(result) + + # Step (Diamond) + result = run_check(":- not &del{ &t .>? p}.",trace="p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ &t .>? p}.",trace="",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>? p}.",trace="",horizon=0) + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>? p}.",trace="p(1).",horizon=2) + self.assert_sat(result) + + # Step (Box) + result = run_check(":-not &del{ &t .>* p}.",trace="",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>* p}.",trace="p(1).",horizon=2) + self.assert_all([[(2,'"last"'),(1,'"p"')]],result) + + result = run_check(":-not &del{ &t .>* p}.",trace="q(2).",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>* p}.",trace="",horizon=0) + self.assert_all([[(0,'"last"')]],result) + self.assert_sat(result) + + + # Test construct (Diamond) + + result = run_check(":-not &del{ ?q .>? p}.",trace="q(0). p(0).",horizon=2) + self.assert_all([[(2,'"last"'),(0,'"q"'),(0,'"p"')]],result) + + result = run_check(":-not &del{ ?q .>? p}.",trace="",horizon=2) + self.assert_unsat(result) + + #TODO add tests for test on negation + + # Test construct (Box) + + result = run_check(":-not &del{ ?q .>* p}.",trace="",horizon=2) + self.assert_all([[(2,'"last"')]],result) + + result = run_check(":-not &del{ ?q .>* p}.",trace="q(2).",horizon=2) + self.assert_all([[(2,'"last"'),(2,'"q"')]],result) + + + # Sequence (Diamond) + + result = run_check(":-not &del{ ?q ;; &t .>? p}.",trace="q(0). p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>? &true}.",trace="q(0). p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>? &true}.",trace="q(0).",horizon=2) + self.assert_unsat(result) + + # Sequence (Box) + + result = run_check(":-not &del{ ?q ;; &t .>* p}.",trace="q(0). p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; &t .>* p}.",trace="p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; &t .>* p}.",trace="",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>* &true}.",trace="q(0). p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>* &true}.",trace="q(0).",horizon=2) + self.assert_sat(result) + + # Choice (Diamond) + + result = run_check(":-not &del{ ?q + &t .>? p}.",trace="q(0). p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + &t .>? p}.",trace="p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="p(0).q(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="",horizon=2) + self.assert_unsat(result) + + + # Choice (Box) + + result = run_check(":-not &del{ ?q + &t .>* p}.",trace="q(0). p(0).",horizon=0) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + &t .>* p}.",trace="p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + &t .>* p}.",trace="",horizon=0) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="p(0).q(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="",horizon=2) + self.assert_sat(result) + + # Star (Diamond) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="p(0).",horizon=0) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="",horizon=0) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="p(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="q(0).p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="q(0).q(1).p(2).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="q(0).q(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q) .>? p}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + # Star (Box) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="p(0).",horizon=0) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="",horizon=0) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="p(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).p(1).p(0).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).q(1).p(2).p(0).p(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).q(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).q(1).p(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q) .>* p}.",trace="p(0).",horizon=2) + self.assert_sat(result) + + def test_check_telingo(self): + self.maxDiff=None + + ######### Examples using simple env starting actions in timepoint 0. + + # Boolean constats + + result = run_check(":- not &del{ &true }.",trace="p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":- not &del{ &true }.",trace="",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":- not &del{ &true }.",trace="",horizon=0,app="telingo") + self.assert_sat(result) + + result = run_check(":- not &del{ &false }.",trace="p(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":- not &del{ &false }.",trace="",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":- not &del{ &false }.",trace="",horizon=0,app="telingo") + self.assert_unsat(result) + + + # Atoms + + result = run_check(":- not &del{ p }.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":- not &del{ p }.",trace="p(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + # Step (Diamond) + result = run_check(":- not &del{ &t .>? p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ &t .>? p}.",trace="",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>? p}.",trace="",horizon=0,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>? p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + # Step (Box) + result = run_check(":-not &del{ &t .>* p}.",trace="",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>* p}.",trace="p(1).",horizon=2,app="telingo") + ## self.assert_all([[(1,'"p"')]],result) + + result = run_check(":-not &del{ &t .>* p}.",trace="q(2).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ &t .>* p}.",trace="",horizon=0,app="telingo") + #self.assert_all([[(0,'"last"')]],result) + self.assert_sat(result) + + + # Test construct (Diamond) + + result = run_check(":-not &del{ ?q .>? p}.",trace="q(0). p(0).",horizon=2,app="telingo") + ## self.assert_all([[(0,'"q"'),(0,'"p"')]],result) + + result = run_check(":-not &del{ ?q .>? p}.",trace="",horizon=2,app="telingo") + self.assert_unsat(result) + + #TODO add tests for test on negation + + # Test construct (Box) + + result = run_check(":-not &del{ ?q .>* p}.",trace="",horizon=2,app="telingo") + #self.assert_all([[(2,'"last"')]],result) + + result = run_check(":-not &del{ ?q .>* p}.",trace="q(2).",horizon=2,app="telingo") + ## self.assert_all([[(2,'"q"')]],result) + + + # Sequence (Diamond) + + result = run_check(":-not &del{ ?q ;; &t .>? p}.",trace="q(0). p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>? &true}.",trace="q(0). p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>? &true}.",trace="q(0).",horizon=2,app="telingo") + self.assert_unsat(result) + + # Sequence (Box) + + result = run_check(":-not &del{ ?q ;; &t .>* p}.",trace="q(0). p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; &t .>* p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; &t .>* p}.",trace="",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>* &true}.",trace="q(0). p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q ;; ?p .>* &true}.",trace="q(0).",horizon=2,app="telingo") + self.assert_sat(result) + + # Choice (Diamond) + + result = run_check(":-not &del{ ?q + &t .>? p}.",trace="q(0). p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + &t .>? p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="p(0).q(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>? &true}.",trace="",horizon=2,app="telingo") + self.assert_unsat(result) + + + # Choice (Box) + + result = run_check(":-not &del{ ?q + &t .>* p}.",trace="q(0). p(0).",horizon=0,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + &t .>* p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + &t .>* p}.",trace="",horizon=0,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="p(0).q(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ ?q + ?p .>* &true}.",trace="",horizon=2,app="telingo") + self.assert_sat(result) + + # Star (Diamond) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="p(0).",horizon=0,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="",horizon=0,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="q(0).p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="q(0).q(1).p(2).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>? p}.",trace="q(0).q(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q) .>? p}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + # Star (Box) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="p(0).",horizon=0,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="",horizon=0,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="p(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).p(1).p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).q(1).p(2).p(0).p(1).",horizon=2,app="telingo") + self.assert_sat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).q(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q ;; &t) .>* p}.",trace="q(0).q(1).p(1).",horizon=2,app="telingo") + self.assert_unsat(result) + + result = run_check(":-not &del{ * (?q) .>* p}.",trace="p(0).",horizon=2,app="telingo") + self.assert_sat(result) + + + + def test_asprilo(self): + + ######### Examples using asprilo env starting actions in timepoint 1. + + + result = run_check(":- not &del{ &t .>? move(robot(1),(1,0))}.",trace="move(robot(1),(1,0),1).",horizon=2,extra_files=["dom/asprilo-md/glue.lp"]) + self.assert_sat(result) + + result = run_check(":- not &del{ &t .>? move(robot(1),(1,0))}.",trace="move(robot(1),(1,0),2).",horizon=3,extra_files=["dom/asprilo-md/glue.lp"]) + self.assert_unsat(result) + + def test_multiple(self): + self.maxDiff=None + + result = run_check(":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.",trace="p(1).q(1).",horizon=2) + self.assert_sat(result) + + result = run_check(":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.",trace="q(1).",horizon=2) + self.assert_unsat(result) + + result = run_check(":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.",trace="p(1).",horizon=2) + self.assert_unsat(result) + + #Test with join + result = run_check(":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.",trace="p(1).q(1).",horizon=2,extra_args="JOIN=1") + self.assert_sat(result) + + result = run_check(":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.",trace="q(1).",horizon=2,extra_args="JOIN=1") + self.assert_unsat(result) + + result = run_check(":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.",trace="p(1).",horizon=2,extra_args="JOIN=1") + self.assert_unsat(result) + + def test_special(self): + self.maxDiff=None + + # Star (Box) with need for nnf + + result = run_check(":-not &del{ (? ((* &t) .>* q)) .>* p}.",trace="",horizon=2) + self.assert_sat(result) + result = run_check(":-not &del{ (? ((* &t) .>* q)) .>* p}.",trace="q(0).q(1).",horizon=2) + self.assert_sat(result) + result = run_check(":-not &del{ (? ((* &t) .>* q)) .>* p}.",trace="q(0).q(1).q(2).",horizon=2) + self.assert_unsat(result) + result = run_check(":-not &del{ (? ((* &t) .>* q)) .>* p}.",trace="q(0).q(1).q(2).p(0).",horizon=2) + self.assert_sat(result) + + + def test_ldlf(self): + formulas = LDLfFormula.from_lp(inline_data= ":- not &del{&t .>? b}.") + self.assertEqual(formulas[0]._rep,"<(&t)>b") + formulas = LDLfFormula.from_lp(inline_data= ":- not &del{ ?a ;; * (? a + ?b ;; &t) .>? b}.") + self.assertEqual(formulas[0]._rep,"b") + formulas = LDLfFormula.from_lp(inline_data= ":- not &del{ ?a(X) .>* &true}, p(X). p(1). p(2).") + self.assertEqual(len(formulas),2) + self.assertEqual(formulas[0]._rep,"[a(1)?] &true ") + self.assertEqual(formulas[1]._rep,"[a(2)?] &true ") + + + def test_translation(self): + + constraints = [ + ":- not &del{ &true }.", + ":- not &del{ &false }.", + # Atoms + ":- not &del{ p }.", + # Step (Diamond) + ":-not &del{ &t .>? p}.", + # Step (Box) + ":-not &del{ &t .>* p}.", + # Test construct (Diamond) + ":-not &del{ ?q .>? p}.", + # Test construct (Box) + ":-not &del{ ?q .>* p}.", + # Sequence (Diamond) + ":-not &del{ ?q ;; &t .>? p}.", + ":-not &del{ ?q ;; ?p .>? &true}.", + # Sequence (Box) + ":-not &del{ ?q ;; &t .>* p}.", + ":-not &del{ ?q ;; ?p .>* &true}.", + # Choice (Diamond) + ":-not &del{ ?q + &t .>? p}.", + ":-not &del{ ?q + ?p .>? &true}.", + # Choice (Box) + ":-not &del{ ?q + &t .>* p}.", + ":-not &del{ ?q + ?p .>* &true}.", + # Star (Diamond) + ":-not &del{ * (?q ;; &t) .>? p}.", + ":-not &del{ * (?q) .>? ?p .>? &t .>? q}.", + # Star (Box) + ":-not &del{ * (&t) .>* p}.", + ":-not &del{ * (?q) .>* p}.", + ":-not &del{ * (?q ;; &t) .>* p}.", + ":-not &del{ * (?q) .>* ?p .>? &t .>? q}.", + # Star (Box) + ":-not &del{ ?q .>? &t .>* &false}.", + # Until + ":- not &del{ *(? a;; &t) .>? b}.", + # Complex + ":- not &del{ *( (? a;; &t) + (? a;; &t ;; ? c;; &t)) .>? b}.", + # Multiple + ":- not &del{ &t .>? p }. :- not &del{ &t .>? q }.", + #Negation + ":-not &del{ * &t .>* ? ~p .>* ~q}." + ] + for cons in constraints: + for h in range(1,4): + # print("Testing {} with h = {}".format(cons,h)) + comapre_apps(cons,h,apps=['afw','dfa-mso','dfa-stm','nfa','nfa-afw'],test_instance=self) + # comapre_apps(cons,h,apps=['afw','dfa-mso','dfa-stm','nfa','nfa-afw'],test_instance=self) + + def test_closure(self): + formula = LDLfFormula.from_lp(inline_data= ":-not &del{ * ((?p + ?q) ;; &t) .>* ?r .>? &true}.")[0] + # formula = LDLfFormula.from_lp(inline_data= ":-not &del{ * (?q) .>* ?p .>? &true .>? q}.")[0] + s = set([]) + formula.closure(s) + closure = [c._rep.replace(" ","") for c in s] + assert "p" in closure + assert "[(&t)][(p?+q?;;(&t))*]&true" in closure + assert "[p?+q?;;(&t)][(p?+q?;;(&t))*]&true" in closure + assert "[p?+q?][(&t)][(p?+q?;;(&t))*]&true" in closure + assert "[p?][(&t)][(p?+q?;;(&t))*]&true" in closure + assert "[q?][(&t)][(p?+q?;;(&t))*]&true" in closure + assert "r" in closure + assert "&true" in closure + assert "&true" in closure + assert "q" in closure + assert "[(p?+q?;;(&t))*]&true" in closure + + + + def test_error(self): + a = """ + :- not &del{(* ( ( ? p ) ;; &t )) .>? ( (* &t ) .>* q )}. + :- not &del{(* ( ( ? r ) ;; &t )) .>? ( (* &t ) .>* s )}. + """ + constraints = [ + a + ] + for cons in constraints: + # print("Testing {} with h = {}".format(cons,1)) + comapre_apps(cons,3,apps=['afw','dfa-mso'],test_instance=self) + + def test_dir(self): + + a = """ + :- not &del{ * &t .>* + ?p ;; &t .>* + *( ? ~ q;; &t) .>? + (?a + ?b + ?c) + .>? &true + }. + """ + + result = run_check(a,trace="",horizon=3,generate=True) + + + + def test_empty(self): + + a = ":- not &del{ ?((* &t) .>* &t .>? b) .>? a }." + result = empty_check(a,horizon=3,app="dfa-mso")[0] + assert "empty" in result + + a = ":- not &del{ ?((* &t) .>* &t .>? b) .>? a }." + result = empty_check(a,horizon=3,app="dfa-stm")[0] + assert "empty" in result + + a = ":- not &del{ ?((* &t) .>* &t .>? b) .>? a }." + result = empty_check(a,horizon=3,app="nfa")[0] + assert "empty" in result + + a = ":- not &del{ ?((* &t) .>* &t .>? b) .>? a }." + result = empty_check(a,horizon=3,app="afw")[0] + assert "error_branching" in result + + a = ":- not &del{ ?a .>? &false}." + result = empty_check(a,horizon=3,app="afw")[0] + assert "empty" in result + + + a = ":- not &del{ ? ((* &t) .>* b) + ? (&t .>? a) .>? &true }." + result = empty_check(a,horizon=3,app="afw")[0] + assert "not_empty" in result + + a = ":- not &del{ ? ((* &t) .>* b) + ? (&t .>? a) .>? &true }." + result = empty_check(a,horizon=3,app="afw")[0] + assert "not_empty" in result + + a = ":- not &del{ ? ((* &t) .>* b) + ? (&t .>? a) .>? &true }." + result = empty_check(a,horizon=3,app="nfa")[0] + assert "not_empty" in result + + a = ":- not &del{ ? ((* &t) .>* b) + ? (&t .>? a) .>? &true }." + result = empty_check(a,horizon=3,app="dfa-mso")[0] + assert "not_empty" in result + + + a = ":- not &del{ (* &t) .>* ?a ;; ? ~a .>? &true }." + result = empty_check(a,horizon=3,app="afw")[0] + assert "empty" in result + + a = ":- not &del{ (* &t) .>* ?a ;; ? ~a .>? &true }." + result = empty_check(a,horizon=3,app="nfa")[0] + assert "empty" in result + + a = ":- not &del{ (* &t) .>* ?a + ? ~a .>? &true }." + result = empty_check(a,horizon=3,app="afw")[0] + assert "not_empty" in result + + a = ":- not &del{ (* &t) .>* ?a + ? ~a .>? &true }." + result = empty_check(a,horizon=3,app="nfa")[0] + assert "not_empty" in result \ No newline at end of file