“…M, Maximum number of active users N, error threshold P e th , code reallocation interval T Output: Code assignment messages 1: design an OCDMA system with N users, M wavelengths and error threshold P e th using formulation (6) and name obtained code length, code weight and crosscorrelation L, W and λ; 2: for i = 1, · · · , N do 3: design an OCDMA system with i users, M wavelengths, code length L and error threshold P e th using formulation (7) and name obtained code weight and cross-correlation W i and λ i ; 4: end for 5: n ←− N; 6: choose code book (L,W n , λ n ); 7: send code assignment messages; 8: T cr ←− time() + T; 9: while 1 do 10: if a user activation message is received then 11: n ←− n + 1; 12: else if a user deactivation message is received then 13: n ←− n − 1; 14: end if 15: if time() T cr then 16: choose code book (L,W n , λ n ); 17: send code assignment messages; 18: T cr ←− time() + T; 19: end if 20: end while For example when L max = 4000, W max = 100 and λ max = 5, the complexity gain G com is more than 10 4 which means that Alg. 1 is 10 4 times faster than its brute force search counterpart.…”