% function uc = Wtot1_test()

global K;
global L;
global N;
global M;
global Wtot;
global Cmiss;
global Cfalse;
global path_index;
global el_index;
global MM;
global MM_max;
global missed_cost;

K1 = [1:K];
x = zeros(N,K*L);
c = zeros(K*L,1);

% L best paths and cost for each track
%
for i = 1:L
  j = K1 + (i-1)*K;
  x(:,j) = paths(i);
  c(j) = Wtot( K1+(path_index(N,i)-1)*K, el_index(N,i));
end

% indices and costs for the unique tracks
%
u = Unique(x);
uc = c(u);
nc = size(uc,1);

for j = 1:nc
  xj = x(:,u(j));
  for i = 1:N
    n = (xj(i) <= MM_max);			% number of measurements used for tracks
    m = MM(i) - n;				% number of false detections
    uc(j) = uc(j) + Cmiss(n+1,1) + Cfalse(m+1);	% apriori costs
    if( i > 1)					% missed target costs only for i>1
      uc(j) = uc(j) + m*missed_cost;
    end
  end
end
