function [ml, min_cost] = es()
%
% exhaustive search for the known-channel multi-user ISI problem
%
% run x2_init and x2 or something like that first
%
% R. Perry, June 2001

global HUGE_VAL;
global FIR_save;
global Nusers;
global states;
global Memory;
global z;

N = size(z,1);
s = [-1; 1];
nsyms = size(s,1);
nstates = prod( (Nusers*nsyms)*ones(1,N)); % nstates = (Nusers*nsyms) ** N

c = ones( 1, Nusers*N);

min_cost = HUGE_VAL;

A = zeros( N, Memory+1, Nusers);

for i = 1:nstates

  b = s(c);

  b = reshape( b, N, Nusers); % one column per user

  w = 0;

  for u = 1:Nusers
    A(:,:,u) = get_A( b(:,u));
  end

  for t=1:N
    for u1 = 1:Nusers
      w1 = z(t,u1);
      for u2 = 1:Nusers
        w1 = w1 - A(t,:,u2)*FIR_save(:,t,u2,u1);
      end
      w = w + w1*w1;
    end
  end

  if( w < min_cost)
    min_cost = w;
    ml = b;
  end
  
  c = FSM_inc( c, nsyms);
  
end
