{"id":19301258,"url":"https://github.com/fuglede/numberpartitioning-cs","last_synced_at":"2026-03-03T09:32:07.579Z","repository":{"id":90007492,"uuid":"395112651","full_name":"fuglede/numberpartitioning-cs","owner":"fuglede","description":"Some C#-only solvers for the multi-way partition problem","archived":false,"fork":false,"pushed_at":"2024-07-07T11:42:39.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-28T00:54:46.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fuglede.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":"2021-08-11T20:46:24.000Z","updated_at":"2025-02-09T20:45:51.000Z","dependencies_parsed_at":"2025-02-28T23:47:10.730Z","dependency_job_id":"e61fe32b-233d-4a4c-abd5-81a88644ff45","html_url":"https://github.com/fuglede/numberpartitioning-cs","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fuglede/numberpartitioning-cs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fnumberpartitioning-cs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fnumberpartitioning-cs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fnumberpartitioning-cs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fnumberpartitioning-cs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuglede","download_url":"https://codeload.github.com/fuglede/numberpartitioning-cs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fnumberpartitioning-cs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30039884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T06:58:30.252Z","status":"ssl_error","status_checked_at":"2026-03-03T06:58:15.329Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-09T23:17:22.716Z","updated_at":"2026-03-03T09:32:07.552Z","avatar_url":"https://github.com/fuglede.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Partition problem solvers in .NET\n\nThis repository includes some pure C# solvers for the [multiway number partitioning optimization problem](https://en.wikipedia.org/wiki/Multiway_number_partitioning); in particular, the standard [greedy algorithm](https://en.wikipedia.org/wiki/Greedy_number_partitioning), and the [Karmarkar--Karp algorithm](https://en.wikipedia.org/wiki/Largest_differencing_method).\n\n## The problem\n\nConcretely, the problem we solve is the following: Suppose *S* is some collection of integers, and *k* is some positive integer, find a partition of *S* into *k* parts so that the sums of the integers in each part are as close as possible.\n\nThe objective function describing \"closeness\" is usually taken to be the difference between the largest and smallest sum among all parts. The optimization version is NP-hard, and the bundled algorithms only aim to provide a good solution in short time. This also means that they can be useful for other objective functions such as, say, the variance of all sums.\n\n## Installation\n\nThe package is available from the public [NuGet Gallery](https://www.nuget.org/packages/NumberPartitioning/).\n\n## Example\n\nSuppose we want to split the collect `[4, 6, 7, 5, 8]` into three parts. We can achieve that as follows:\n\n```cs\nvar numbers = new[] { 4, 6, 7, 5, 8 };\nvar (partition, sizes) = KarmarkarKarp.Heuristic(numbers, 3);\n```\n\nHere, `partition` becomes `[[4], [0, 3], [1, 2]]`, the indices corresponding to the elements `[[8], [4, 7], [5, 6]]`, and `sizes` are the sums of the elements in each part, `[8, 11, 11]`. This happens to be optimal.\n\nAs noted [on Wikipedia](https://en.wikipedia.org/wiki/Largest_differencing_method), an example where this approach does not give the optimal result is the following:\n\n```cs\nvar numbers = new[] { 5, 5, 5, 4, 4, 3, 3, 1 };\nvar (partition, sizes) = KarmarkarKarp.Heuristic(numbers, 3);\n```\n\nHere, `sizes` is `[9, 10, 11]` but it is possible to achieve a solution in which the sums of each part is 10.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuglede%2Fnumberpartitioning-cs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuglede%2Fnumberpartitioning-cs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuglede%2Fnumberpartitioning-cs/lists"}