DP优化 - 四边形不等式优化

news/2024/11/24 4:27:17/

若对于 i≤i′≤j≤j′i\leq i'\leq j \leq j'iijj,二维数组 aaa 满足如下性质:

ai,j+ai′,j′≤ai,j′+ai′,ja_{i,j} + a_{i',j'} \leq a_{i,j'} + a_{i', j}ai,j+ai,jai,j+ai,j

则称数组 aaa 满足四边形不等式。

若对于 i≤i′≤j≤j′i\leq i'\leq j \leq j'iijj,二维数组 aaa 满足如下性质:

ai′,j≤ai,j′a_{i',j} \leq a_{i,j'}ai,jai,j

则称数组 aaa 满足关于区间包含的单调性。

动态规划中有一种常见的转移方程(一般见于区间 DP):

fi,j={min⁡i≤k<j{x∣x=wi,j+fi,k+fk+1,j}i<j0i=j∞i>jf_{i,j}=\begin{cases} \min\limits_{i\leq k< j}\{x|x=w_{i,j}+f_{i,k}+f_{k+1,j}\}&i<j\\ 0&i=j\\ \infty&i>j\end{cases}fi,j=ik<jmin{xx=wi,j+fi,k+fk+1,j}0i<ji=ji>j

如果这时 wi,jw_{i,j}wi,j 同时满足四边形不等式和区间包含单调性,则可以使用四边形不等式优化。

推导过程:

首先可以证明二维数组 fff 也满足四边形不等式,即

fi,j+fi′,j′≤fi,j′+fi′,jf_{i,j} + f_{i',j'} \leq f_{i,j'} + f_{i', j}fi,j+fi,jfi,j+fi,j

分类讨论:

① 若 i=i′≤j≤j′i = i'\leq j \leq j'i=ijj
fi,j+fi′,j′=fi′,j+fi,j′\begin{aligned} f_{i,j} + f_{i',j'} &= f_{i',j} + f_{i,j'}\end{aligned}fi,j+fi,j=fi,j+fi,j

② 若 i<i′≤j=j′i < i'\leq j = j'i<ij=j
fi,j+fi′,j′=fi,j′+fi′,j\begin{aligned} f_{i,j} + f_{i',j'} &= f_{i,j'} + f_{i',j}\end{aligned}fi,j+fi,j=fi,j+fi,j

③ 若 i<i′=j<j′i < i' =j < j'i<i=j<j

原不等式则转换为:
fi,j+fj,j′≤fi,j′+fj,j\begin{aligned} f_{i,j} + f_{j,j'} &\leq f_{i,j'} + f_{j, j} \end{aligned}fi,j+fj,jfi,j+fj,j

fj,j=0f_{j,j} =0fj,j=0,又转化为:
fi,j+fj,j′≤fi,j′\begin{aligned} f_{i,j} + f_{j,j'} &\leq f_{i,j'} \end{aligned}fi,j+fj,jfi,j

对于所有 iii,都有:
fi,i+1+fi+1,i+2=wi,i+1+wi+1,i+2+fi,i+fi+1,i+1+fi+1,i+1+fi+2,i+2=wi,i+1+wi+1,i+2≤wi,i+2≤fi,i+2\begin{aligned} f_{i,i+1} + f_{i+1,i+2} &= w_{i,i+1} + w_{i+1,i+2} + f_{i,i} + f_{i+1,i+1} + f_{i+1,i+1} + f_{i+2,i+2}\\&= w_{i,i+1} + w_{i+1,i+2}\\&\leq w_{i,i+2}\\&\leq f_{i, i+2}\end{aligned}fi,i+1+fi+1,i+2=wi,i+1+wi+1,i+2+fi,i+fi+1,i+1+fi+1,i+1+fi+2,i+2=wi,i+1+wi+1,i+2wi,i+2fi,i+2

k=max⁡i≤x≤j{x∣fi,j=wi,j+fi,x+fx+1,j}k=\max\limits_{i\leq x\leq j}\{x|f_{i,j} = w_{i,j} + f_{i,x} + f_{x+1,j}\}k=ixjmax{xfi,j=wi,j+fi,x+fx+1,j}

此时,若 k≤i′=jk\leq i' = jki=j

假设 fk+1,j+fi′j′≤fk+1,j′f_{k+1,j} + f_{i'j'} \leq f_{k+1,j'}fk+1,j+fijfk+1,j 成立,则有

fi,j+fj,j′≤wi,j+fi,k+fk+1,j+fj,j′≤wi,j′+fi,k+fk+1,j+fj,j′≤wi,j+fi,k+fk+1,j′≤fi,j′\begin{aligned} f_{i,j} + f_{j,j'} &\leq w_{i,j} + f_{i,k} + f_{k+1,j} + f_{j,j'}\\&\leq w_{i,j'} + f_{i,k} + f_{k+1,j} + f_{j,j'}\\ &\leq w_{i,j}+f_{i,k}+f_{k+1,j'}\\&\leq f_{i,j'}\end{aligned}fi,j+fj,jwi,j+fi,k+fk+1,j+fj,jwi,j+fi,k+fk+1,j+fj,jwi,j+fi,k+fk+1,jfi,j

k>i′=jk > i' = jk>i=j

假设 fk+1,j+fi′j′≤fk+1,j′f_{k+1,j} + f_{i'j'} \leq f_{k+1,j'}fk+1,j+fijfk+1,j 成立,则有

fi,j+fj,j′≤fi,j+wj,j′+fj,k+fk+1,j′≤wi,j′+fi,j+fi′,k+fk+1,j′≤wi,j+fi,k+fk+1,j′≤fi,j′\begin{aligned} f_{i,j} + f_{j,j'} &\leq f_{i,j} + w_{j,j'} + f_{j,k} + f_{k+1,j'}\\&\leq w_{i,j'} + f_{i,j} + f_{i',k} + f_{k+1,j'} \\ &\leq w_{i,j}+f_{i,k}+f_{k+1,j'}\\&\leq f_{i,j'}\end{aligned}fi,j+fj,jfi,j+wj,j+fj,k+fk+1,jwi,j+fi,j+fi,k+fk+1,jwi,j+fi,k+fk+1,jfi,j

综述,通过数学归纳法可知:

fi,j+fj,j′≤fi,j′\begin{aligned} f_{i,j} + f_{j,j'} &\leq f_{i,j'} \end{aligned}fi,j+fj,jfi,j

④ 若 i<i′<j<j′i < i' <j < j'i<i<j<j

k1=max⁡i≤x≤j′{x∣fi′,j=wi′,j+fi′,x+fx+1,j}k_1=\max\limits_{i\leq x\leq j'}\{x|f_{i',j} = w_{i',j} + f_{i',x} + f_{x+1,j}\}k1=ixjmax{xfi,j=wi,j+fi,x+fx+1,j}
k2=max⁡i′≤x≤j{x∣fi,j′=wi,j′+fi,x+fx+1,j′}k_2=\max\limits_{i'\leq x\leq j}\{x|f_{i,j'} = w_{i,j'} + f_{i,x} + f_{x+1,j'}\}k2=ixjmax{xfi,j=wi,j+fi,x+fx+1,j}

k1≤k2k_1\leq k_2k1k2,因为 i≤k1≤j′,i′≤k2≤ji \leq k_1 \leq j', i' \leq k_2\leq jik1j,ik2j,所以 i≤k1≤k2≤ji\leq k_1\leq k_2 \leq jik1k2j

所以 i≤k1≤j,i′≤k2≤j′i\leq k_1\leq j, i'\leq k_2 \leq j'ik1j,ik2j

此时,
fi,j+fi′,j′≤wi,j+wi′,j′+fi,k2+fk2+1,j+fi′,k1+fk1+1,j′≤wi,j′+wi′,j+fi,k2+fk2+1,j+fi′,k1+fk1+1,j′≤wi,j′+wi′,j+fi,k2+fi′,k1+fk2+1,j+fk1+1,j′≤wi,j′+wi′,j+fi,k2+fi′,k1+fk1+1,j+fk2+1,j′≤(wi,j′+fi,k2+fk2+1,j′)+(wi′,j+fi′,k1+fk1+1,j)≤fi,j′+fi′,j\begin{aligned} f_{i,j}+f_{i',j'} &\leq w_{i,j} + w_{i',j'} + f_{i,k_2} + f_{k_2+1,j} + f_{i',k_1} + f_{k_1+1,j'}\\ &\leq w_{i,j'} +w_{i',j} + f_{i,k_2} + f_{k_2+1,j} + f_{i',k_1} + f_{k_1 + 1,j'}\\ &\leq w_{i,j'} +w_{i',j} + f_{i,k_2} + f_{i',k_1} + f_{k_2+1,j} + f_{k_1 + 1,j'}\\ &\leq w_{i,j'} +w_{i',j} + f_{i,k_2} + f_{i',k_1} + f_{k_1 + 1,j} + f_{k_2+1,j'}\\ &\leq (w_{i,j'} + f_{i,k_2} + f_{k_2+1,j'}) + (w_{i',j} + f_{i',k_1} + f_{k_1 + 1,j})\\ &\leq f_{i,j'}+f_{i',j} \end{aligned}fi,j+fi,jwi,j+wi,j+fi,k2+fk2+1,j+fi,k1+fk1+1,jwi,j+wi,j+fi,k2+fk2+1,j+fi,k1+fk1+1,jwi,j+wi,j+fi,k2+fi,k1+fk2+1,j+fk1+1,jwi,j+wi,j+fi,k2+fi,k1+fk1+1,j+fk2+1,j(wi,j+fi,k2+fk2+1,j)+(wi,j+fi,k1+fk1+1,j)fi,j+fi,j

k1>k2k_1> k_2k1>k2,因为 i≤k1≤j′,i′≤k2≤ji \leq k_1 \leq j', i' \leq k_2\leq jik1j,ik2j,所以 i′≤k2<k1≤j′i'\leq k_2 < k_1 \leq j'ik2<k1j

所以 i′≤k1≤j′,i≤k2≤ji'\leq k_1\leq j', i\leq k_2 \leq jik1j,ik2j

此时,
fi,j+fi′,j′≤wi,j+wi′,j′+fi,k1+fk1+1,j+fi′,k2+fk2+1,j′≤wi,j′+wi′,j+fi,k1+fk1+1,j+fi′,k2+fk2+1,j′≤wi,j′+wi′,j+fi,k1+fi′,k2+fk1+1,j+fk2+1,j′≤wi,j′+wi′,j+fi,k1+fi′,k2+fk2+1,j+fk1+1,j′≤(wi,j′+fi,k1+fk1+1,j′)+(wi′,j+fi′,k2+fk2+1,j)≤fi,j′+fi′,j\begin{aligned} f_{i,j}+f_{i',j'} &\leq w_{i,j} + w_{i',j'} + f_{i,k_1} + f_{k_1+1,j} + f_{i',k_2} + f_{k_2+1,j'}\\ &\leq w_{i,j'} +w_{i',j} + f_{i,k_1} + f_{k_1+1,j} + f_{i',k_2} + f_{k_2 + 1,j'}\\ &\leq w_{i,j'} +w_{i',j} + f_{i,k_1} + f_{i',k_2} + f_{k_1+1,j} + f_{k_2 + 1,j'}\\ &\leq w_{i,j'} +w_{i',j} + f_{i,k_1} + f_{i',k_2} + f_{k_2 + 1,j} + f_{k_1 + 1,j'}\\ &\leq (w_{i,j'} + f_{i,k_1} + f_{k_1+1,j'}) + (w_{i',j} + f_{i',k_2} + f_{k_2 + 1,j})\\ &\leq f_{i,j'}+f_{i',j} \end{aligned}fi,j+fi,jwi,j+wi,j+fi,k1+fk1+1,j+fi,k2+fk2+1,jwi,j+wi,j+fi,k1+fk1+1,j+fi,k2+fk2+1,jwi,j+wi,j+fi,k1+fi,k2+fk1+1,j+fk2+1,jwi,j+wi,j+fi,k1+fi,k2+fk2+1,j+fk1+1,j(wi,j+fi,k1+fk1+1,j)+(wi,j+fi,k2+fk2+1,j)fi,j+fi,j

综述,由数学归纳法可知,fi,j+fi′,j′≤fi,j′+fi′,jf_{i,j}+f_{i',j'}\leq f_{i,j'} + f_{i',j}fi,j+fi,jfi,j+fi,j

根据 ①②③④,得,当 i≤i′≤j≤j′i\leq i' \leq j \leq j'iijj 时,fi,j+fi′,j′≤fi,j′+fi′,jf_{i,j}+f_{i',j'}\leq f_{i,j'} + f_{i',j}fi,j+fi,jfi,j+fi,j

假设 ki,j=max⁡i≤x≤j{x∣fi,j=wi,j+fi,x+fx+1,j}k_{i,j} = \max\limits_{i\leq x\leq j}\{x|f_{i,j}=w_{i,j}+f_{i,x}+f_{x+1,j}\}ki,j=ixjmax{xfi,j=wi,j+fi,x+fx+1,j}

则可以推出 ki,jk_{i,j}ki,j 单调

ki−1,j≤ki,j≤ki,j+1k_{i-1,j} \leq k_{i,j} \leq k_{i,j+1}ki1,jki,jki,j+1

证明:

i>ji > ji>j

ki−1,j=ki,j=ki,j+1=∞k_{i-1,j} = k_{i, j} = k_{i, j+1} = \inftyki1,j=ki,j=ki,j+1=

i=ji = ji=j

ki,j=0<∞=ki,j+1ki,j=0<∞=ki+1,jk_{i,j} = 0 < \infty = k_{i, j+1}\\k_{i,j}= 0<\infty = k_{i+1,j}ki,j=0<=ki,j+1ki,j=0<=ki+1,j

i<ji < ji<j

我们假设 fi,j,k=wi,j+fi,k+fk+1,jf_{i,j,k} = w_{i,j} + f_{i,k} + f_{k + 1, j}fi,j,k=wi,j+fi,k+fk+1,j

fi,j,ki,j=fi,jf_{i,j,k_{i,j}} = f_{i,j}fi,j,ki,j=fi,j

对于任意 k≤k′<jk\leq k' < jkk<j,有

fk+1,j+fk′+1,j+1≤fk+1,j+1+fk′+1,jf_{k + 1, j} + f_{k' + 1,j+1} \leq f_{k + 1, j+1} + f_{k' + 1, j}fk+1,j+fk+1,j+1fk+1,j+1+fk+1,j

等式两边增加 wi,j+fi,k+wi,j+1+fi,k′w_{i,j} + f_{i,k} + w_{i,j + 1} + f_{i,k'}wi,j+fi,k+wi,j+1+fi,k,得

wi,j+fi,k+wi,j+1+fi,k′+fk+1,j+fk′+1,j+1≤wi,j+fi,k+wi,j+1+fi,k′+fk+1,j+1+fk′+1,jwi,j+fi,k+fk+1,j+wi,j+1+fi,k′+fk′+1,j+1≤wi,j+1+fi,k+fk+1,j+1+wi,j+fi,k′+fk′+1,jfi,j,k+fi,j+1,k′≤fi,j+1,k+fi,j,k′fi,j,k−fi,j,k′≤fi,j+1,k−fi,j+1,k′\begin{aligned} w_{i,j} + f_{i,k} + w_{i,j + 1} + f_{i,k'} + f_{k + 1, j} + f_{k' + 1,j+1} &\leq w_{i,j} + f_{i,k} + w_{i,j + 1} + f_{i,k'} + f_{k + 1, j+1} + f_{k' + 1, j}\\ w_{i,j} + f_{i,k} + f_{k + 1, j} + w_{i,j + 1} + f_{i,k'} + f_{k' + 1,j+1} &\leq w_{i,j + 1} + f_{i,k} + f_{k + 1, j+1} + w_{i,j} + f_{i,k'} + f_{k' + 1, j}\\ f_{i,j,k} + f_{i,j+1,k'} &\leq f_{i,j + 1,k} + f_{i,j,k'}\\ f_{i,j,k} - f_{i,j,k'} &\leq f_{i,j+1,k} - f_{i,j+1,k'}\end{aligned}wi,j+fi,k+wi,j+1+fi,k+fk+1,j+fk+1,j+1wi,j+fi,k+fk+1,j+wi,j+1+fi,k+fk+1,j+1fi,j,k+fi,j+1,kfi,j,kfi,j,kwi,j+fi,k+wi,j+1+fi,k+fk+1,j+1+fk+1,jwi,j+1+fi,k+fk+1,j+1+wi,j+fi,k+fk+1,jfi,j+1,k+fi,j,kfi,j+1,kfi,j+1,k

所以,fi,j,k′≤fi,j,kf_{i,j,k'} \leq f_{i,j,k}fi,j,kfi,j,k 可以推出 fi,j+1,k′≤fi,j+1,kf_{i,j+1,k'} \leq f_{i,j+1,k}fi,j+1,kfi,j+1,k,即:
fi,j,k′≤fi,j,k→fi,j+1,k′≤fi,j+1,kf_{i,j,k'} \leq f_{i,j,k} \to f_{i,j+1,k'} \leq f_{i,j+1,k}fi,j,kfi,j,kfi,j+1,kfi,j+1,k

对于所有 k<si,jk < s_{i,j}k<si,j,都有 fi,j,si,j=fi,j≤fi,j,kf_{i,j,s_{i,j}} = f_{i,j} \leq f_{i,j,k}fi,j,si,j=fi,jfi,j,k

则对于所有 k<si,jk< s_{i,j}k<si,j,有 fi,j+1,si,j≤fi,j+1,kf_{i,j+1,s_{i,j}} \leq f_{i,j+1,k}fi,j+1,si,jfi,j+1,k

所以 si,j≤si,j+1s_{i,j} \leq s_{i,j+1}si,jsi,j+1

对于任意 i<k≤k′i < k\leq k'i<kk,有

fi,k+fi+1,k′≤fi,k′+fi+1,kf_{i, k} + f_{i + 1, k'} \leq f_{i, k'} + f_{i + 1, k}fi,k+fi+1,kfi,k+fi+1,k

等式两边增加 wi,j+fk+1,j+wi+1,j+fk′+1,jw_{i,j} + f_{k+1,j} + w_{i+1,j} + f_{k' + 1, j}wi,j+fk+1,j+wi+1,j+fk+1,j,得

wi,j+fk+1,j+wi+1,j+fk′+1,j+fi,k+fi+1,k′≤wi,j+fk+1,j+wi+1,j+fk′+1,j+fi,k′+fi+1,kwi,j+fi,k+fk+1,j+wi+1,j+fi+1,k′+fk′+1,j≤wi,j+fi,k′+fk′+1,j+wi+1,j+fi+1,k+fk+1,jfi,j,k+fi+1,j,k′≤fi,j,k′+fi+1,j,kfi,j,k−fi,j,k′≤fi+1,j,k−fi+1,j,k′\begin{aligned} w_{i,j} + f_{k+1,j} + w_{i+1,j} + f_{k' + 1, j} + f_{i, k} + f_{i + 1, k'} &\leq w_{i,j} + f_{k+1,j} + w_{i+1,j} + f_{k' + 1, j} + f_{i, k'} + f_{i + 1, k}\\ w_{i,j} + f_{i, k} + f_{k+1,j} + w_{i+1,j} + f_{i + 1, k'} + f_{k' + 1, j} &\leq w_{i,j} + f_{i, k'} + f_{k' + 1, j} + w_{i+1,j} + f_{i + 1, k} + f_{k+1,j}\\ f_{i,j,k} + f_{i+1,j,k'} &\leq f_{i,j,k'} + f_{i+1,j,k}\\ f_{i,j,k} - f_{i,j,k'} &\leq f_{i+1,j,k} - f_{i+1,j,k'}\end{aligned}wi,j+fk+1,j+wi+1,j+fk+1,j+fi,k+fi+1,kwi,j+fi,k+fk+1,j+wi+1,j+fi+1,k+fk+1,jfi,j,k+fi+1,j,kfi,j,kfi,j,kwi,j+fk+1,j+wi+1,j+fk+1,j+fi,k+fi+1,kwi,j+fi,k+fk+1,j+wi+1,j+fi+1,k+fk+1,jfi,j,k+fi+1,j,kfi+1,j,kfi+1,j,k

所以,fi,j,k′≤fi,j,kf_{i,j,k'} \leq f_{i,j,k}fi,j,kfi,j,k 可以推出 fi+1,j,k′≤fi+1,j,kf_{i+1,j,k'} \leq f_{i+1,j,k}fi+1,j,kfi+1,j,k,即:
fi,j,k′≤fi,j,k→fi+1,j,k′≤fi+1,j,kf_{i,j,k'} \leq f_{i,j,k} \to f_{i+1,j,k'} \leq f_{i+1,j,k}fi,j,kfi,j,kfi+1,j,kfi+1,j,k

对于所有 k<si,jk < s_{i,j}k<si,j,都有 fi,j,si,j=fi,j≤fi,j,kf_{i,j,s_{i,j}} = f_{i,j} \leq f_{i,j,k}fi,j,si,j=fi,jfi,j,k

则对于所有 k<si,jk< s_{i,j}k<si,j,有 fi,j+1,si,j≤fi+1,j,kf_{i,j+1,s_{i,j}} \leq f_{i+1,j,k}fi,j+1,si,jfi+1,j,k

所以 si,j≤si+1,js_{i,j} \leq s_{i+1,j}si,jsi+1,j

综述,si−1,j≤si,j≤si,j+1s_{i-1,j} \leq s_{i,j} \leq s_{i,j+1}si1,jsi,jsi,j+1

所以,si,j−1≤si,j≤si+1,js_{i,j-1} \leq s_{i,j} \leq s_{i+1,j}si,j1si,jsi+1,j

所以 fi,jf_{i,j}fi,j 转移方程可以转换为

fi,j={min⁡si,j−1≤k<si+1,j{x∣x=wi,j+fi,k+fk+1,j}i<j0i=j∞i>jf_{i,j}=\begin{cases} \min\limits_{s_{i,j-1}\leq k< s_{i+1,j}}\{x|x=w_{i,j}+f_{i,k}+f_{k+1,j}\}&i<j\\ 0&i=j\\ \infty&i>j\end{cases}fi,j=si,j1k<si+1,jmin{xx=wi,j+fi,k+fk+1,j}0i<ji=ji>j

我们缩小了 kkk 的范围,从而缩小的计算量。

最终时间复杂度为 O(n2)O(n^2)O(n2)(原时间复杂度为 O(n3)O(n^3)O(n3)


http://www.ppmy.cn/news/22897.html

相关文章

故障排查:ArcGIS Data Store升级失败(Attempt to configure data store failed)

博客主页&#xff1a;https://tomcat.blog.csdn.net 博主昵称&#xff1a;农民工老王 主要领域&#xff1a;Java、Linux、K8S 期待大家的关注&#x1f496;点赞&#x1f44d;收藏⭐留言&#x1f4ac; 目录故障详情问题原因解决办法总结故障详情 最近有同事反馈&#xff0c;他…

软件测试最重要的事之编写用例

软件测试用例得出软件测试用例的内容&#xff0c;其次&#xff0c;按照软件测试写作方法&#xff0c;落实到文档中&#xff0c;两者是形式和内容的关系&#xff0c;好的测试用例不仅方便自己和别人查看&#xff0c;而且能帮助设计的时候考虑的更周。 一个好的测试用例必须包含…

python(13)--字典(Dict)

一、字典的基本操作 1.定义字典 字典也是一个列表型的数据结构&#xff0c;字典的数据是用“{ }”装的&#xff08;列表&#xff1a;[ ]&#xff0c;元组&#xff1a;( )&#xff09;&#xff0c;字典的元素是一一对应的关系“key-value”。 格式&#xff1a; Dictname{ key1…

Suflo-Cyanine5.5 Tyramide,Suflo-Cyanine3 TSA,磺酸基-花青素Cy5 酪酰胺

一、试剂基团反应特点&#xff08;Reagent group reaction characteristics&#xff09;&#xff1a;TSA主要原理是利用酪胺Tyramide的过氧化物酶反应(酪胺盐在HRP催化H202下形成共价键结合位点)&#xff0c;产生大量的酶促产物&#xff0c;该产物能与周围的蛋白残基(包括色氨酸…

共聚焦显微镜能做什么

共聚焦显微镜主要采用3D捕获的成像技术&#xff0c;它通过数码相机针孔的高强度激光来实现数字成像&#xff0c;具有很强的纵向深度的分辨能力。 共聚焦显微镜成像原理 共焦显微镜装置是在被测对象焦平面的共轭面上放置两个小孔&#xff0c;其中一个放在光源前面&#xff0c;…

哪里有可以定制室内地图?室内地图怎么制作?

室内地图一般指大型室内建筑的内部地图&#xff0c;例如商场、机场等建筑物内的内部地图&#xff0c;用户通过移动终端查看室内地图可以在建筑物内部仍能较为便捷地找到要去的店铺、卫生间、电梯、休息区、出入口等。在现有技术中&#xff0c;室内地图一般都是以比较简单的平面…

RPC框架的路由策略

1 为什么选择路由策略&#xff1f; 真实环境的服务提供方以集群提供服务&#xff0c;对服务调用方&#xff0c;就是一个接口会有多个服务提供方同时提供服务&#xff0c;所以RPC每次发起请求时&#xff0c;要从多个服务提供方节点里选择一个用于发请求的节点。这次请求无论发送…

Node 多版本管理(清晰明了)

概述 最近学习cloud项目&#xff0c;前端使用到 vue3 ts 等技术&#xff0c;在启动 vue3 项目中需要 node 版本较高&#xff08;16.15.0&#xff09;&#xff0c;但自己又不想卸载原来的版本&#xff0c;这时使用需要 Node 多版本管理&#xff0c;根据项目官方文档提供的方法…