// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   SimpleMutation.java

package drm.genetics.simple;

import drm.genetics.*;
import java.io.PrintStream;

public class SimpleMutation extends AbstractMutation
{

	public boolean DEBUG_INVERSE;

	public SimpleMutation()
	{
		DEBUG_INVERSE = false;
	}

	public SimpleMutation(double percentage)
	{
		super(percentage);
		DEBUG_INVERSE = false;
	}

	public void mutateSame(Individual individ)
	{
		drm.genetics.Gene genom[] = individ.accessGenome();
		int count = (int)Math.ceil(percentage * (double)genom.length);
		int num[] = randomNumbers(genom.length, count);
		if(DEBUG_INVERSE)
		{
			System.out.print("Mutation, inverting: ");
			int debug[] = new int[genom.length];
			for(int i = 0; i < num.length; i++)
				debug[num[i]] = 1;

			for(int i = 0; i < debug.length; i++)
				System.out.print(debug[i]);

			System.out.println();
		}
		for(int i = 0; i < num.length; i++)
			((Inversible)genom[num[i]]).inverse();

		individ.updateWeight();
	}
}
