{"id":32154514,"url":"https://github.com/nrel/mincostflows.jl","last_synced_at":"2025-10-21T11:57:21.873Z","repository":{"id":137346821,"uuid":"166308518","full_name":"NREL/MinCostFlows.jl","owner":"NREL","description":"Fast min-cost flow solver for network optimization in PRAS","archived":false,"fork":false,"pushed_at":"2024-12-02T22:07:44.000Z","size":62,"stargazers_count":1,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-21T11:57:09.203Z","etag":null,"topics":[],"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/NREL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-01-17T22:50:56.000Z","updated_at":"2024-12-03T00:49:24.000Z","dependencies_parsed_at":"2023-03-14T13:15:12.385Z","dependency_job_id":null,"html_url":"https://github.com/NREL/MinCostFlows.jl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NREL/MinCostFlows.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NREL%2FMinCostFlows.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NREL%2FMinCostFlows.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NREL%2FMinCostFlows.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NREL%2FMinCostFlows.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NREL","download_url":"https://codeload.github.com/NREL/MinCostFlows.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NREL%2FMinCostFlows.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280256227,"owners_count":26299342,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-10-21T11:57:20.719Z","updated_at":"2025-10-21T11:57:21.864Z","avatar_url":"https://github.com/NREL.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MinCostFlows\n\n[![Tests](https://github.com/NREL/MinCostFlows.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/NREL/MinCostFlows.jl/actions/workflows/CI.yml)\n[![Coverage](https://codecov.io/gh/NREL/MinCostFlows.jl/graph/badge.svg?token=QhINmAOLgW)](https://codecov.io/gh/NREL/MinCostFlows.jl)\n\nEfficiently solves min-cost network flow problems using the Relaxation\ndual ascent method of Bertsekas (1985), including support for parameter\nupdates and warm-started re-solves.\n\nMin cost flow problems involve networks with flow injections at nodes,\nand flow costs and limits on edges. A min cost flow solver identifies a\nleast-cost set of flows that satisfy both the edge flow constaints and\nflow balance constraints at every node.\n\nIn this implementation, all edges have an implicit minimum flow of zero,\nhowever edges can be defined in both directions between nodes. All\nparameters must be integers.\n\n# Usage\n\nConsider the following min-cost flow problem, with three nodes and four\nedges:\n\n[![Example network](example.svg)](example.svg)\n\nThe network can be encoded as a min cost flow problem as follows:\n\n```julia\nusing MinCostFlows\n\n# Node properties\ninjection = [5, 4, -9]\n\n# Edge properties\nnodefrom = [1, 2, 3, 1]\nnodeto = [2, 3, 1, 3]\nlimit = [4, 6, 3, 5]\ncost = [1, 1, 2, 3]\n\nfp = FlowProblem(nodefrom, nodeto, limit, cost, injection)\n```\n\nWith the problem defined, it can be solved and the solution obtained with:\n\n```julia\nsolveflows!(fp)\nsolution = flows(fp) # [2, 6, 0, 3]\n```\n\nIn this case, all of node 2's 4-unit injection flows to node 3 via edge 2.\nAs much of node 1's injection as possible (two units) flows through edges\n1 and 2 (at a cost of 1+1=2 per unit), until edge 2's capacity is reached.\nThe remaining three units flow from node 1 through edge 3 at a cost of 3\nper unit.\n\nThe network parameters (injections, costs, and limits) can also be changed\nin-place and the problem re-solved using the previous solution as a\nstarting point. Depending on the size and nature of the network, this can\nbe substantially faster than solving the problem from scratch.\n\n```julia\n# Set node 2 injection to zero, automatically adjusting withdrawal at\n# node 3 to maintain flow feasibility\nupdateinjection!(fp.nodes[2], fp.nodes[3], 0)\nsolveflows!(fp)\nflows(fp) # [4, 4, 0, 1]\n\n# Reduce the cost of flows on edge 4, and increase its capacity\nupdateflowcost!(fp.edges[4], 1)\nupdateflowlimit!(fp.edges[4], 5)\nsolveflows!(fp)\nflows(fp) # [0, 0, 0, 5]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrel%2Fmincostflows.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnrel%2Fmincostflows.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrel%2Fmincostflows.jl/lists"}