{"id":15286734,"url":"https://github.com/infrasenselabs/roundandswap.jl","last_synced_at":"2026-05-27T18:31:26.562Z","repository":{"id":52340821,"uuid":"520810942","full_name":"infrasenselabs/RoundAndSwap.jl","owner":"infrasenselabs","description":"Easily implement a heuristic for solving Mixed Integer problems","archived":false,"fork":false,"pushed_at":"2023-01-06T08:40:43.000Z","size":455,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T08:30:20.715Z","etag":null,"topics":["julia","optimization"],"latest_commit_sha":null,"homepage":"","language":"Julia","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/infrasenselabs.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}},"created_at":"2022-08-03T09:10:20.000Z","updated_at":"2023-01-06T08:38:07.000Z","dependencies_parsed_at":"2023-02-05T17:45:41.775Z","dependency_job_id":null,"html_url":"https://github.com/infrasenselabs/RoundAndSwap.jl","commit_stats":null,"previous_names":["this-josh/roundandswap.jl"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrasenselabs%2FRoundAndSwap.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrasenselabs%2FRoundAndSwap.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrasenselabs%2FRoundAndSwap.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrasenselabs%2FRoundAndSwap.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infrasenselabs","download_url":"https://codeload.github.com/infrasenselabs/RoundAndSwap.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247424776,"owners_count":20936827,"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":["julia","optimization"],"created_at":"2024-09-30T15:18:23.052Z","updated_at":"2025-12-11T23:03:09.629Z","avatar_url":"https://github.com/infrasenselabs.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./docs/src/assets/logo.png\" width=20% height=20%\u003e\n\u003c/p\u003e\n\n# RoundAndSwap.jl\n\n| **Documentation**                                                               | **Build Status**                                                                                |\n|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|\n| [![][docs-stable-img]][docs-stable-url] [![][docs-dev-img]][docs-dev-url] | [![][GHA-img]][GHA-url] [![][codecov-img]][codecov-url] |\n\n\n[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg\n[docs-dev-url]: https://this-josh.github.io/RoundAndSwap.jl/dev/\n\n[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg\n[docs-stable-url]: https://this-josh.github.io/RoundAndSwap.jl/stable/\n\n[GHA-img]: https://github.com/this-josh/RoundAndSwap.jl/actions/workflows/runtests.yml/badge.svg\n[GHA-url]: https://github.com/this-josh/RoundAndSwap.jl/actions/workflows/runtests.yml\n\n[codecov-img]: https://codecov.io/gh/this-josh/RoundAndSwap.jl/branch/main/graph/badge.svg?token=hfQGPZjl2y\n[codecov-url]: https://codecov.io/gh/this-josh/RoundAndSwap.jl\n\n\n\n`RoundAndSwap.jl` is a library which implements the Round and Swap algorithm, this implementation was inspired by Filippo Pecci's usage in [Bounds and Convex Heuristics for Bi-Objective Sensor Placement in Water Networks](https://arxiv.org/abs/2207.04897).\n\n\n## Getting started\n\n1.  Create your JuMP model, and optimize\n```julia\n# Define how many variables you want fixed\nnum_to_fix = 2\n\nusing JuMP, HiGHS\nmodel = Model(HiGHS.Optimizer)\n@variable(model, 0 ≤ a ≤ 1)\n@variable(model, 0 ≤ b ≤ 1)\n@variable(model, 0 ≤ c ≤ 1)\n@variable(model, 0 ≤ d ≤ 1)\n@constraint(model, a + b + c + d == num_to_fix)\n@objective(model, Max, (a + b) + (2 * (b + c)) + (3 * (c - d)) + (4 * (d + a)))\n\n# To demonstate functionality we will fix b and d\nfix(b, 0.8; force=true)\nfix(d, 0.8; force=true)\n\noptimize!(model)\n```\n2. Identify which variable we are considering making `1`\n```julia\nconsider_swapping = [a,b,c,d]\n```\n\n3. Round variables closest to `1`, this will be b and d as we fixed them at `0.8`.\n```julia\nusing RoundAndSwap\nround!(consider_swapping, num_to_fix)\n```\n4. Begin swapping\n```julia\nbest_swap, swapper = swap(model, consider_swapping)\n```\n5. Review your best swap\n```julia\njulia\u003e best_swap\n1-element Vector{Swap}:\n Swap \n    existing:           b\n    new:                a\n    obj_value:          10.0          \n    success:            true            \n    all_fixed:          [:a, :c]          \n    termination_status: OPTIMAL \n    solve_time:         0.0004438320000872409\n    swap_number:        7\n```\nAs you can see in this case we found the globally optimal solution of 10.\n *Note:* Round and Swap does not provide guarantees of global optimility.\n\n### caveats\n\n* Currently can only set variables to `0` or `1`.\n\n## Performance\n\nIn testing I've done 536 swaps with `round_and_swap` taking 174.1 seconds with 172.8 seconds of that being in the optimizer, giving `RoundAndSwap.jl` an overhead of 0.75%.  \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrasenselabs%2Froundandswap.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfrasenselabs%2Froundandswap.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrasenselabs%2Froundandswap.jl/lists"}