function A=hminired(A) %HMINIRED Initial reduction of cost matrix for the Hungarian method. % %B=assredin(A) %A - the unreduced cost matris. %B - the reduced cost matrix with linked zeros in each row. % v1.0 96-06-13. Niclas Borlin, niclas@cs.umu.se. [m,n]=size(A); % Subtract column-minimum values from each column. colMin=min(A); A=A-colMin(ones(n,1),:); % Subtract row-minimum values from each row. rowMin=min(A')'; A=A-rowMin(:,ones(1,n)); % Get positions of all zeros. [i,j]=find(A==0); % Extend A to give room for row zero list header column. A(1,n+1)=0; for k=1:n % Get all column in this row. cols=j(k==i)'; % Insert pointers in matrix. A(k,[n+1 cols])=[-cols 0]; end
时间: 2024-02-16 14:01:18 浏览: 156
这部分代码实现了对代价矩阵的约化。先对每一列减去其最小值,再对每一行减去其最小值。这样约化后的矩阵中至少有一个元素为 0。接下来,找到所有为 0 的元素的位置,对于每一行,在矩阵的最后一列新增一个指针,指向该行中所有为 0 的元素所在的列。这样,在匈牙利算法中寻找增广路径时,只需要遍历每一行中所有指向未匹配列的指针,找到增广路径的起点。
相关问题
PCX1 = 1.5482 $Shape factor Cfx for longitudinal force PDX1 = 1.1632 $Longitudinal friction Mux at Fznom PDX2 = -0.11154 $Variation of friction Mux with load PDX3 = 0.94173 $Variation of friction Mux with camber squared PEX1 = 0.27 $Longitudinal curvature Efx at Fznom PEX2 = 0.011693 $Variation of curvature Efx with load PEX3 = 0.053303 $Variation of curvature Efx with load squared PEX4 = 0.59223 $Factor in curvature Efx while driving PKX1 = 32.9102 $Longitudinal slip stiffness Kfx/Fz at Fznom PKX2 = 12.7911 $Variation of slip stiffness Kfx/Fz with load PKX3 = -0.11254 $Exponent in slip stiffness Kfx/Fz with load PHX1 = -0.0017527 $Horizontal shift Shx at Fznom PHX2 = 0.00068824 $Variation of shift Shx with load PVX1 = 0.068079 $Vertical shift Svx/Fz at Fznom PVX2 = 0.0023429 $Variation of shift Svx/Fz with load PPX1 = -0.8733 $linear influence of inflation pressure on longitudinal slip stiffness PPX2 = 0.7035 $quadratic influence of inflation pressure on longitudinal slip stiffness PPX3 = -0.0080216 $linear influence of inflation pressure on peak longitudinal friction PPX4 = -0.47776 $quadratic influence of inflation pressure on peak longitudinal friction RBX1 = 18.3369 $Slope factor for combined slip Fx reduction RBX2 = 18.2559 $Variation of slope Fx reduction with kappa RBX3 = 607.8133 $Influence of camber on stiffness for Fx combined RCX1 = 0.96372 $Shape factor for combined slip Fx reduction REX1 = -1.2699 $Curvature factor of combined Fx REX2 = -0.14323 $Curvature factor of combined Fx with load RHX1 = 0.0037359 $Shift factor for combined slip Fx reduction帮我做成表格
| 参数 | 值 |
| --- | --- |
| PCX1 | 1.5482 |
| PDX1 | 1.1632 |
| PDX2 | -0.11154 |
| PDX3 | 0.94173 |
| PEX1 | 0.27 |
| PEX2 | 0.011693 |
| PEX3 | 0.053303 |
| PEX4 | 0.59223 |
| PKX1 | 32.9102 |
| PKX2 | 12.7911 |
| PKX3 | -0.11254 |
| PHX1 | -0.0017527 |
| PHX2 | 0.00068824 |
| PVX1 | 0.068079 |
| PVX2 | 0.0023429 |
| PPX1 | -0.8733 |
| PPX2 | 0.7035 |
| PPX3 | -0.0080216 |
| PPX4 | -0.47776 |
| RBX1 | 18.3369 |
| RBX2 | 18.2559 |
| RBX3 | 607.8133 |
| RCX1 | 0.96372 |
| REX1 | -1.2699 |
| REX2 | -0.14323 |
| RHX1 | 0.0037359 |
function Selected_Data_Index = BPLSH(Data,M,L,W) %----------Data Reduction----------% %Normalizing the data between 0 and 1 maximum = max(Data(:,1:end-1)); %找出Data第一列到倒数第二列,每一列元素的最大值 minimum = min(Data(:,1:end-1)); maxmin = maximum-minimum; maxmin(maxmin==0) = 1; Data(:,1:end-1) = (Data(:,1:end-1) - minimum)./maxmin; % ./ 一一对应相除 %将Data 第一列 到 倒数第二列所有行的元素赋值 Dimension = size(Data(:,1:end-1),2); % Number of features M; % Number of hash functions in each table L; % Number of hash tables W; % Bucket size %s = rng; %Reset Random Number Generator 重置随机数生成器 a = normrnd(0,1, [M*L , Dimension]); %生成M*L?Dimension的随机矩阵,每个元素都是从均值为0,标准差为1的正态分布中随机生成 %# Generate a in floor((ax+b)/W) b = W.*rand(M*L,1); % Generate b in floor((ax+b)/W) %生成M*L行1列伪随机数 % Calculating the buckets of samples % disp('Bucket Assigning'); Bucket_Index_Decimal_All = int32(zeros(L,size(Data(:,1:end-1),1))); 解释一下
该函数的功能是进行数据降维,使用了基于局部敏感哈希(BPLSH)的方法。
下面是对函数中代码的解释:
1. 对数据进行归一化,将所有特征值缩放到0和1之间。
2. 定义了三个参数:M表示每个哈希表中的哈希函数数量,L表示哈希表数量,W表示哈希桶大小。
3. 生成随机数矩阵a和b,用于哈希函数的计算。其中a是一个M*L行,每行包含Dimension个元素的矩阵,每个元素都是从均值为0,标准差为1的正态分布中随机生成的。b是一个M*L行,每行只有一个元素,这个元素是从0到W之间的随机整数。
4. 计算数据样本的哈希桶索引。对于每个样本,使用M个哈希函数将其映射到M个哈希桶中,并将这M个哈希桶的索引值连接起来作为该样本在一个哈希表中的索引。最终得到一个L行,每行包含所有样本在该哈希表中的索引值的向量。这个向量中的每个元素是一个十进制整数,表示样本在对应哈希桶中的索引。
5. 将所有样本在L个哈希表中的哈希桶索引值合并,得到一个L*实例数的矩阵Bucket_Index_Decimal_All。其中每一列是一个实例在L个哈希表中的哈希桶索引值。
6. 返回Bucket_Index_Decimal_All。
阅读全文