| Procedure. CB-RNSA |
| Input: self training set Train, expected coverage rate p0 |
| Output: detector set D, boundary self set Selfo, outlier self set Selfd |
| n0: the sampling frequency of non-self space, n0 |
| i: the number of non-self samples |
| m: the number of non-self samples which are covered by detectors |
| : candidate detector set = = = , , ,āā |
| Clusters: cluster set Clusters = |
| : the number of candidate detector level |
| Begin |
| Initialize self training set Train, i = 0, m = 0, , , n0 = ; |
| Initialize outlier self set Selfd according to Procedure outlier selves discovery algorithm; |
| Initialize cluster set Clusters according to Procedure clusters discovery algorithm; |
| While does not reach the maximum number of levels for candidate detectors do |
| Consider centers of Clusters as antigens, randomly generate initial immune cell population in the qualified range; |
| While true do |
| Select immune cells; |
| Generate copies of immune cells; |
| Mutate according to affinities; |
| Compute distances between mutated individual and every self in the training set Train; |
| If is recognized by some self Then discard ; |
| Else |
| Find the closest self to dnew, and add it to boundary self set Selfo; |
| i ++; |
| Compute distances between and every detector in the detector set D; |
| If dnew is not identified by any detector Then put it into the candidate detector set CD; |
| Else m ++; |
| End if; |
| If the number of non-self samples reaches the sample times Then |
| Compute current coverage rate p; |
| If p reaches the expected coverage rate , break; |
| Else incorporate candidate detector set CD with D, reset i, m, CD; |
| End if; |
| End; |
| l ++; |
| Changes the limited range of candidate detectors; |
| End; |
| End. |