THINK FIRST·CODE LATER

← All labs

The offloading decision: local, edge or cloud?

Problem

Input: C D fLocal Pcompute Ptx alpha (C in gigacycles, D in KB with 1 KB = 1,000 bytes, fLocal in GHz, powers in W, alpha ∈ [0, 1]), then two lines name fServer bandwidthMHz snrDb rttMs (edge, then cloud).

Compute the uplink rate R = B log₂(1 + 10^(snr/10)); for each server print edge: uplink 69.2 Mb/s, upload 23.1 ms, compute 10.0 ms, RTT 5.0 ms. Then for local, edge, cloud print %-6s time X ms, energy Y mJ, cost Z (times and energies with 1 decimal, cost with 3), where the phone's remote energy is Ptx × upload time and cost = alpha × time/time_local + (1 − alpha) × energy/energy_local. Then Fastest: …, least energy: …, best weighted (alpha 0.5): … (first one on ties, in the order local, edge, cloud) and for each server Break-even uplink for edge: 18.8 Mb/s or … never faster than local. Numbers are printed as integers when whole, else with 1 decimal.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.