evodef.DefaultMutator Maven / Gradle / Ivy
package evodef;
import java.util.Arrays;
import java.util.Random;
/**
* Created by sml on 17/01/2017.
*/
public class DefaultMutator implements Mutator {
// this will be set each time a DefaultMutator is created
public double pointProb;
static Random random = new Random();
public boolean totalRandomChaosMutation = false;
public static double defaultPointProb = 1.0;
public static boolean flipAtLeastOneValueDefault = true;
public boolean flipAtLeastOneValue = flipAtLeastOneValueDefault;
SearchSpace searchSpace;
public DefaultMutator(SearchSpace searchSpace) {
this.searchSpace = searchSpace;
pointProb = defaultPointProb;
flipAtLeastOneValue = flipAtLeastOneValueDefault;
}
boolean swapMutation = false;
public int[] swapMutation(int[] a) {
int[] x = new int[a.length];
// first of all make a copy
for (int i=0; i= cur ? rx+1 : rx;
}
public static int diffHamming(int[] a, int[] b) {
int tot =0;
for (int i=0; i