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, M. Kalavadia, V. Hegde and O. J. Pandey,
"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, D. and Kalavadia, M. and Hegde, V. and Pandey, O. J.},
  journal = {IEEE Transactions on Circuits and Systems II: Express Briefs},
  volume  = {71},
  number  = {3},
  pages   = {1126--1130},
  year    = {2024},
  doi     = {10.1109/TCSII.2023.3322340}
}

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.1.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.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bcfl_optimizer-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2ac3390d5ba2faeafa434ca6b227a218e1343eade3d3862b62daf621bd08eb53
MD5 4a527d91dac986d861e6c804608f6777
BLAKE2b-256 0bde440cc8c991311a76e83ebc03ca1fa9948827d435d8aaaeb7cbd38e446342

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bcfl_optimizer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d097e9209ffa0626a664c9e22dd39bf3c17544fb3a720c920b9e0433475620
MD5 8fba3eb8902818e99812e6305d698d8c
BLAKE2b-256 98186781bfa666fccbe0a180cc94f94f5aee5d57854ff11cedb6fa5b0e6be552

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