1. Hamilton方法的缺陷
在只考虑组织人数,而不考虑其他因素的情况下,Hamilton的方法分配席位是不公平的。
如果名额人数增加到21名,同样利用上一篇博客的Matlab代码,求出了以下的分配方案:
在人数不变的情况下,显然这个结果对丙系是极其不公平的,因为总名额增加一个,而丙系的代表名额却由4个减少为3个。由此可见,哈密顿方法存在很大缺陷。
2. 新的方法:Huntington方法(推导过程,可以略过)
3. Huntington方法的Matlab代码
Huntington方法的推导过程可能比较长,但是结论是比较简洁的。关键就是求出 Q i Q_i Qi进行比较。Matlab代码也很简单,只需要十行代码,如下:
% Solutions to the problem of equitable distribution
%Huntington method
% Allocation of seats by Huntington method
% # Define basic parameters
% # Numbers of places are N
N=21;
% # numbers of organizations are s
s=3;
% The number of people in the ith Organization (the default sorting is in descending order)
numbers=[103 63 34];
%进入循环前, 先每个单位分一个名额,定义剩下的名额数量N_1
N_1=N-s;
results=ones(1,s);
disp('首先给每一个组织分配一个名额,result=')
disp(results)
%分配剩下的N-s个名额
loop_num=0;
while N_1
temp=results;
Qvalue=(numbers.^2)./((temp+1).*(temp));
[Maxvalue,index]=max(Qvalue);
results(index)=results(index)+1;
loop_num=loop_num+1;
% disp('第'+num2str(loop_num+1)+'个名额分配给了第'+num2str(index)+'位组织')
N_1=N_1-1;
end
disp('最后的结果:results=')
disp(results)
4. 求解结果
同样如果名额为21,这次用新的方法求分配方案:
可见,丙保住了失去的那个名额,相对公平。