function SetCover(Prob, N, CoverTol, CostType, prescription, SaveType);

%
% Get some values
%

[SCm, SCn] = size(Prob.TumorRowIndex);
[Crit, u] = size(Prob.CriticalRowIndex);
[Reg, u] = size(Prob.RegularRowIndex);

%
% Eventually an input: Desired number of beams 
%

for q = 1:length(N)

for t = 1:length(fieldnames(CostType))

%Check the pdf
SCcosts = eval(['Prob.', eval(sprintf('CostType.t%d',t)) ] );

if max(SCcosts) > .01

for s = 1:length(CoverTol)

%grab system clock
t0 = clock;

%
% Get Tumor Matrix and convert to 0-1 (1 if entry >0)
%

% Take a look at only the tumor pixels for covering
A = Prob.DoseMatrix(Prob.TumorRowIndex,:);

% Grab space for the binary matrix
SCA = zeros(SCm,Prob.NumAngles);

% Aggregate the sub-beam information into beam colums - stored in SCA
ColInd = 1;
for a = 1:Prob.NumAngles
    SCA(:,a) = A(:, ColInd : ColInd + Prob.NumPencils(a) - 1) * ...
           ones(Prob.NumPencils(a),1);
    ColInd = ColInd + Prob.NumPencils(a);
end

% Get the maximum beam dose contrabution
MaxRate = max(max(SCA));

% Convert to binary matrix depending on cover tolerance
SCA(find(SCA > CoverTol(s)*MaxRate )) = 1;
SCA(find(SCA ~= 1)) = 0;

%Check to make sure feasibility is an option
if min(SCA*ones(Prob.NumAngles,1)) < 1
   % Write a line to the latex file
   LaTex('AddRow', sprintf('SetCover (tol=%0.2f)',CoverTol(s)), ...
      'Infeasible', [], []);
else
   % Constraint on number of beams
   SCAeq = ones(1,Prob.NumAngles);
   
   % Get The Objective Coefficients
   SCcosts = eval(['Prob.', eval(sprintf('CostType.t%d',t)) ] );
   
   % Solve the binary problem
   Soln = CplexLink(-SCcosts, -SCA, -ones(SCm,1), SCAeq, N(q), [], [], ...
      char(ones(1,Prob.NumAngles)*'B'), 'mip');
   disp(Soln.statustext)
   
   % Find the Angles that were selected
   Angles = find(Soln.variables>0.999);
   
   % Construct a restricted problem
   TmpProb = RestrictedSolver(Prob, prescription, Angles);
   
   % Make the nice pics of the solution
   Figure(TmpProb, prescription, sprintf('%s_NumBeams%d_Tol=%0.2f', ...
      eval(sprintf('CostType.t%d',t)), N(q), CoverTol(s)),'SetCover', ...
           SaveType)
   
   % Write a line to the latex file
   LaTex('AddRow', sprintf('SetCover (tol=%0.2f)',CoverTol(s)), ...
      eval(sprintf('CostType.t%d',t)), Angles, etime(clock,t0)/60 );
end

end

else

   fprintf('    -> PDF is zero, skipping SetCover \n')

end

end

end
