{"id":13831513,"url":"https://github.com/ML-KULeuven/PySDD","last_synced_at":"2025-07-09T14:33:09.845Z","repository":{"id":40690658,"uuid":"125235210","full_name":"ML-KULeuven/PySDD","owner":"ML-KULeuven","description":"Python package for Sentential Decision Diagrams (SDD)","archived":false,"fork":false,"pushed_at":"2025-02-21T14:41:05.000Z","size":2042,"stargazers_count":62,"open_issues_count":2,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-27T20:43:21.498Z","etag":null,"topics":["cython","knowledge-compilation","model-counting","python","sdd","weighted-model-counting"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ML-KULeuven.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-14T15:37:17.000Z","updated_at":"2025-05-24T15:20:39.000Z","dependencies_parsed_at":"2024-08-04T10:06:48.471Z","dependency_job_id":"a178c459-5b79-4aa9-a3a7-19aaadb1534e","html_url":"https://github.com/ML-KULeuven/PySDD","commit_stats":{"total_commits":194,"total_committers":8,"mean_commits":24.25,"dds":"0.22164948453608246","last_synced_commit":"1f8a6624ca6d7b3df6242ebf30feb7b23f8e01f5"},"previous_names":["wannesm/pysdd"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ML-KULeuven/PySDD","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ML-KULeuven%2FPySDD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ML-KULeuven%2FPySDD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ML-KULeuven%2FPySDD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ML-KULeuven%2FPySDD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ML-KULeuven","download_url":"https://codeload.github.com/ML-KULeuven/PySDD/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ML-KULeuven%2FPySDD/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264476322,"owners_count":23614491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cython","knowledge-compilation","model-counting","python","sdd","weighted-model-counting"],"created_at":"2024-08-04T10:01:29.863Z","updated_at":"2025-07-09T14:33:09.526Z","avatar_url":"https://github.com/ML-KULeuven.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"=====\nPySDD\n=====\n\nPython wrapper package to interactively use `Sentential Decision Diagrams (SDD) \u003chttp://reasoning.cs.ucla.edu/sdd/\u003e`_.\n\nFull documentation available on http://pysdd.readthedocs.io.\n\n------------\nInstallation\n------------\n\n.. code-block:: shell\n\n   $ pip install PySDD\n\n\n--------------\nPython package\n--------------\n\nThe wrapper can be used as a Python package and allows for interactive use.\n\nThe following example builds an SDD for the formula ``a∧b ∨ b∧c ∨  c∧d``.\n\n.. code-block:: python\n\n    from pysdd.sdd import SddManager, Vtree, WmcManager\n    vtree = Vtree(var_count=4, var_order=[2,1,4,3], vtree_type=\"balanced\")\n    sdd = SddManager.from_vtree(vtree)\n    a, b, c, d = sdd.vars\n\n    # Build SDD for formula\n    formula = (a \u0026 b) | (b \u0026 c) | (c \u0026 d)\n\n    # Model Counting\n    wmc = formula.wmc(log_mode=False)\n    print(f\"Model Count: {wmc.propagate()}\")\n    wmc.set_literal_weight(a, 0.5)\n    print(f\"Weighted Model Count: {wmc.propagate()}\")\n\n    # Visualize SDD and Vtree\n    with open(\"output/sdd.dot\", \"w\") as out:\n        print(formula.dot(), file=out)\n    with open(\"output/vtree.dot\", \"w\") as out:\n        print(vtree.dot(), file=out)\n\nThe SDD and Vtree are visualized using Graphviz DOT:\n\n.. image:: https://people.cs.kuleuven.be/wannes.meert/pysdd/sdd.png\n.. image:: https://people.cs.kuleuven.be/wannes.meert/pysdd/vtree.png\n\n\n\nMore examples are available in the ``examples`` directory.\nAn interactive Jupyter notebook is available in\n`notebooks/examples.ipynb \u003cnotebooks/examples.ipynb\u003e`_\n\n\n----------------------\nCommand Line Interface\n----------------------\n\nA Python CLI application is installed if you use pip, ``pysdd``. Or it can be used\ndirectly from the source directory where it is called ``pysdd-cli.py``.\nThis script mimicks the original sdd binary and adds additional features (e.g. weighted model counting)\n\n.. code-block:: shell\n\n    $ pysdd -h\n    $ ./pysdd-cli.py -h\n    usage: pysdd-cli.py [-h] [-c FILE | -d FILE | -s FILE] [-v FILE] [-W FILE]\n                    [-V FILE] [-R FILE] [-S FILE] [-m] [-t TYPE] [-r K] [-q]\n                    [-p] [--log_mode]\n\n    Sentential Decision Diagram, Compiler\n\n    optional arguments:\n      -h, --help  show this help message and exit\n      -c FILE     set input CNF file\n      -d FILE     set input DNF file\n      -s FILE     set input SDD file\n      -v FILE     set input VTREE file\n      -W FILE     set output VTREE file\n      -V FILE     set output VTREE (dot) file\n      -R FILE     set output SDD file\n      -S FILE     set output SDD (dot) file\n      -m          minimize the cardinality of compiled sdd\n      -t TYPE     set initial vtree type (left/right/vertical/balanced/random)\n      -r K        if K\u003e0: invoke vtree search every K clauses. If K=0: disable\n                  vtree search. By default (no -r option), dynamic vtree search is\n                  enabled\n      -q          perform post-compilation vtree search\n      -p          verbose output\n      --log_mode  weights in log\n\n    Weighted Model Counting is performed if the NNF file containts a line\n    formatted as follows: \"c weights PW_1 NW_1 ... PW_n NW_n\".\n\n\n-----------------\nMemory management\n-----------------\n\nPython's memory management is not used for the internal datastructures.\nUse the SDD library's garbage collection commands (e.g. ref, deref) to\nperform memory management.\n\n\n-----------------------\nCompilation from source\n-----------------------\n\nTo install from source, make sure to have the correct development tools installed:\n\n* C compiler (see `Installing Cython \u003chttps://cython.readthedocs.io/en/latest/src/quickstart/install.html\u003e`_)\n* The Python development version that includes Python header files and static library (e.g. libpython3-dev, python-dev, ...)\n\nThe build process will download Cython and numpy in an isolated environment.\n\nThen run:\n\n.. code-block:: shell\n\n   $ pip install build\n   $ python -m build\n\n\nTo install the main branch:\n\n.. code-block:: shell\n\n   $ pip install git+https://github.com/wannesm/PySDD.git#egg=PySDD\n\n\n\n----------\nReferences\n----------\n\nThis package is inspired by the SDD wrapper used in the probabilistic\nprogramming language `ProbLog \u003chttps://dtai.cs.kuleuven.be/problog/\u003e`_.\n\nReferences:\n\n* Wannes Meert \u0026 Arthur Choi, PySDD,\n  in `Recent Trends in Knowledge Compilation\n  \u003chttp://drops.dagstuhl.de/opus/volltexte/2018/8589/pdf/dagrep_v007_i009_p062_17381.pdf\u003e`_,\n  Report from Dagstuhl Seminar 17381, Sep 2017.\n  Eds. A. Darwiche, P. Marquis, D. Suciu, S. Szeider.\n\nOther languages:\n\n* C: http://reasoning.cs.ucla.edu/sdd/\n* Java: https://github.com/jessa/JSDD\n\n\n-------\nContact\n-------\n\n* Wannes Meert, KU Leuven, https://people.cs.kuleuven.be/wannes.meert\n* Arthur Choi, UCLA, http://web.cs.ucla.edu/~aychoi/\n\n\n-------\nLicense\n-------\n\nPython SDD wrapper:\n\nCopyright 2017-2024, KU Leuven and Regents of the University of California.\nLicensed under the Apache License, Version 2.0.\n\n\nSDD package:\n\nCopyright 2013-2018, Regents of the University of California\nLicensed under the Apache License, Version 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FML-KULeuven%2FPySDD","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FML-KULeuven%2FPySDD","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FML-KULeuven%2FPySDD/lists"}