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

global HUGE_VAL;
global FIR;
global states;
global Memory;
global z;

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

c = ones( 1, N);

min_cost = HUGE_VAL;

for i = 1:nstates

  b = s(c);

  A = get_A( b);

  w = 0;

  for t=1:N
    w1 = z(t) - A(t,:)*FIR;
    w = w + w1*w1;
  end

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