%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pickVariablesToEliminate
%
% Carlos Guestrin    guestrin@cs.stanford.edu
% December 2000

%%% This method finds the variables in the variables vector that
%haven't yet been eliminated, returns their index 

function[eliminate, num] = pickVariablesToEliminate(variables, elim) 

eliminate = [];
num = 0;

num_variables = length(variables);

%%%% if elim is not empty find uneliminated variables that contain
%elim in the domain
if ~isempty(elim)
  for i = 1:num_variables
    if (variables(i).eliminated == 0)
      if ~isempty(variables(i).domain)
	if ~isempty(find(variables(i).domain == elim))
	  num = num + 1;
	  eliminate(num) = i;
	end
      end
    end
  end
%%%%% if elim is empty find all uneliminated variables that have
%non-empty domain
else
  for i = 1:num_variables
    if (variables(i).eliminated == 0)
      if isempty(variables(i).domain)
	num = num + 1;
	eliminate(num) = i;
      end
    end
  end
end



