Input: the self training set , expected coverage
Output: the detector set
: sampling times in non-self space,
: the number of non-self samples
: the number of non-self samples covered by detectors
: the set of candidate detectors
Step . Initialize the self training set
Step . Call to generate grid structure which contains selves, where
   is the -tree storage of grids and is the line storage of grids;
Step . Randomly generate a candidate detector . Call to find the grid
   where is;
Step . Calculate the Euclidean distance between and all the selves in and its neighbor grids. If
   is identified by a self antigen, abandon it and execute Step ; if not, increase ;
Step . Calculate the Euclidean distance between and all the detectors in and its neighbor grids. If
   is not identified by any detector, add it into the candidate detector set ; if not, increase , and judge
   whether it reaches the expected coverage , if so, return and the algorithm ends;
Step . Judge whether reaches sampling times . If , call to implement the screening process of
  candidate detectors, and put candidate detectors which passed this process into , reset ;
   if not, return to Step .
Algorithm 2: The algorithm of GB-RNSA.