m=2 n=3 dims = repmat([m],[1 n]); [Ainf,Binf] = lipab(m,n); good = 1; while good K = zeros(m^n,1); if 1 while 1 sig = sign(randn(m,1)); if ~all(sig==sig(1)) break end end K = rand(m^n,1); % ensure signs condition for xind = 1:m^n x = ind2coord(xind,dims); s = sig(x(1)); K(xind) = K(xind)*s; end else K = randn(m^n,1); end if 1 % sum|K|<=2 ip = find(K>=0); K(ip) = K(ip)/sum(K(ip)); in = find(K<0); K(in) = K(in)/abs(sum(K(in))); else % ensure sum= 0 K = K - sum(K)/length(K); end LB = 0+zeros(m^(n),1); UB = n+zeros(m^(n),1); %[x,fval] = linprog(-K,[],[],[],[],LB,UB); [x,fval] = linprog(-K,Ainf,Binf,[],[],[],[]); if fval>0 K = -K end phi = round(x-min(x))'; FN = randFN(m,-n,1,'no'); phi = FN{end}; phi = round(phi-min(phi)); S = abs(fval) MU = {}; sum0 = 0; %[MU1,phi1,K1,maxs,st] = boundsumm(K,m,n,{},sum0); %[mu,phi1,K1,maxs] = boundsumm1(K,phi,m,n) [mu,phi1,K1,maxs] = boundsumm2(K,m,n); %[mu,phi1,K1,maxs] = boundsumnl(K,m,n); %mu = MU1{1}; %mu = find(mu); maxs g1 = (maxs+1e-8 > S); %mu0 = getmask1(phi,m,n); %phim = fillgmask(mu0,m); %g2 = isempty(symsetdiff(mu0{1},mu)); %good = (g1 & g2); good = (g1); keyboard if ~good 'bad' keyboard end end