The initial solution is constructed interactively by sorting the most common characters in each position of the set of strings. The characters are then added to the RCL. The size of the RCL, alpha, determines the greediness of the algorithm. The chosen character is them randomly selected from the RCL.
Here is used a simple disturbance of the constructed solution. The method randomly changes characters to others from the alphabet. The total number of permutations can be controlled by NhbMax
func CSP(strings []string, alphabet []string, stringSize int, maxIterations int, alpha int, NhbMax int) (string,int,int)
Where:
strings
the initial set of strings to work withalphabet
array containing the characters of the stringsstringSize
the size of the resulting stringmaxIterations
number of iterationsNhbMax
greediness (a.k.a. the size of the RCL)
Return:
string
containing the solutionint
lower bound. Min distance to the setint
upper bound. Max distance to the set