{ "info": { "author": "Rahul Gupta", "author_email": "rahujupiter@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools" ], "description": "# WAPS-Sampler\nWAPS, Weighted And Projected Sampler, generates samples on a sampling set conforming to a weight distribution defined by a literal-weighted weight function. It operates by using a compiled deterministic decomposable negation normal form (d-DNNF) of a CNF. It expects CNF in the DIMACS format and d-DNNF in the same format as that produced by the [C2D compiler](http://reasoning.cs.ucla.edu/c2d/). Is is based on our paper titled \"WAPS:Weighted and Projected Sampling\" as published in TACAS-2019 conference.\n\n## Installation\n```bash\nsudo apt-get install graphviz\nsudo apt-get install libgmp-dev\nsudo apt-get install libmpfr-dev\nsudo apt-get install libmpc-dev\npip install -r requirements.txt\nwget -P bin/ http://www.cril.univ-artois.fr/KC/ressources/d4\nchmod u+x bin/d4\n```\n\nFor now, [D4 compiler](http://www.cril.univ-artois.fr/KC/d4.html) and [Dsharp_PCompile](https://bitbucket.org/haz/dsharp) (modified for our use case, see the \"PCompile\" procedure) are included as default for compiling CNF to d-DNNF. Any other compiler can be easily used with slight modifications.\n\n## Running WAPS\nYou can run WAPS by using 'waps.py' Python script present in waps directory. A simple invocation looks as follows:\n```bash\npython3 waps.py \n```\nThe usage instructions and default values to arguments can be found by running\n```bash\npython3 waps.py -h\n```\n## Weight Format\nWAPS supports providing weights in CNF itself apart from being provided separately in a file. Weight of a literal is in [0,inf], specified by line starting with 'w',literal, and weight separated by space. Later, WAPS normalizes it such that weight(l)+weight(-l)=1 where l is a literal. While weights for both positive and negative literals should be specified, if weight of only positive literal is specified, waps assumes it to be normalized and assigns weight of negative literal as 1 - weight(l). By default, every literal's weight is set to 0.5, if its value is not given in CNF or the weightfile. \n\n## Specifying sampling set\nWAPS supports providing sampling set in CNF itself. It is specified by lines starting with 'c ind' ,var indexes separated by space, and ended by 0. If sampling set is not provided, by default, every variable specified in formula is assumed to be a part of sampling set.\n\n## Output Format\nThe output samples are stored in samples.txt by default. Each line of the output consists of a serial number of the sample followed by a satisfying assignment projected on sampling set. The satisfying assignment consists of literals seperated by space. Note that turning random assignment (--randAssign) to 0 can lead to partial assignments in each line. In such cases, the unassigned sampling variables can be chosen to be True or False.\n\nAlso, WAPS can output a graphical representation of d-DNNF for the input NNF. In this d-DNNF, the leaves consists of literals and internal nodes can be OR ('O') or AND ('A') nodes as expected for an NNF. However, internal nodes also contain 2 numbers seperated by space in our representation. This second one gives the annotation. The first one, only serves the purpose of distinguishing between individual OR and AND nodes and has no other meaning.\n\n## Benchmarks\nBenchmarks can be found [here](https://drive.google.com/open?id=1AQnpPwqJ-3ouwqKGw_VIjqWEHfQCnzBM).\n\n## Python Usage\nWAPS is also available as a library on PyPI, installable via pip. \n```bash\nsudo apt-get install graphviz\nsudo apt-get install libgmp-dev\nsudo apt-get install libmpfr-dev\nsudo apt-get install libmpc-dev\nwget https://github.com/meelgroup/WAPS/master/bin/Dsharp_PCompile\nwget http://www.cril.univ-artois.fr/kc/ressources/d4\nchmod u+x Dsharp_PCompile\nchmod u+x d4\nsudo mv Dsharp_PCompile /usr/local/bin/\nsudo mv d4 /usr/local/bin/\npip install waps\n```\nPlease reload your shell so that binaries are accessible via PATH.\n\nA typical usage is as follows:\n```python\nfrom waps import sampler\n\nsampler = sampler(cnfFile=\"toy.cnf\")\nsampler.compile()\nsampler.parse()\nsampler.annotate()\nsamples = sampler.sample()\nprint(list(samples))\n```\n\nYou can find more information on usage by:\n```python\nfrom waps import sampler\nhelp(sampler)\n```\n\n\n## Issues, questions, bugs, etc.\nPlease click on \"issues\" at the top and [create a new issue](https://github.com/meelgroup/WAPS/issues). All issues are responded to promptly.\n\n## How to Cite\n```\n@inproceedings{GSRM19,\nauthor={Gupta, Rahul and Sharma, Shubham and Roy, Subhajit and Meel, Kuldeep S.},\ntitle={WAPS: Weighted and Projected Sampling},\nbooktitle={Proceedings of Tools and Algorithms for the Construction and Analysis of Systems (TACAS)},\nmonth={4},\nyear={2019},\ncode={https://github.com/meelgroup/WAPS},\nabstract={Previous work on applying Knowledge compilation has focused on uniform sampling over all the variables. Since the constraints are written in high level languages such as Verilog, the popular CNF encoding schemes as Tseitin encoding introduces additional auxiliary variables. The resulting CNF formulas are not equivalent but equisatisfiable. In particular, for a formula $G$ specified in high level language we obtain a CNF formula F such that $G (X) = \\exists Y F(X,Y)$. This makes one wonder if it is possible to extend Knowledge compilation based techniques to sample over a subset of variables. Furthermore, languages such as Verilog allow specification of weights to user-defined constraints, so there is a need to sample according to the posterior distribution. In this paper, we provide affirmative question to the above two questions: We propose KUS that samples over user defined subset of variables from posterior distribution for a given prior distribution defined over product spaces.},\n}\n```\n\n## Contributors\n * Rahul Gupta (grahul@iitk.ac.in)\n * Shubham Sharma (smsharma@iitk.ac.in)\n * Subhajit Roy (subhajit@iitk.ac.in)\n * Kuldeep Meel (meel@comp.nus.edu.sg)\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/meelgroup/waps/archive/v1.0.2.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/meelgroup/waps/", "keywords": "sampling,cnf,weighted sampling,projected sampling,dDNNF", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "waps", "package_url": "https://pypi.org/project/waps/", "platform": "", "project_url": "https://pypi.org/project/waps/", "project_urls": { "Download": "https://github.com/meelgroup/waps/archive/v1.0.2.tar.gz", "Homepage": "https://github.com/meelgroup/waps/" }, "release_url": "https://pypi.org/project/waps/1.0.2/", "requires_dist": [ "numpy", "pydot", "gmpy2", "pyparsing" ], "requires_python": "", "summary": "This library can be used to sample satisfying assignments for a CNF/DNF obeying a given literal-weighted weight function and projected upon a given sampling set.", "version": "1.0.2" }, "last_serial": 4981139, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "3c99251517c02f764b7bff2a0d279453", "sha256": "f938ca2f8cfaa8b94af85fa4483f1e9ad4877abf5aa5867368b231701742535b" }, "downloads": -1, "filename": "waps-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3c99251517c02f764b7bff2a0d279453", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11073, "upload_time": "2019-03-25T07:01:14", "url": "https://files.pythonhosted.org/packages/57/21/6ac87a065d976191cc761e27968f0918f2078ff43e494a47c93c10634dfc/waps-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b70a6def9975a5b26032f0715dd905d", "sha256": "4cab430e02cc8e8906628cb3a991cd3e8cc2eed027a5d2671d6dbdf2b073fc5c" }, "downloads": -1, "filename": "WAPS-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1b70a6def9975a5b26032f0715dd905d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11346, "upload_time": "2019-03-24T19:06:14", "url": "https://files.pythonhosted.org/packages/50/12/db1c5c83a7422d6c8b23d8cdaead3684c4630a03eee683ffa01c4ddd4be4/WAPS-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "657c4c55826e3765e799236dd73edc07", "sha256": "05481d60387f840f84dcc63221f911a23ccc5691798ad4ba4aae97d502e442e3" }, "downloads": -1, "filename": "WAPS-1.0.tar.gz", "has_sig": false, "md5_digest": "657c4c55826e3765e799236dd73edc07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1198738, "upload_time": "2019-03-24T19:06:18", "url": "https://files.pythonhosted.org/packages/a1/77/da99db9a383cb43f865e3a0746aa32334f5cb4338dfd093c378a018632b7/WAPS-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "94daf32a3b51c9317226019dbb2906a7", "sha256": "bf08c3f4f661ea2010f7e13c037cee149c67afba210052b36bf91f033ff85d6c" }, "downloads": -1, "filename": "waps-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "94daf32a3b51c9317226019dbb2906a7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11098, "upload_time": "2019-03-25T07:03:57", "url": "https://files.pythonhosted.org/packages/e2/5c/ad0fa0867a1d47c7ca45a026ebfcc904fa248f66bd35546eb6c7b7542328/waps-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "392b0579498a4e1b495334e1d0e10ef6", "sha256": "2485ab776ca93ee5bdc8d22bae4dba49f2fdbaf3bc2e23888a2cc81d044a60a5" }, "downloads": -1, "filename": "waps-1.0.1.tar.gz", "has_sig": false, "md5_digest": "392b0579498a4e1b495334e1d0e10ef6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10354, "upload_time": "2019-03-25T07:03:58", "url": "https://files.pythonhosted.org/packages/ed/31/00f53a298b834a6f09ad492568081c1c92bca3716c709b416ded66090d5b/waps-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "e7c41f68b608ba8c0471839745a39443", "sha256": "afefe88980853a725ac32282f849023e89f6522af1d75540261eea5362186845" }, "downloads": -1, "filename": "waps-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e7c41f68b608ba8c0471839745a39443", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11099, "upload_time": "2019-03-25T07:11:06", "url": "https://files.pythonhosted.org/packages/cc/4f/7bc67ad167f7731028375302552d8ade14b2b0156c9cadfbfb51016229ed/waps-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "610282139fc18bb820bf01b08f568fd5", "sha256": "437dd8f029befcd4904e2ece48f7fa7f2242e0e516e1a9a78e4af518ac0876c6" }, "downloads": -1, "filename": "waps-1.0.2.tar.gz", "has_sig": false, "md5_digest": "610282139fc18bb820bf01b08f568fd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10351, "upload_time": "2019-03-25T07:11:07", "url": "https://files.pythonhosted.org/packages/58/89/c7c565db9ce4320916d1b93ae206071ddc15a373816fb0ce567201f0f042/waps-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e7c41f68b608ba8c0471839745a39443", "sha256": "afefe88980853a725ac32282f849023e89f6522af1d75540261eea5362186845" }, "downloads": -1, "filename": "waps-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e7c41f68b608ba8c0471839745a39443", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11099, "upload_time": "2019-03-25T07:11:06", "url": "https://files.pythonhosted.org/packages/cc/4f/7bc67ad167f7731028375302552d8ade14b2b0156c9cadfbfb51016229ed/waps-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "610282139fc18bb820bf01b08f568fd5", "sha256": "437dd8f029befcd4904e2ece48f7fa7f2242e0e516e1a9a78e4af518ac0876c6" }, "downloads": -1, "filename": "waps-1.0.2.tar.gz", "has_sig": false, "md5_digest": "610282139fc18bb820bf01b08f568fd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10351, "upload_time": "2019-03-25T07:11:07", "url": "https://files.pythonhosted.org/packages/58/89/c7c565db9ce4320916d1b93ae206071ddc15a373816fb0ce567201f0f042/waps-1.0.2.tar.gz" } ] }