function [A,C,fval] = mylpm(h) %global A0 global nstate m = nstate; % box constraints LB = zeros(m,1); UB = ones(m,1); % normalization constraints Aeq = zeros(m+1,m^2+m); for i=1:m+1 for j=1:m Aeq(i,m*(i-1)+j) = 1; end end Beq = ones(m+1,1); % stricture constraints %% nevermind for now -- a bit cumbersome... %% though still linear, i'm pretty sure %% let's cheat % not cheating, doing this right SIGNS = 2*list_all_ind(repmat([2],[1 m]))-3; Ain = zeros(size(SIGNS,1)*m*(m-1)/2,m^2+m); rind = 0; for i1 = 1:m for i2 = i1+1:m for s = 1:size(SIGNS,1) rind = rind+1; ss = SIGNS(s,:); for j=1:m ind1 = coord2ind([j i1],[m m]); ind2 = coord2ind([j i2],[m m]); Ain(rind,ind1) = ss(j); Ain(rind,ind2) = -ss(j); end end end end Bin = ones(size(SIGNS,1),1)*h*2; A1 = pnormdim(rand(m,m),1); C1 = pnormdim(rand(m,1),1); x0 = [A1(:);C1] options = optimset('TolCon',1e-12,'TolFun',1e-12) [x,fval] = fmincon(@myobjm,x0,Ain,Bin,Aeq,Beq,LB,UB,[],options); A = reshape(x(1:nstate^2),[nstate nstate]); C = x(end-nstate+1:end); return %function nonlcon(x) %global curH % %return %function [h,i1,i2] = strict(A) function h = strict(x) A = reshape(x(1:nstate^2),[nstate nstate]); [n,n,T] = size(A); h = 0; i1 = 0; i2 = 0; for t=1:T for i=1:n %for i=1 for j=i+1:n x = A(:,i); y = A(:,j); d = .5*sum(abs(x-y)); if d>h i1=i; i2=j; h=d; end end end end return