移动边缘计算的任务卸载与资源调度是指在移动设备和边缘服务器之间,将部分计算任务从移动设备卸载到边缘服务器,并合理分配资源以提高系统性能和降低能耗。
在本文所研究的区块链网络中,优化的变量为:挖矿决策(即 m)和资源分配(即 p 和 f),目标函数是使所有矿工的总利润最大化。问题可以表述为:
max m , p , f F miner = ∑ i ∈ N ′ F i miner s.t. C 1 : m i ∈ { 0 , 1 } , ∀ i ∈ N C 2 : p min ≤ p i ≤ p max , ∀ i ∈ N ′ C 3 : f min ≤ f i ≤ f max , ∀ i ∈ N ′ C 4 : ∑ i ∈ N ′ f i ≤ f total C 5 : F M S P ≥ 0 C 6 : T i t + T i m + T i o ≤ T i max , ∀ i ∈ N ′ \begin{aligned} \max _{\mathbf{m}, \mathbf{p}, \mathbf{f}} & F^{\text {miner }}=\sum_{i \in \mathcal{N}^{\prime}} F_{i}^{\text {miner }} \\ \text { s.t. } & C 1: m_{i} \in\{0,1\}, \forall i \in \mathcal{N} \\ & C 2: p^{\min } \leq p_{i} \leq p^{\max }, \forall i \in \mathcal{N}^{\prime} \\ & C 3: f^{\min } \leq f_{i} \leq f^{\max }, \forall i \in \mathcal{N}^{\prime} \\ & C 4: \sum_{i \in \mathcal{N}^{\prime}} f_{i} \leq f^{\text {total }} \\ & C 5: F^{M S P} \geq 0 \\ & C 6: T_{i}^{t}+T_{i}^{m}+T_{i}^{o} \leq T_{i}^{\max }, \forall i \in \mathcal{N}^{\prime} \end{aligned} m,p,fmax s.t. Fminer =i∈N′∑Fiminer C1:mi∈{0,1},∀i∈NC2:pmin≤pi≤pmax,∀i∈N′C3:fmin≤fi≤fmax,∀i∈N′C4:i∈N′∑fi≤ftotal C5:FMSP≥0C6:Tit+Tim+Tio≤Timax,∀i∈N′
其中:
C1表示每个矿工可以决定是否参与挖矿;
C2 指定分配给每个参与矿机的最小和最大传输功率;
C3 表示分配给每个参与矿工的最小和最大计算资源;
C4表示分配给参与矿机的总计算资源不能超过MEC服务器的总容量;
C5保证MSP的利润不小于0;
C6 规定卸载、挖掘和传播步骤的总时间不能超过最长时间约束。
在所研究的区块链网络中,我们假设 IoTD 是同质的,并且每个 IoTD 都具有相同的传输功率范围和相同的计算资源范围。
上式中:
F i m i n e r = ( w + α D i ) P i m ( 1 − P i o ) − c 1 E i t − c 2 f i , ∀ i ∈ N ′ R i = B log 2 ( 1 + p i H i σ 2 + ∑ j ∈ N ′ \ i m j p j H j ) , ∀ i ∈ N ′ T i t = D i R i , ∀ i ∈ N ′ T i m = D i X i f i , ∀ i ∈ N ′ E i m = k 1 f i 3 T i m , ∀ i ∈ N ′ P i m = k 2 T i m , ∀ i ∈ N ′ F M S P = ∑ i ∈ N ′ ( c 2 f i − c 3 E i m ) − c 3 E 0 P i o = 1 − e − λ ( T i o + T i s ) = 1 − e − λ ( z D i + T i t ) , ∀ i ∈ N ′ F_i^{miner}=(w+\alpha D_i)P_i^m(1-P_i^o)-c_1E_i^t-c_2f_i,\forall i\in\mathcal{N'}\\R_{i}=B \log _{2}\left(1+\frac{p_{i} H_{i}}{\sigma^{2}+\sum_{j \in \mathcal{N}^{\prime} \backslash i} m_{j} p_{j} H_{j}}\right), \forall i \in \mathcal{N}^{\prime}\\T_{i}^{t}=\frac{D_{i}}{R_{i}},\forall i\in\mathcal{N}^{\prime}\\T_{i}^{m}=\frac{D_{i}X_{i}}{f_{i}},\forall i\in\mathcal{N}'\\E_i^m=k_1f_i^3T_i^m,\forall i\in\mathcal{N}'\\P_i^m=\frac{k_2}{T_i^m},\forall i\in\mathcal{N}^{\prime}\\F^{MSP}=\sum_{i\in\mathcal{N}^{\prime}}\left(c_2f_i-c_3E_i^m\right)-c_3E_0\\\begin{aligned} P_{i}^{o}& =1-e^{-\lambda(T_{i}^{o}+T_{i}^{s})} \\ &=1-e^{-\lambda(zD_{i}+T_{i}^{t})},\forall i\in\mathcal{N}^{\prime} \end{aligned} Fiminer=(w+αDi)Pim(1−Pio)−c1Eit−c2fi,∀i∈N′Ri=Blog2(1+σ2+∑j∈N′\imjpjHjpiHi),∀i∈N′Tit=RiDi,∀i∈N′Tim=fiDiXi,∀i∈N′Eim=k1fi3Tim,∀i∈N′Pim=Timk2,∀i∈N′FMSP=i∈N′∑(c2fi−c3Eim)−c3E0Pio=1−e−λ(Tio+Tis)=1−e−λ(zDi+Tit),∀i∈N′
差分进化算法(Differential Evolution Algorithm,DE)是一种全局优化算法,它基于群体的启发式搜索。每个个体对应一个解向量,DE的进化流程包括变异、杂交和选择操作。与遗传算法相比,差分进化算法的操作定义有所不同,但整体思想相似。
差分进化算法的描述如下:
差分进化算法相对于遗传算法的优势在于简单易实现,但也有很多变种和改进方法,可以根据具体情况选择适合的算法。
close all
clear
clc
dbstop if all error
t=1;
for NP=50:50:300
para = parametersetting(NP);
para.MaxFEs =6000;%最大迭代次数
Result(t)=Compute(NP,para);
t=t+1;
end
QQ=50:50:300;
LenG={};
StrCor={'r-','g--','b-','c-','m--','k-.','y-'};
figure
for i=1:t-1
plot(Result(i).FitCurve,StrCor{i},'linewidth',3)
hold on
LenG{i}=['N=' num2str(QQ(i))];
Data(i)=Result(i).FitCurve(end);
end
legend(LenG)
xlabel('FEs')
ylabel('Token')
figure
bar(Data)
hold on
plot(Data,'r-o','linewidth',3)
set(gca,'xtick',1:1:t-1);
set(gca,'XTickLabel',LenG)
ylabel('Token')
当矿工数量为50 100 150 200 250 300 350时:所有矿工的利润随迭代次数的变化如下图所示
1.70961903063870 0.915057108482030
1.97884581710515 0.136309993850076
1.82063040644361 0.475380964903532
1.43793030306619 0.714888695101324
1.82063040644361 0.900636150747992
1.61403687280477 0.230326490177402
1.44882104170844 0.475380964903532
1.92948288208559 0.679024405084065
1.97217203090381 0.475380964903532
1.89759336207038 0.230000959720043
1.84465608318310 0.577481991007684
1.88386265861916 0.403219304807995
1.98275518824349 0.184344657691976
1.88386265861916 0.690069920918526
1.99454958480856 0.714888695101324
1.64205969743127 0.154575948291039
1.92820145682232 0.738160805429999
1.97531511718751 0.486581365313851
1.89124702129147 0.998483429338209
1.85753262962595 0.784929891371303
0.206794357912299 0.475380964903532
1.98519754174442 0.625966057957844
1.95031384568391 0.890794551305381
1.63613228590527 0.757641108127655
1.58453437629969 0.572035284258508
1.95992990908977 0.588978363106915
1.99454958480856 0.157923330009538
1.87752509446173 0.861874778071472
1.73388961758303 0.0182505268364460
1.97884581710515 0.679546185110974
1.72577419634882 0.733875154051102
1.92979930893703 0.845620688312287
1.81981689329417 0.475380964903532
1.85753262962595 0.358725775264239
1.98275518824349 0.820915129741387
1.88386265861916 0.890794551305381
1.96549917117933 0.403219304807995
1.64287348500743 0.960178855853379
1.66476223036004 0.836742870036493
1.82259751216598 0.588978363106915
1.65625788695821 0.0534368180687056
1.99019691658474 0.0783551639914413
1.96083706050509 0.676355368865015
1.94280042487603 0.0425319119217820
1.92820145682232 0.958717191748582
1.92948288208559 0.739401704264659
1.97181148757610 0.619487787865644
1.83599108308744 0.921117032842475
0.796709687090485 0.626280644353691
1.95852658388316 0.0203334852718414