Package: aspmc
aspmc(Algebraic) answer set counter based on a treewidth-aware cycle-breaking for normal answer set programs.For usage on Linux you may also install this software as a pip package viapip install aspmcDocumentation for usage as a python module is availablehere.
Examples for command line usage are available below.If you have any issues please contact us, or even better create an issue on GitHub.For academic usage citeEiter, T., Hecher, M., & Kiesel, R. (2021, September). Treewidth-Aware Cycle Breaking for Algebraic Answer Set Counting. In Proceedings of the International Conference on Principles of Knowledge Representation and Reasoning (Vol. 18, No. 1, pp. 269-279).Development setupFor developement clone viagit clone --single-branch --branch=main git@github.com:raki123/aspmc.gitto avoid the download of the experimental results in branchresults.We include a setup bash scriptsetup.shthat should automatically perform all steps below that are required to run our code. (Except for providing the c2d and miniC2D binary.)PythonPython >= 3.6All required modules are listed inrequirements.txtand can be obtained by runningpip install -r requirements.txtTree Decompositions via flow-cutterWe useflow-cutterto obtain treedecompositions that are needed for our treedecomposition guided clark completion, obtaining treewidth upperbounds on the programs, variable order generation and more.It is included as a git submodule.The submodules can be obtained by runninggit submodule update --initflow-cutter further needs to be compiled viacd aspmc/external/flow-cutter/
bash build.shKnowledge Compilation via d4 or sharpSAT-TDWe used4orsharpSAT-TDfor knowledge compilation. Note that both of these are forks of the original model countershereandhere, respectively. For d4 we added support for smooth compilation and for sharpSAT-TD we used the nicely thought out addition by Tuukka Korhonen and Matti Järvisalo to enable weighted model counting over semirings in that we added a custom semiring to compile an sd-DNNF.Both are also included as a git submodules.The submodules can be obtained by runninggit submodule update --initThey can then be compiled viacd aspmc/external/sharpsat-td/
mkdir bin
bash setupdev.sh
cd ../../../
cd aspmc/external/d4/
make -j4
cd ../../../Optionally: c2d and miniC2DWe also are able to use c2d to obtain d-DNNF representations.
The c2d binary can be provided underaspmc/external/c2d/bin/asc2d_linuxand can be downloaded fromhere.
The miniC2D binary (and the hgr2htree binary) can be provided underaspmc/external/miniC2D/bin/linux/asminiC2D(andhgr2htree) and can be downloaded fromhere.Note that they are only available for research use.UsageThe basic usage ispython main.py [-m .] [-c] [-s .] [-n] [-t] [-ds .] [-dt .] [-k .] [-g .] [-h] [<INPUT-FILES>]
    --mode          -m  MODE        set input mode to MODE:
                                    * asp           : take a normal answer set program as input
                                    * problog       : take a problog program as input
                                    * smproblog     : take a problog program with negations as input
                                    * meuproblog    : take a problog program with extra decision and utility atoms as input
                                    * mapproblog    : take a problog program with extra evidence and map query atoms as input
    --count         -c              not only output the equivalent cnf as out.cnf but also performs (algebraic) counting of the answer sets
    --semiring      -s  SEMIRING    use the semiring specified in the python file aspmc/semirings/SEMIRING.py
                                    only useful with -m problog
    --no_pp         -n              does not perform cycle breaking and outputs a normalized version of the input program as `out.lp`
                                    the result is equivalent, ground and does not contain annotated disjunctions.
    --treewidth     -t              print the treewidth of the resulting CNF
    --decos         -ds SOLVER      set the solver that computes tree decompositions to SOLVER:
                                    * flow-cutter   : uses flow_cutter_pace17 (default)
    --decot         -dt SECONDS     set the timeout for computing tree decompositions to SECONDS (default: 1)
    --knowlege      -k  COMPILER    set the knowledge compiler to COMPILER:
                                    * sharpsat-td   : uses a compilation version of sharpsat-td (default)
                                    * d4            : uses the (slightly modified) d4 compiler. 
                                    * c2d           : uses the c2d compiler. 
                                    * miniC2D       : uses the miniC2D compiler. 
    --guide_clark   -g  GUIDE       set the tree decomposition type to use to guide the clark completion to GUIDE:
                                    * none          : preform the normal clark completion without guidance
                                    * ors           : guide for or nodes only 
                                    * both          : guide for both `and` and `or` nodes (default)
    --help          -h              print this help and exitExamplesThese examples are for when the code is downloaded via GitHub.
When using the pip package replacepython main.pybyaspmcto obtain the same result.ASP example:python main.py -m asp -c -f 
a :- not b.
b :- not a.Reads the program from stdin and counts its models.python main.py -m asp -c -f test/test_cycle.lpReads the same program from file and counts its models.problog examplepython main.py -m problog -c -f
0.5::a.
b :- a.
query(b).Evaluates the given simple program over the probability semiring.python main.py -m problog -c -s maxplus -f
0.5::a.
b :- a.
query(b).Evaluates the given simple program over the MaxPlus semiring.