{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}} {\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\lang1033\f0\fs20 %%% CODE FOR COMPUTING THE LIST OF INEQUALITIES THAT CHARACTERIZE THE SUPERMODULAR STOCHASTIC ORDERING.\par \par %%% THIS CODE IS BASED ON THE DUAL CONE REPRESENTATION ALGORITHM BY FUKUDA, \par %%% AND REQUIRES THE MATLAB FILE cddmex.dll\par \par %%% PART I: The function falgo(d) takes as an imput the vector of dimensions of the lattice \par %%% for which the SSO is characterized.\par %%% The output is the list of inequalities that the difference vector g-f mut satisfy, \par %%% in order to be comparable in the SSO sense\par \par \par function func = falgo(d)\par k = numel(d);\par w = ones(1,k);\par for j=2:k\par w(j) = prod(d(1:j-1)); \par end\par m = prod(d);\par A = zeros(1,m); \par i = ones(1,k);\par while sum(i) < sum(d)\par l1 = (i-1)*w'+1;\par for j1 = 1:k\par for j2 = j1+1:k\par if (d(j1)-i(j1))*(d(j2)-i(j2))>0\par v = zeros(1,m);\par v(l1) = 1; \par v(l1 + w(j1)) = -1;\par v(l1 + w(j2)) = -1;\par v(l1 + w(j1) + w(j2)) = 1;\par A = [A; v];\par end\par end\par end\par l = find(d-i>0,1);\par i(1:l-1) = 1;\par i(l) = i(l)+1;\par end\par A = A(2:end,:);\par size(A);\par H=struct('A',-A,'B',zeros(size(A,1),1));\par func =cddmex('extreme',H);\par \par \par \par %%% PART II: The function fdimsym characterizes the \ul symmetric\ulnone supermodular stochastic ordering.\par %%% It takes as inputs the number of dimensions of the lattice, and the (common) number of points \par %%% in the support along each dimension.\par \par function func = fdimsym(ndimensions,npoints)\par k = ndimensions;\par d = npoints*ones(1,k);\par w = ones(1,k);\par for j=2:k\par w(j) = prod(d(1:j-1)); % w indicates index shift per dimension\par end\par m = prod(d);\par A = zeros(1,m); \par i = ones(1,k);\par nsym = nchoosek(ndimensions+npoints-1,npoints-1);\par T = zeros(m,nsym);\par countsym = zeros(1,nsym);\par while sum(i) <= sum(d) \par l1 = (i-1)*w'+1; % returns index representation from spatial representation\par ri = rearrange(i,npoints);\par lexi = lexico(ri);\par T(l1,lexi) = 1;\par countsym(lexi) = countsym(lexi)+1;\par for j1 = 1:k\par for j2 = j1+1:k\par if (d(j1)-i(j1))*(d(j2)-i(j2))>0\par v = zeros(1,m);\par v(l1) = 1; \par v(l1 + w(j1)) = -1;\par v(l1 + w(j2)) = -1;\par v(l1 + w(j1) + w(j2)) = 1;\par A = [A; v];\par end\par end\par end\par if i==d\par i(1) = i(1) + 1;\par end\par l = find(d-i>0,1);\par i(1:l-1) = 1;\par i(l) = i(l)+1;\par \par end\par A = A(2:end,:);\par %size(A);\par SA = A*T;\par j = 1;\par while j