{"id":18088443,"url":"https://github.com/prakaa/battery-optimisation-benchmarking","last_synced_at":"2025-04-13T03:13:56.618Z","repository":{"id":61673231,"uuid":"553288930","full_name":"prakaa/Battery-Optimisation-Benchmarking","owner":"prakaa","description":"Benchmarking MIP solutions across packages in Python and Julia","archived":false,"fork":false,"pushed_at":"2022-12-06T07:34:52.000Z","size":1662,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T03:13:30.326Z","etag":null,"topics":["battery","julia","linear-programming","mixed-integer-programming","optimization","python"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prakaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-18T02:01:34.000Z","updated_at":"2023-04-20T12:14:11.000Z","dependencies_parsed_at":"2023-01-24T12:31:05.474Z","dependency_job_id":null,"html_url":"https://github.com/prakaa/Battery-Optimisation-Benchmarking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prakaa%2FBattery-Optimisation-Benchmarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prakaa%2FBattery-Optimisation-Benchmarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prakaa%2FBattery-Optimisation-Benchmarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prakaa%2FBattery-Optimisation-Benchmarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prakaa","download_url":"https://codeload.github.com/prakaa/Battery-Optimisation-Benchmarking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657922,"owners_count":21140846,"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":["battery","julia","linear-programming","mixed-integer-programming","optimization","python"],"created_at":"2024-10-31T17:13:04.026Z","updated_at":"2025-04-13T03:13:56.590Z","avatar_url":"https://github.com/prakaa.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Battery-Optimisation-Benchmarking\r\nBenchmarking MIP solutions across packages in Python and Julia\r\n\r\n## Julia\r\n- [JuMP](https://github.com/UNSW-CEEM/Battery-Optimisation-Benchmarking/blob/master/battery_optimisation_benchmarking/julia/jump.ipynb)\r\n\r\n## Python\r\n- [linopy](https://github.com/UNSW-CEEM/Battery-Optimisation-Benchmarking/blob/master/battery_optimisation_benchmarking/python/linopy.ipynb)\r\n- [python-mip](https://github.com/UNSW-CEEM/Battery-Optimisation-Benchmarking/blob/master/battery_optimisation_benchmarking/python/mip.ipynb)\r\n- [pyomo](https://github.com/prakaa/Battery-Optimisation-Benchmarking/blob/master/battery_optimisation_benchmarking/python/pyomo.ipynb)\r\n\r\n## Bechmark Results\r\n\r\n**Note 1**: Julia is just-in-time compiled. The first run of a function will involve compilation, so the first run will generally always be slower. The table below reports times for first and subsequent runs as (first, subsequent)\r\n\r\n**Note 2**: Python packages are installed via `poetry`, which presumably uses `pip`. Using the `Pypy` versions of packages (where available) may improve times.\r\n\r\n**Note 3**: Linopy is still in alpha (at time of writing), so a direct comparison is not appropriate.\r\n\r\n**Note 3**: Times reflect rough average of 10 runs\r\n\r\n| Package (Language) | Solution?  | Cbc Solver Time (s) | Gurobi Solver Time (s) | HiGHS Solver Time (s) |\r\n|--------------------|------------|---------------------|------------------------|-----------------------|\r\n| pyomo (Python      | Yes        | ~7.2                | ~3.8                   | N/A                   |\r\n| mip (Python)       | Yes        | ~10.1               | ~1.6                   | N/A                   |\r\n| linopy (Python)    | Yes        | ~6.2                | ~2.7                   | ~5.8                  |\r\n| JuMP (Julia)       | Yes        | (~12.2, ~5.5)       | (~10.4, ~2.4)          | (~10.0, ~7.4)         |\r\n\r\n## Qualitative Comparison\r\n\r\n### JuMP:\r\n  - Pluses\r\n    - Has the best syntax and is the easiest framework to write models. \r\n    - Retrieving solutions requires understanding data structures, but is still simple\r\n      - Improved with addition of [`Tables.jl` support](https://github.com/jump-dev/JuMP.jl/releases/tag/v1.4.0)\r\n    - Decent performance and access to broad range of solvers\r\n    - Most featured, including callbacks and more problem types beyond MIP (e.g. NLP, QP, SOCP)\r\n    - Very very good documentation that is also a good intro to optimisation\r\n    - Extensions of varying maturity (e.g. stochastic programming)\r\n    - Passing solver level args is possible\r\n  - Downsides\r\n    - Has the downside of needing to learn Julia and some specific Julia syntax\r\n      - One option is to solve models in Julia then do everything else in Python. There is also PyCall.jl\r\n    - As Julia is just-in-time compiled, \"time-to-first-[plot,solve]\" can be long, but this can be reduced by things like PackageCompiler.jl. See [here](https://jump.dev/JuMP.jl/stable/tutorials/getting_started/performance_tips/)\r\n\r\n### python-mip:\r\n  - Pluses\r\n    - Relatively nice syntax for model creation\r\n    - Very fast and could be even faster if using Pypy\r\n    - Advanced MIP features (lazy constraints)\r\n  - Downsides\r\n    - Locked to LP or MIP\r\n    - Locked to Cbc or Gurobi\r\n    - Missing some features such as indicator constraints\r\n    - Retrieving solutions is awkward\r\n    \r\n### linopy\r\n  - Pluses\r\n    - Vectorised model creation that can use numpy, pandas or xarray data structures\r\n    - Solution retrieval is very easy\r\n    - Multiple solvers (though the python interfaces may be needed)\r\n    - Passing solver level args is possible\r\n  - Downsides\r\n    - Locked to LP or binary MIP as of Oct 22\r\n    - In alpha\r\n    - Stricter model definition (min only, all variables on LHS, variable * constant only)\r\n    - Constructing intertemporal constraints can require care (e.g. exclude t=0 intertemporal SoC constraint)\r\n    \r\n### pyomo\r\n  - Pluses\r\n    - Very mature and large user community\r\n    - Can formulate many types of problems and has multiple extensions (e.g. stochastic programming)\r\n    - Syntax is relatively compact\r\n    - Broad solver range (though HiGHS interface in development)\r\n    - Passing solver level args is possible\r\n    - Handling model components as attributes has several benefits, e.g. method call to retrieve solution results\r\n  - Downsides\r\n    - Syntax is rather arcane\r\n    - Docs could be better. Understanding how to build models often requires looking at examples.   \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprakaa%2Fbattery-optimisation-benchmarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprakaa%2Fbattery-optimisation-benchmarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprakaa%2Fbattery-optimisation-benchmarking/lists"}