Skip to main content

Energy-efficient and latency-aware device selection for Blockchain-Enabled Federated Learning.

Project description

bcfl-optimizer

Energy-efficient and latency-aware device selection for Blockchain-Enabled Federated Learning.

A Python library implementing the joint optimization algorithm from:

D. Kushwaha, S. Redhu, C. G. Brinton, and R. M. Hegde,
"Energy-Efficient and Latency-Aware Blockchain-Enabled Federated Learning for Edge Networks,"
IEEE TCAS-II, Vol. 71, No. 3, March 2024.


Installation

pip install -e .

Dependencies: numpy (required), pandas (for CSV loading), matplotlib (for plotting examples).

Quick Start

from bcfl import DevicePool, MinerPool, optimize

# Create pools (from arrays, CSV, JSON, or random)
devices = DevicePool.random(n=50)
miners  = MinerPool.random(m=15)

# Select optimal 30 devices + miners (balanced latency-energy trade-off)
result = optimize(devices, miners, s_d=30, beta=0.5)

print(result)
# OptimizationResult(
#   devices=30, miners=2,
#   latency=3.2145s, energy=12.4532J,
#   fitness=0.012345, a_fork=1.2214, beta=0.5
# )

Loading Real Device Data

# From CSV
devices = DevicePool.from_csv("my_devices.csv")
# Expected columns: cpu_freq, tx_power, data_size

# From JSON
devices = DevicePool.from_json("my_devices.json")

# From NumPy arrays
devices = DevicePool(
    cpu_freq=[1.8e9, 1.2e9, ...],
    tx_power=[0.3, 0.15, ...],
    data_size=[87, 112, ...]
)

API Reference

DevicePool(cpu_freq, tx_power, data_size, ...)

Heterogeneous edge device pool. Methods:

  • .computation_cost(epochs, kappa) → latency, energy per device (Eq. 1-2)
  • .upload_cost(model_size, bandwidth, noise_power) → latency, energy (Eq. 3)
  • .total_cost(...) → combined per-device costs

MinerPool(proc_freq, ver_power)

Miner pool. Methods:

  • .verification_cost(model_size) → latency, energy per miner (Eq. 4)

optimize(device_pool, miner_pool, s_d, beta=0.5, ...)

Run Algorithm 1 to find optimal device-miner selection.
Returns OptimizationResult with selected indices, latency, energy, fitness.

sweep(device_pool, miner_pool, beta=0.5, s_d_range=None, ...)

Run optimization across multiple S_D values for parameter studies.

forking_probability(num_miners, ...) / forking_multiplier(...)

Blockchain forking model (Eq. 10).

Examples

python examples/quickstart.py           # Minimal usage
python examples/paper_reproduction.py   # Reproduce Fig. 3 trade-off curves

Citation

If you use this library in your research, please cite:

@article{kushwaha2024energy,
  title   = {Energy-Efficient and Latency-Aware Blockchain-Enabled Federated Learning for Edge Networks},
  author  = {Kushwaha, Deepali and Redhu, Surender and Brinton, Christopher G. and Hegde, Rajesh M.},
  journal = {IEEE Transactions on Circuits and Systems II: Express Briefs},
  volume  = {71},
  number  = {3},
  pages   = {1126--1130},
  year    = {2024}
}

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bcfl_optimizer-0.1.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bcfl_optimizer-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file bcfl_optimizer-0.1.0.tar.gz.

File metadata

  • Download URL: bcfl_optimizer-0.1.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bcfl_optimizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c75c6d4189c0e78ce0938ff9d39449d4641bdff204ea7684945ca80f9e25caa1
MD5 40b6d6ad813c3cdb7ba6961ad8748f03
BLAKE2b-256 9b91e02e9137e442a33df7bc3b53a8e592ed81ac5319c77d6b1c23dcbe80ad2a

See more details on using hashes here.

File details

Details for the file bcfl_optimizer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bcfl_optimizer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bcfl_optimizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6378fc57c42e1286e1f5d177e8d56b893d6d23a7fc86f9a08dfac60d699bd5ae
MD5 88d36207b7945ec87bee4f5798526df0
BLAKE2b-256 b5a824a8f1ecfb3d8df2e50d7c1ee170ad41581860d250a4f90fd043e52caf91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page