{"id":20064732,"url":"https://github.com/thinklab-sjtu/t2tco","last_synced_at":"2025-07-05T05:06:07.262Z","repository":{"id":204885152,"uuid":"712863006","full_name":"Thinklab-SJTU/T2TCO","owner":"Thinklab-SJTU","description":"[NeurIPS 2023] T2T: From Distribution Learning in Training to Gradient Search in Testing for Combinatorial Optimization","archived":false,"fork":false,"pushed_at":"2025-01-27T11:06:52.000Z","size":15295,"stargazers_count":61,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T19:48:54.255Z","etag":null,"topics":["combinatorial-optimization","diffusion","generative-model","graph","machine-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thinklab-SJTU.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}},"created_at":"2023-11-01T11:02:33.000Z","updated_at":"2025-03-05T04:11:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"208525e9-e165-4bbd-81ac-1b13490264cb","html_url":"https://github.com/Thinklab-SJTU/T2TCO","commit_stats":null,"previous_names":["thinklab-sjtu/t2tco"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Thinklab-SJTU/T2TCO","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinklab-SJTU%2FT2TCO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinklab-SJTU%2FT2TCO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinklab-SJTU%2FT2TCO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinklab-SJTU%2FT2TCO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thinklab-SJTU","download_url":"https://codeload.github.com/Thinklab-SJTU/T2TCO/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinklab-SJTU%2FT2TCO/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263687147,"owners_count":23496088,"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":["combinatorial-optimization","diffusion","generative-model","graph","machine-learning"],"created_at":"2024-11-13T13:47:33.179Z","updated_at":"2025-07-05T05:06:07.251Z","avatar_url":"https://github.com/Thinklab-SJTU.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# T2T: From Distribution Learning in Training to Gradient Search in Testing for Combinatorial Optimization\n\nOfficial implementation of **NeurIPS 2023** paper: \"[T2T: From Distribution Learning in Training to Gradient Search in Testing for Combinatorial Optimization](https://openreview.net/forum?id=JtF0ugNMv2)\".\n\nAuthors: Yang Li, Jinpei Guo, Runzhong Wang, Junchi Yan.\n\nThe improved version has been published in **NeurIPS 2024**: \"[Fast T2T: Optimization Consistency Speeds Up Diffusion-Based Training-to-Testing Solving for Combinatorial Optimization](https://openreview.net/forum?id=xDrKZOZEOc)\".\n\n![fig1](figs/fig1.png)\n\n![fig2](figs/fig2.png)\n\n**Abstract:** Extensive experiments have gradually revealed the potential performance bottleneck of modeling Combinatorial Optimization (CO) solving as neural solution prediction tasks. The neural networks, in their pursuit of minimizing the average objective score across the distribution of historical problem instances, diverge from the core target of CO of seeking optimal solutions for every test instance. This calls for an effective search on each problem instance, while the model should serve to provide supporting knowledge that benefits the search. To this end, we propose T2TCO (Training to Testing) framework  that first leverages the generative modeling to estimate the high-quality solution distribution for each instance during training, and then conducts a gradient-based search within the solution space during testing. The proposed neural search paradigm consistently leverages generative modeling, specifically diffusion, for graduated solution improvement. It disrupts the local structure of the given solution by introducing noise and reconstructs a lower-cost solution guided by the optimization objective.  Experimental results on Traveling Salesman Problem (TSP) and Maximal Independent Set (MIS) show the significant superiority of T2TCO, demonstrating an average performance gain of 49.15% for TSP solving and 17.27% for MIS solving compared to the previous state-of-the-art.\n\n## Setup\n\nThe implementation is primarily developed on top of [DIFUSCO](https://github.com/Edward-Sun/DIFUSCO)'s code foundation.\n\n```bash\nconda env create -f environment.yml\nconda activate t2tco\n```\n\nRunning TSP experiments requires installing the additional cython package for merging the diffusion heatmap results:\n\n```bash\ncd diffusion/utils/cython_merge\npython setup.py build_ext --inplace\ncd -\n```\n\n## Data and Pretrained Checkpoints\n\nWe provide the evaluation data for TSP in `data/tsp`. For other details, please refer to `data` folder. Please download the pretrained model checkpoints from [here](https://drive.google.com/drive/folders/1IjaWtkqTAs7lwtFZ24lTRspE0h1N6sBH?usp=sharing) and [mis_er_categorizal](https://drive.google.com/file/d/1f3tNzpANSecJsn5ClgzRQ0lX6v1TPpXn/view?usp=sharing).\n\n## Reproduction\n\nPlease refer to [DIFUSCO](https://github.com/Edward-Sun/DIFUSCO) for the training process. Evaluation scripts can be directly found in `scripts` folder.\n\nEvaluation can be simply conducted through:\n\n```bash\n# TSP\nbash tsp50.sh  # evaluate on 50-node TSP instances\nbash tsp100.sh  # evaluate on 100-node TSP instances\nbash tsp500.sh  # evaluate on 500-node TSP instances\nbash tsp1000.sh  # evaluate on 1000-node TSP instances\nbash tsplib50-200.sh  # evaluate on TSPLIB instances with 50-200 nodes\nbash tsplib200-1000.sh  # evaluate on TSPLIB instances with 200-1000 nodes\n\n# MIS\nbash mis_er.sh  # evaluate on ER instances\nbash mis_satlib.sh  # evaluate on SATLIB instances\n```\n\nFor instance, a simple run of T2TCO on TSP50 data:\n\n```bash\nexport PYTHONPATH=\"$PWD:$PYTHONPATH\"\nexport CUDA_VISIBLE_DEVICES=0,1,2,3\n\npython -u diffusion/train.py \\\n  --task \"tsp\" \\\n  --wandb_logger_name \"tsp50\" \\\n  --storage_path \"./\" \\\n  --validation_split \"data/tsp/tsp50_concorde.txt\" \\\n  --test_split \"data/tsp/tsp50_concorde.txt\" \\\n  --validation_examples 8 \\\n  --inference_schedule \"cosine\" \\\n  --inference_diffusion_steps 50 \\\n  --two_opt_iterations 1000 \\\n  --resume_weight_only \\\n  --ckpt_path \"ckpts/tsp50_categorical.ckpt\" \\\n  --parallel_sampling 1 \\\n  --rewrite_ratio 0.4 \\\n  --norm \\\n  --rewrite\n```\n\nHyperparameter setting for reproduction:\n\n|          | TSP-50 | TSP-100 | TSP-500 | TSP-1000 | SATLIB | ER-[700-800] |\n| -------- | ------ | ------- | ------- | -------- | ------ | ------------ |\n| $\\alpha$ | 0.4    | 0.4     | 0.25    | 0.25     | 0.1    | 0.1          |\n\n## Reference\n\nIf you found this codebase useful, please consider citing the paper:\n\n```\n@inproceedings{li2023t2t,\n  title = {T2T: From Distribution Learning in Training to Gradient Search in Testing for Combinatorial Optimization},\n  author = {Li, Yang and Guo, Jinpei and Wang, Runzhong and Yan, Junchi},\n  booktitle = {Advances in Neural Information Processing Systems},\n  year = {2023}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinklab-sjtu%2Ft2tco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinklab-sjtu%2Ft2tco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinklab-sjtu%2Ft2tco/lists"}