Skip to content

About

The package DRO aims to provide a collection of distributed optimization algorithms optimizing resources (e.g. energy resources, robotic resources...). The algorithms are implemented without considering one special communication technique or package.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

distributed-resource-optimization logo

Tests Coverage lifecycle MIT License PyPI

Distributed Resource Optimization

A Python package providing distributed optimization algorithms for coordinating flexible resources. Algorithms are implemented independently of any particular communication backend — a pluggable carrier abstraction lets you run the same algorithm code in a single asyncio process or across a real network via mango-agents.

Ten algorithms are available:

Algorithm Problem type Coordination
ADMM Sharing Continuous resource allocation, sum-to-target Coordinator required
ADMM Exchange Continuous exchange, sum to zero (or ≥ 0 with a free surplus) Coordinator required
ADMM Consensus Agents converge to a shared target vector Coordinator required
COHDA Combinatorial schedule selection, weighted L1 target Fully distributed
Consensus + innovations Agree on a shared vector λ; local mismatches sum to zero Coordinator starts and stops
DEED-ADMM Σ (x_i − y_i) = 0 with local boxes; peers exchange (λ, ξ) (Zhu et al. 2025) Coordinator starts and stops
Diffusion Σ_j w[j] = target, own cost per entry; the target is learnt by information sharing (de Azevedo et al. 2017) Fully distributed (coordinator only starts)
Exact diffusion min Σ_k J_k(w) over a common w; adapt-correct-combine reaches the exact minimiser (Yuan et al. 2019) Coordinator starts and ends at max_iter
FDGDM min Σ_i F_i(x_i), Σ_i x_i fixed at the start, local sets; gradients swapped with degree/curvature weights (Bai et al. 2022) Coordinator splits the start, collects stop flags
DPD-TV min Σ_i f_i(x_i), Σ_i g_i(x_i) ≤ 0, local sets; allocations y_i moved by neighbours' multipliers (Camisa et al. 2021) Coordinator starts; runs to max_iter

Two carriers are included:

Carrier When to use
SimpleCarrier In-process asyncio simulation — zero overhead, ideal for prototyping and testing
MangoCarrier Networked multi-agent deployments via mango-agents (≥ 2.4.0); routes (next_hops) relay messages hop by hop on sparse topologies, replies route back; across several real containers give the coordinator addresses={aid: AgentAddress} and the containers codec=json_codec() (numpy + DRO messages; fixes mango 2.4's AgentAddress JSON round trip)

Note: the package is still experimental. API may change between minor versions.


Scope of this package

This package is one of three with separate responsibilities:

  • mango-energy-environments — simulation and representation of energy networks for mango, in two modes: physical (runs on the real frameworks — pandapower, monee — incl. their physical calculations) and copper-plate (physics skipped; lines only decide which agents are connected, energy moves freely between any actors; used by the benchmark). Networks, components, time series, observe/act, binding agents to network elements (one component or a whole bus), network sources (e.g. PyPSA) converted into backend networks, generic preparation steps. Existing functionality (monee restoration, pandapower scheduling) is kept. No distributed-algorithm or benchmark logic.
  • distributed-resource-optimization — only the logic of the distributed algorithms, as generic as possible (usable for non-energy problems too) and built on mango as far as possible, including the generic mango carrier/role. No PyPSA, network or benchmark logic.
  • energy-scheduling-benchmark — builds the benchmark from the other two: the economic-dispatch problem formulation, storage model, central-dispatch optimum, benchmark roles (leader, bus agents), concrete datasets, runs and comparisons.

Dependencies point one way only: energy-scheduling-benchmark → the other two; mango-energy-environments and distributed-resource-optimization never import each other.

Installation

pip install distributed-resource-optimization

For networked deployments with mango-agents:

pip install "distributed-resource-optimization[mango]"

For development:

git clone https://github.com/Digitalized-Energy-Systems/distributed-resource-optimization
cd distributed-resource-optimization
pip install -e ".[dev,docs]"

Quick Start

ADMM Sharing — flexible resource coordination

Three resources must collectively match a power target. The sharing ADMM distributes the load optimally:

import asyncio
from distributed_resource_optimization import (
    create_admm_flex_actor_one_to_many,
    create_sharing_target_distance_admm_coordinator,
    create_admm_sharing_data,
    create_admm_start,
    start_coordinated_optimization,
)


async def main():
    # Three resources: 10 kW, 15 kW, 10 kW input capacities
    # Efficiency vectors map input to three output types
    flex1 = create_admm_flex_actor_one_to_many(10, [0.1, 0.5, -1.0])
    flex2 = create_admm_flex_actor_one_to_many(15, [0.1, 0.5, -1.0])
    flex3 = create_admm_flex_actor_one_to_many(10, [-1.0, 0.0, 1.0])

    # Target combined output [-4, 0, 6] with first sector weighted x5
    coordinator = create_sharing_target_distance_admm_coordinator()
    start = create_admm_start(create_admm_sharing_data([-4, 0, 6], [5, 1, 1]))

    await start_coordinated_optimization([flex1, flex2, flex3], coordinator, start)

    print(flex1.x)  # optimal output for resource 1
    print(flex2.x)  # optimal output for resource 2
    print(flex3.x)  # optimal output for resource 3


asyncio.run(main())

COHDA — combinatorial schedule coordination

Each participant selects exactly one schedule from a discrete set; COHDA minimises the L1 distance of the aggregate to a target:

import asyncio
from distributed_resource_optimization import (
    create_cohda_participant,
    create_cohda_start_message,
    start_distributed_optimization,
)


async def main():
    actor1 = create_cohda_participant(1, [[0.0, 1, 2], [1, 2, 3]])
    actor2 = create_cohda_participant(2, [[0.0, 1, 2], [1, 2, 3]])

    start = create_cohda_start_message([1.2, 2.0, 3.0])
    await start_distributed_optimization([actor1, actor2], start)

    print(actor1.memory.solution_candidate.schedules.sum(axis=0))


asyncio.run(main())

Using SimpleCarrier directly

For full control over message flow, create the container and carriers yourself:

import asyncio
from distributed_resource_optimization import (
    ActorContainer,
    SimpleCarrier,
    cid,
    create_cohda_participant,
    create_cohda_start_message,
)


async def main():
    container = ActorContainer()
    c1 = SimpleCarrier(container, create_cohda_participant(1, [[0.0, 1, 2], [1, 2, 3]]))
    c2 = SimpleCarrier(container, create_cohda_participant(2, [[0.0, 1, 2], [1, 2, 3]]))

    start = create_cohda_start_message([1.2, 2.0, 3.0])
    c1.send_to_other(start, cid(c2))
    await container.done_event.wait()


asyncio.run(main())

Documentation

Full documentation including algorithm background, tutorials, and API reference is available at:

https://digitalized-energy-systems.github.io/distributed-resource-optimization/

(not online as of 2026-11-08 — build it locally: pip install -r docs/requirements.txt, then make -C docs html → docs/build/html/index.html.)


Contributing

Contributions are welcome. Please open an issue or pull request on GitHub.


License

MIT

About

The package DRO aims to provide a collection of distributed optimization algorithms optimizing resources (e.g. energy resources, robotic resources...). The algorithms are implemented without considering one special communication technique or package.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages