S-Random interleaver
目的
将索引 j ∈ [ 1 , N ] j \in [1,N] j∈[1,N] 通过置乱函数映射为 π j ∈ [ 1 , N ] \pi_j \in [1,N] πj∈[1,N],满足相邻 S S S个索引间距大于 S S S
算法
- 选择整数 S S S
- 对位置 j j j,随机从 1 1 1到 N N N 之间选取1个数 t t t
- 如果 t t t 之前没有被选择过,确认之前选取的 S S S 个索引与当前随机数 t t t 保持至少 S S S 的距离,也即 ∣ π p − t ∣ > S for p = j − S , . . . , j − 1 |\pi_p -t|>S \ \text{for}\ p=j-S,...,j-1 ∣πp−t∣>S for p=j−S,...,j−1
- 如果 t t t 满足条件,保留,令 π j = t \pi_j = t πj=t,持续过程指导全部 N N N 个索引被选择完。
算法收敛时间
S
<
N
2
S<\sqrt{\frac{N}{2}}
S<2N
当 S = 1 S=1 S=1,为纯随机交织(相邻间距最小为1)。当 S S S 取更大的值,可以保证置乱后相邻位置间距相较置乱前至少为 S S S。
注:这里没有给出初始 S S S 个序列的限制,实际上按照定义,应该保证初始序列之间的间距也满足要求。
代码
思路比较直给,可能理解有误,从结果来看满足要求,仅提供参考。
%% Demo of S-random Interleaver
% Author: ZA
% Date: 2024/3/25
clc;close all;clear;delete *.asv;
%% Initialize
N = 64;
% S = floor(sqrt(N/2))-1; % Converge in reasonable time
S = 3; % S=1->Purely Random Interleaver
jVec = 1:1:N;
PiJ = zeros(1,N);
PiP = zeros(1,N);
%% Start Loop
disp('S-Random Interleaver Start!');
InitFailedFlag = 0;
for j = 1:N
jVec = jVec(~ismember(jVec,PiP));
if j<=S
t = jVec(randi(length(jVec)));
dis = abs(PiP(1:j-1)-t);
if length(find(dis>S))~=j-1 && j>=2
InitFailedFlag = 1;
break;
else
PiP(j) = t;
end
else
if j>=S+1
StopFlag = 0;
jVec = jVec(~ismember(jVec,PiP));
loopCnt = 1;
while ~StopFlag && loopCnt<1000
t = jVec(randi(length(jVec)));
dis = abs(PiP(j-S:j-1)-t);
if length(find(dis>S))==S
StopFlag = 1;
end
loopCnt = loopCnt+1;
end
PiP(j) = t;
end
end
end
%% Results Output
if InitFailedFlag
disp('Initialize Failed! Please Restart!');
else
if loopCnt>=1000
disp(['Loop Max! Failed at j = ',num2str(j)]);
else
disp('S-Random Interleaver Success!');
end
end
disp(PiP);
%% Calculate Adjacent Distance
disPiP = zeros(S,N-1);
for iS = 1:S
disPiP(iS,iS:N-1) = abs(PiP(1+iS:end) - PiP(1:end-iS));
end
运行结果 1
成功生成
S-Random Interleaver Start!
S-Random Interleaver Success!
列 1 至 11
24 3 60 19 32 23 11 17 47 21 58
列 12 至 22
14 40 18 30 25 54 43 34 59 48 28
列 23 至 33
63 7 12 57 36 16 52 61 46 39 51
列 34 至 44
33 64 15 27 10 41 37 56 45 20 38
列 45 至 55
53 2 6 44 50 13 9 55 49 22 4
列 56 至 64
35 8 26 1 31 62 5 42 29
>>
运行结果 2
初始化失败,因前 S S S 个索引采用随机数生成,不可避免地存在间距小于 S S S 的情况
S-Random Interleaver Start!
Initialize Failed! Please Restart!
列 1 至 11
34 0 0 0 0 0 0 0 0 0 0
列 12 至 22
0 0 0 0 0 0 0 0 0 0 0
列 23 至 33
0 0 0 0 0 0 0 0 0 0 0
列 34 至 44
0 0 0 0 0 0 0 0 0 0 0
列 45 至 55
0 0 0 0 0 0 0 0 0 0 0
列 56 至 64
0 0 0 0 0 0 0 0 0
>>
运行结果 3
在最后输出错误,可以发现最后两位间距为1,不满足要求,但最后4位索引没有可供选择的余地了,此时需要重新运行生成
S-Random Interleaver Start!
Loop Max! Failed at j = 64
列 1 至 11
9 19 36 24 55 15 40 20 60 27 43
列 12 至 22
34 63 23 42 50 62 35 14 52 18 45
列 23 至 33
33 41 49 13 57 31 1 37 11 28 21
列 34 至 44
39 7 48 2 22 30 38 54 46 25 32
列 45 至 55
16 61 47 56 4 26 8 58 3 51 29
列 56 至 64
17 12 44 53 59 64 10 6 5
>>
参考资料
[1] Tarable A, Escribano F J. Chaos-Based Anytime Reliable Coded Communications[J]. IEEE Systems Journal, 2020, 14(2): 2214–2224.