function [BestSet] = keys(train, testData, BUDGET)

% This runs KEYS with FWPSABE as a scoring function.

% Declare all our nice parameters.

guessNum = 10 * BUDGET; % Number of guesses per cycle
[numProjects, numFeatures] = size(train);

Selected = zeros(1, numProjects + (2*(numFeatures - 1))) - 1; % Matrix of fixed mitigations, starts with no selections
[junk, length] = size(Selected);

Guessed = [];
numSet = 1;

while all(Selected >= 0) ~= 1
Guessed = randint(guessNum, length + 1);
for i = 1 : guessNum
input = mergesg(Selected, Guessed(i,1:(end -1)));
Guessed(i,end) = fwpsabe(train, testData, input(1, 1 : numProjects), input(1, (1 + numProjects) : end));
end
rank = bore(Selected, Guessed);

[junk, highRank] = max(abs(rank));
if (rank(1,highRank) > 0)
Selected(1, highRank) = 1;
end
if (rank(1,highRank) < 0)
Selected(1, highRank) = 0;
end
rank(1,highRank) = 0;

numSet++;
endwhile

BestSet = Selected;