{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/one-model-any-csp-graph-neural-networks-as","title":"One Model, Any CSP: Graph Neural Networks as Fast Global Search Heuristics for Constraint Satisfaction","arxiv_id":"2208.10227","date":"2022-08-22","proceeding":null,"authors":["Jan Tönshoff","Berke Kisin","Jakob Lindner","Martin Grohe"],"abstract":"We propose a universal Graph Neural Network architecture which can be trained as an end-2-end search heuristic for any Constraint Satisfaction Problem (CSP). Our architecture can be trained unsupervised with policy gradient descent to generate problem specific heuristics for any CSP in a purely data driven manner. The approach is based on a novel graph representation for CSPs that is both generic and compact and enables us to process every possible CSP instance with one GNN, regardless of constraint arity, relations or domain size. Unlike previous RL-based methods, we operate on a global search action space and allow our GNN to modify any number of variables in every step of the stochastic search. This enables our method to properly leverage the inherent parallelism of GNNs. We perform a thorough empirical evaluation where we learn heuristics for well known and important CSPs from random data, including graph coloring, MaxCut, 3-SAT and MAX-k-SAT. Our approach outperforms prior approaches for neural combinatorial optimization by a substantial margin. It can compete with, and even improve upon, conventional search heuristics on test instances that are several orders of magnitude larger and structurally more complex than those seen during training.","url_abs":"https://arxiv.org/abs/2208.10227v1","url_pdf":"https://arxiv.org/pdf/2208.10227v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"one-model-any-csp-graph-neural-networks-as","repo_url":"https://github.com/toenshoff/runcsp-pytorch","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"combinatorial-optimization","task_name":"Combinatorial Optimization"},{"task_slug":"graph-neural-network","task_name":"Graph Neural Network"}],"methods":[{"method_slug":"graph-neural-network","method_name":"Graph Neural Network"},{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2208.10227","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2208.10227"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/toenshoff/runcsp-pytorch","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":8},"by_repo_kind":{"official":{"samples":8,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"25baf66017fe6269","entry":"csp_loss","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"loss.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/loss.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"25baf66017fe6269"}},{"code_sha256_prefix":"62765ff126646d94","entry":"generate_geo_graph","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"generate_k_col.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/generate_k_col.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"62765ff126646d94"}},{"code_sha256_prefix":"d9fd24315468b0ee","entry":"generate_gnm_graph","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"generate_k_col.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/generate_k_col.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d9fd24315468b0ee"}},{"code_sha256_prefix":"e60acdecfd9f031c","entry":"generate_pwl_graph","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"generate_k_col.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/generate_k_col.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e60acdecfd9f031c"}},{"code_sha256_prefix":"f11a6a4cccea3570","entry":"load_dimacs_cnf","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"data_utils.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/data_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f11a6a4cccea3570"}},{"code_sha256_prefix":"1f9f28ca34a9e801","entry":"load_dimacs_graph","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"data_utils.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/data_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1f9f28ca34a9e801"}},{"code_sha256_prefix":"80f967339c97fa8d","entry":"load_graphs","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"data_utils.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/data_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"80f967339c97fa8d"}},{"code_sha256_prefix":"eb5897f28483da0e","entry":"mis_loss","repo":"toenshoff/runcsp-pytorch","repo_kind":"official","path":"loss.py","file_url":"https://github.com/toenshoff/runcsp-pytorch/blob/HEAD/loss.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"eb5897f28483da0e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}