{"id":15303385,"url":"https://github.com/meelgroup/approxmc","last_synced_at":"2026-01-16T14:06:27.350Z","repository":{"id":43843518,"uuid":"157052469","full_name":"meelgroup/approxmc","owner":"meelgroup","description":"Approximate Model Counter","archived":false,"fork":false,"pushed_at":"2025-12-21T14:32:23.000Z","size":984,"stargazers_count":81,"open_issues_count":2,"forks_count":28,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-26T12:56:07.957Z","etag":null,"topics":["cnf-clauses","counting","dimacs-cnf","model-couting","sat","satisfiability"],"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/meelgroup.png","metadata":{"files":{"readme":"README.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-11-11T06:06:20.000Z","updated_at":"2025-12-14T12:02:31.000Z","dependencies_parsed_at":"2023-01-22T04:47:57.977Z","dependency_job_id":"ff078e29-51bd-45d7-853e-66385b2507b9","html_url":"https://github.com/meelgroup/approxmc","commit_stats":{"total_commits":558,"total_committers":9,"mean_commits":62.0,"dds":0.06093189964157708,"last_synced_commit":"eab29f5568020223b85b9fa3912ecbf12dd67652"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/meelgroup/approxmc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fapproxmc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fapproxmc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fapproxmc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fapproxmc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meelgroup","download_url":"https://codeload.github.com/meelgroup/approxmc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fapproxmc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cnf-clauses","counting","dimacs-cnf","model-couting","sat","satisfiability"],"created_at":"2024-10-01T06:01:59.614Z","updated_at":"2026-01-16T14:06:27.345Z","avatar_url":"https://github.com/meelgroup.png","language":"C++","funding_links":[],"categories":["Solvers"],"sub_categories":["SharpSAT (#SAT) Solvers"],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![build](https://github.com/meelgroup/approxmc/workflows/build/badge.svg)\n\n# ApproxMC6: Approximate Model Counter\nApproxMCv6 is a state-of-the-art approximate model counter using\n[Arjun](https://github.com/meelgroup/arjun) and\n[CryptoMiniSat](https://github.com/msoos/cryptominisat) to give probabilistic\napproximate model counts to problems of size and complexity that were not\npossible before.\n\nThis work is the culmination of work by a number of people. See publication list at the end of this README for more details.\n\nApproxMC handles CNF formulas and performs approximate counting.\n1. If you are interested in exact model counting, visit our exact counter\n   [Ganak](http://github.com/meelgroup/ganak)\n2. If you need to count a weighted CNF formula, you need to preprocess your CNF\n   using [our tool](https://github.com/meelgroup/weighted-to-unweighted) to\n   convert it to an unweighted CNF formula. Then you can use ApproxMC to count it.\n3. If you are interested in DNF formulas, visit our approximate DNF\n   counter [Pepin](https://github.com/meelgroup/pepin).\n\nNotice that for some formula families, Ganak is faster than ApproxMC. It\ncan be worthwhile to try both tools on your instances.\n\n## Installation\nYou can try out ApproxMC [from your browser](https://www.msoos.org/approxmc/).\n\nIt is strongly recommended to not build, but to use the precompiled\nbinaries as in our [release](https://github.com/meelgroup/approxmc/releases).\nThe second best thing to use is Nix. Simply [install\nnix](https://nixos.org/download/) and then:\n```shell\nnix shell github:meelgroup/approxmc#approxmc\n```\n\nThen you will have `approxmc` binary available and ready to use.\n\nIf this is somehow not what you want, you can also build it. See the [GitHub\nAction](https://github.com/meelgroup/approxmc/actions/workflows/build.yml) for the\nspecific set of steps.\n\n## Providing a Projection Set\nFor some applications, one is not interested in solutions over all the\nvariables and instead interested in counting the number of unique solutions to\na subset of variables, called sampling set (also called a \"projection set\").\nApproxMC allows you to specify the sampling set using the following modified\nversion of DIMACS format:\n\n```plain\n$ cat myfile.cnf\nc p show 1 3 4 6 7 8 10 0\np cnf 500 1\n3 4 0\n```\nAbove, using the `c p show` line, we declare that only variables 1, 3, 4, 6, 7,\n8 and 10 form part of the sampling set out of the CNF's 500 variables\n`1,2...500`. This line must end with a 0. The solution that ApproxMC will be\ngiving is essentially answering the question: how many different combination of\nsettings to this variables are there that satisfy this problem? Naturally, if\nyour sampling set only contains 7 variables, then the maximum number of\nsolutions can only be at most 2^7 = 128. This is true even if your CNF has\nthousands of variables.\n\n## Running ApproxMC\nIn our case, the maximum number of solutions could at most be 2^7=128, but our\nCNF should be restricting this. Let's see:\n\n```plain\n$ approxmc --seed 5 myfile.cnf\nc ApproxMC version 3.0\n[...]\nc CryptoMiniSat SHA revision [...]\nc Using code from 'When Boolean Satisfiability Meets Gauss-E. in a Simplex Way'\n[...]\n[appmc] using seed: 5\n[appmc] Sampling set size: 7\n[appmc] Sampling set: 1, 3, 4, 6, 7, 8, 10,\n[appmc] Using start iteration 0\n[appmc] [    0.00 ] bounded_sol_count looking for   73 solutions -- hashes active: 0\n[appmc] [    0.01 ] bounded_sol_count looking for   73 solutions -- hashes active: 1\n[appmc] [    0.01 ] bounded_sol_count looking for   73 solutions -- hashes active: 0\n[...]\n[appmc] FINISHED ApproxMC T: 0.04 s\nc [appmc] Number of solutions is: 48*2**1\ns mc 96\n```\nApproxMC reports that we have approximately `96 (=48*2)` solutions to the CNF's\nindependent support. This is because for variables 3 and 4 we have banned the\n`false,false` solution, so out of their 4 possible settings, one is banned.\nTherefore, we have `2^5 * (4-1) = 96` solutions.\n\n## Guarantees\nApproxMC provides so-called \"PAC\", or Probably Approximately Correct,\nguarantees. In less fancy words, the system guarantees that the solution found\nis within a certain tolerance (called \"epsilon\") with a certain probability\n(called \"delta\"). The default tolerance and probability, i.e. epsilon and delta\nvalues, are set to 0.8 and 0.2, respectively. Both values are configurable.\n\n## How to use the Python interface\nInstall using pip:\n```bash\npip install pyapproxmc\n```\n\nThen you can use it as:\n```python\nimport pyapproxmc\nc = pyapproxmc.Counter()\nc.add_clause([1,2,3])\nc.add_clause([3,20])\ncount = c.count()\nprint(\"Approximate count is: %d*2**%d\" % (count[0], count[1]))\n```\n\nThe above will print that `Approximate count is: 11*2**16`. Since the largest\nvariable in the clauses was 20, the system contained 2\\*\\*20 (i.e. 1048576)\npotential models. However, some of these models were prohibited by the two\nclauses, and so only approximately 11*2\\*\\*16 (i.e. 720896) models remained.\n\nIf you want to count over a projection set, you need to call\n`count(projection_set)`, for example:\n```python\nimport pyapproxmc\nc = pyapproxmc.Counter()\nc.add_clause([1,2,3])\nc.add_clause([3,20])\ncount = c.count(range(1,10))\nprint(\"Approximate count is: %d*2**%d\" % (count[0], count[1]))\n```\n\nThis now prints `Approximate count is: 7*2**6`, which corresponds to the\napproximate count of models, projected over variables 1..10.\n\n### Library usage\nThe system can be used as a library:\n\n```c++\n#include \u003capproxmc/approxmc.h\u003e\n#include \u003cvector\u003e\n#include \u003ccassert\u003e\n\nusing std::vector;\nusing namespace ApproxMC;\nusing namespace CMSat;\n\nint main() {\n    AppMC appmc;\n    appmc.new_vars(10);\n\n    vector\u003cLit\u003e clause;\n\n    //add \"-3 4 0\"\n    clause.clear();\n    clause.push_back(Lit(2, true));\n    clause.push_back(Lit(3, false));\n    appmc.add_clause(clause);\n\n    //add \"3 -4 0\"\n    clause.clear();\n    clause.push_back(Lit(2, false));\n    clause.push_back(Lit(3, true));\n    appmc.add_clause(clause);\n\n    SolCount c = appmc.count();\n    uint32_t cnt = std::pow(2, c.hashCount)*c.cellSolCount;\n    assert(cnt == std::pow(2, 9));\n\n    return 0;\n}\n```\n\n## Sparse XOR Counting\nYou can turn on the sparse XORs using the flag `--sparse 1` but beware as reported in\n[LICS-20](http://www.cs.toronto.edu/~meel/Papers/lics20-ma.pdf) paper,\nthis may slow down solving in some cases. It is likely to give a\nsignificant speedup if the number of solutions is very large.\n\n## How to Cite\nIf you use ApproxMC, please cite the following papers:\n[CAV-23](https://arxiv.org/pdf/2305.09247)\n, [AAAI-19](https://www.cs.toronto.edu/~meel/Papers/aaai19-sm.pdf)\n, [CAV-20](https://www.cs.toronto.edu/~meel/Papers/cav20-sgm.pdf)\n, [CAV-20](https://dblp.uni-trier.de/rec/conf/cav/SoosGM20.html?view=bibtex)\n, [LICS-20](https://www.cs.toronto.edu/~meel/publications/AM20.bib)\n, [AAAI-19](https://www.cs.toronto.edu/~meel/publications/SM19.bib)\n, [IJCAI-16](https://www.cs.toronto.edu/~meel/publications/CMV16.bib)\n, [CP-13](https://www.cs.toronto.edu/~meel/publications/CMV13b.bib)\n\nAdditional related publications can be found [here](https://www.cs.toronto.edu/~meel/publications.html)\n\n## Benchmarks Used\nThe benchmarks used in our evaluation can be found [here](https://zenodo.org/records/10449477)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeelgroup%2Fapproxmc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeelgroup%2Fapproxmc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeelgroup%2Fapproxmc/lists"}