{"id":15912244,"url":"https://github.com/cdeil/python-discrete-optimization-examples","last_synced_at":"2025-03-22T16:30:34.347Z","repository":{"id":142038892,"uuid":"254386790","full_name":"cdeil/python-discrete-optimization-examples","owner":"cdeil","description":"Quick try-out of (mostly Python) discrete optimization packages","archived":false,"fork":false,"pushed_at":"2020-05-26T15:35:37.000Z","size":247,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T13:28:56.623Z","etag":null,"topics":["discrete-optimization","examples","operations-research","python","sudoku-solver","tutorials"],"latest_commit_sha":null,"homepage":null,"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/cdeil.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":"2020-04-09T14:00:48.000Z","updated_at":"2024-06-18T07:16:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0409e84-0d1d-4e35-bd2f-3e8b6ababef2","html_url":"https://github.com/cdeil/python-discrete-optimization-examples","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.07407407407407407,"last_synced_commit":"34e97ee221a6e431e9885609817e10b6f07284b3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdeil%2Fpython-discrete-optimization-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdeil%2Fpython-discrete-optimization-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdeil%2Fpython-discrete-optimization-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdeil%2Fpython-discrete-optimization-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdeil","download_url":"https://codeload.github.com/cdeil/python-discrete-optimization-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244986206,"owners_count":20542973,"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":["discrete-optimization","examples","operations-research","python","sudoku-solver","tutorials"],"created_at":"2024-10-06T16:03:27.021Z","updated_at":"2025-03-22T16:30:34.324Z","avatar_url":"https://github.com/cdeil.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-discrete-optimization-examples\n\nQuick try-out of (mostly Python) discrete optimization packages.\n\nContributions via pull requests welcome!\n\n## What is this?\n\nThe goal here is to find some that are performant, flexible, widely used, easy\nto install, easy to use, well maintained, have good documentation. At the\nmoment, the evaluation here is super limited, we just tried to install each code\nand get one simple example to run.\n\nSee README files, Python scripts and notebooks in the sub-folders for each\npackage.\n\nA nice introduction to some of these packages is [here](http://www.mathopt.org/Optima-Issues/optima103.pdf).\n\n## Examples\n\n* A `*_getting_started.py` for each package, with the front-page docs example, so that you can try it out quickly.\n* [Wikipedia Sudoku example](https://en.wikipedia.org/wiki/Sudoku)\n\n## Open-source codes\n\n* [Google OR-Tools](https://developers.google.com/optimization) - see [ortools](ortools)\n* [Pyomo](http://www.pyomo.org/) - see [pyomo](pyomo)\n* [JuMP](https://jump.dev/) - see [jump](jump) (this one is Julia, not Python)\n* [PuLP](https://coin-or.github.io/pulp/) - see [pulp](pulp)\n* [Python-MIP](https://www.python-mip.com/) - see [mip](mip)\n* [CVXPY](https://www.cvxpy.org/) - see [cvxpy](cvxpy)\n\nNote that there's two things:\n* [algebraic modeling languages](https://en.wikipedia.org/wiki/Algebraic_modeling_language)\n* Solvers, see e.g.\n  [here](https://www.juliaopt.org/JuMP.jl/stable/installation/) or\n  [here](https://en.wikipedia.org/wiki/AMPL#Solvers) or\n  [here](https://github.com/joaojunior/awesome-operational_research#solvers).\n\nWe're only looking at codes where the modeling language is a Python API.\nSometimes the line is a bit blurry and a package has built-in solvers, but\nusually the solvers are separate.\n\nThe list above is not extensive at all - just the best options we found so far.\n\n## Commercial codes\n\nUnfortunately, it seems that the most performant packages in this domain, such\nas [Gurobi](https://www.gurobi.com/), [SCIP](https://scip.zib.de/) or\n[CPLEX](https://www.ibm.com/analytics/cplex-optimizer) are proprietary and\nexpensive (on the order of 10 kEUR per year per user or machine). We will not\ntry those out here, since choosing an expensive product causes friction: how\nmany licenses, how to optimise their usage among developers and test and\nproduction machines, convincing the company to buy it. If we were to buy a\ncommercial package, using `gurobipy` seems to be a good choice.\n\nMost of the packages mentioned above (Google OR-Tools, Pyomo, JuMP) offer a\nmodel definition API, and have flexible solver backend support, including these\ncommercial solvers. So a possible strategy, if the modeling tool is good enough,\nto stick with it, and only make a small change to hook up to a better solver at\nsome later time, if needed.\n\nThere's also [NEOS Server](https://neos-server.org/) which could be used to try\nout different solvers, including the commercial ones, without purchasing a\nlicense, albeit only on test or open data.\n\n## Installation\n\nOne way to install the codes is to install [Anaconda](https://www.anaconda.com/)\nand use this to install all codes:\n\n```\nconda create -n python-discrete-optimization-examples anaconda\nconda activate python-discrete-optimization-examples\nconda config --add channels conda-forge\nconda install pyomo pyomo.extras coincbc ipopt glpk\nconda install pulp\npip install ortools\npip install mip\npip install cvxpy\n```\n\nThe COIN and OR-Tools packaging is being improved, see e.g.\n[here](https://github.com/coin-or/COIN-OR-OptimizationSuite) and\n[here](https://github.com/conda-forge/staged-recipes/issues/2717). There's a\nCOIN-OR\n[optimization-suite-docker](https://github.com/tkralphs/optimization-suite-docker),\nand we could also create our own docker image with all the codes we want to use.\n\nFor the Julia and JuMP installation instrucations, see [jump](jump)\n\n## References\n\n### Books\n\n* https://www.manning.com/books/classic-computer-science-problems-in-python\n* https://www.apress.com/de/book/9781484234228\n\n### Courses\n\n* https://www.coursera.org/learn/discrete-optimization\n* https://www.coursera.org/learn/basic-modeling\n* https://www.coursera.org/learn/julia-programming\n* https://www.edx.org/course/optimization-methods-for-business-analytics\n\n### Sudoku\n\n* https://emerentius.github.io/sudoku_web/\n* https://norvig.com/sudoku.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdeil%2Fpython-discrete-optimization-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdeil%2Fpython-discrete-optimization-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdeil%2Fpython-discrete-optimization-examples/lists"}