# i need a swap mutation code (genetic algorithm) in Mathematica?

I'm working on GA coding to optimize the locators position in fixturing system to minimize the error in precision manufacturing.I need a code for mutation (genetic algorithm) in Mathematica. Here, I am sharing the code which I tried to made. Kindly, help me if possible. Thanks in advance.

string = {1, 0, 0, 0, 1, 1}
mutataionrate = .01;
domutation[string_] :=
Module[{tempstring, i},
tempstring = string;
Do[If[Random[] < mutationrate,
tempstring[[i]] = 1 - tempstring[[i]]],
{i, StringLength}];
Return[{tempstring}]]

• Have you taken a look at (How can I speed up the classic GA for graph coloring?)[mathematica.stackexchange.com/q/13454/27951]? The question and answers contain a possible implementation of mutation. – MarcoB May 28 '15 at 17:22

Since it looks like your search space is binary strings, you can take advantage of BitXor which is popular in GAs for toggling genes:
doMutation[string_, geneMutateProb_] :=