一、优化模型简介
在所研究的区块链网络中,优化的变量为:挖矿决策(即 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′
二、差分进化算法求解
2.1部分代码
close all
clear
clc
dbstop if all error
NP = 100;%矿工数量
para = parametersetting(NP);
para.MaxFEs =5000;%最大迭代次数
Result=Compute(NP,para);
figure(1)
plot(Result.FitCurve,'r-','linewidth',2)
xlabel('FEs')
ylabel('Token')
figure(2)
plot(Result.ConCurve,'g-','linewidth',2)
xlabel('FEs')
ylabel('Con')
2.2部分结果
当矿工数量为100时:所有矿工的利润随迭代次数的变化如下图所示
文章来源:https://www.toymoban.com/news/detail-823188.html
算法得到的资源分配:文章来源地址https://www.toymoban.com/news/detail-823188.html
1.96811552438660 0.953006101348509
1.96466685390698 0.271902260303373
1.98787052377883 0.474153524868700
1.96819942207163 0.346379035947841
1.99091543574949 0.200876712644815
1.75343624634699 0.334356132462864
1.98500749778468 0.307444848291752
1.84892091516342 0.298750104087243
1.97627537784477 0.136707719799701
1.98247708944478 0.825715938835666
1.82415247169822 0.592341764056851
1.95255969969755 0.266870044692269
1.55784064472313 0.198677986588129
1.99905703081220 0.864360471110543
1.99966672978573 0.208510255774389
1.99688659497769 0.0918824246788308
1.98550616407992 0.338463477789463
1.93993936287256 0.125644327388094
1.99699497232442 0.647475988987162
1.96398401982365 0.465688977142535
1.99091543574949 0.743184799966985
1.96990281764298 0.714108040841893
1.97038900311126 0.589313007134188
1.99476384052921 0.165976864334375
1.88837922907041 0.407249404947350
1.90123564522443 0.0259150669487571
1.96990281764298 0.865499536534992
1.98251610689349 0.423166248324710
1.79062121977309 0.134536527173266
1.86555117077209 0.433716644319901
1.99699497232442 0.527866317534775
1.99476384052921 0.688760982663683
1.97674256927618 0.287210638597892
1.76141326412447 0.433716644319901
1.98550616407992 0.494479004505169
1.93568365938428 0.210270205638780
1.76141326412447 0.134536527173266
1.99318790325672 0.463178386123276
1.95682912764954 0.873704345638409
1.96819942207163 0.684964734475016
1.98247708944478 0.461790633870382
1.97627537784477 0.787640320359472
1.96819942207163 0.465688977142535
1.81951497310007 0.709782769737031
1.91717991800798 0.307444848291752
1.64596073389228 0.239159634095697
1.99826774684560 0.402723342616452
1.97330988977545 0.420841090504728
1.99688659497769 0.367195541000771
1.97889615328010 0.843193159989458
1.99699497232442 0.523768689297030
1.92148215776128 0.663367007870150
1.97511494395285 0.770648130067366
1.96819942207163 0.327375030890668
1.90398161302827 0.839744341831028
1.89043943861968 0.289783983459719
1.99699497232442 0.533319780807194
1.95116437441300 0.700957227852864
1.99121369063535 0.754607214742589
1.87983995904930 0.609769452627303
1.84892091516342 0.539298593105581
1.99977128699058 0.788773855758191
1.98739282034646 0.469029773060142
1.99977128699058 0.738806842279465
1.99318790325672 0.861732699602560
1.89528705623385 0.751248427333978
1.99318790325672 0.606673004912089
1.88837922907041 0.0950878414681128
1.95986020059497 0.420841090504728
1.99620036364745 0.367759263664120
1.84149233878646 0.0312600209994546
1.97052417907742 0.614595104101977
1.95930654638147 0.252309411754703
1.99767004536831 0.471008106969735
1.99476384052921 0.121831563328420
1.91023269675185 0.891251163847819
1.99826774684560 0.697077892570419
1.94737447735811 0.223823307777294
1.96466685390698 0.530942973106581
1.98251610689349 0.709782769737031
1.80244505169201 0.903799290199773
1.97330988977545 0.511557550448898
1.99897629369323 0.401063559063827
1.99476384052921 0.669326947551257
1.99476384052921 0.209953433257302
1.99476384052921 0.473000128326441
1.96819942207163 0.884127095870242
1.99699497232442 0.974541259533987
1.99584133362082 0.525442981913958
1.96575023838394 0.0623933694916289
1.93792710962256 0.855551087118804
1.99740286694205 0.735027403529296
1.98550616407992 0.314664453608669
1.99620036364745 0.506153103638960
1.96811552438660 0.0309570286681788
1.97798566131583 0.189970375715465
1.98526170939456 0.118404965890552
1.99740286694205 0.879091954485326
1.99476384052921 0.983286613303637
1.65047014229422 0.0102537270833978
三、完整MATLAB代码
到了这里,关于基于差分进化算法的移动边缘计算 (MEC) 的资源调度分配优化(提供MATLAB代码)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!