// 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:   MethodGATask.java

package lt.ktu.gmj.methods;

import drm.genetics.*;
import drm.genetics.advanced.BestSelCrossover;
import drm.genetics.advanced.BestSelMutation;
import drm.genetics.simple.*;
import lt.ktu.gmj.*;

// Referenced classes of package lt.ktu.gmj.methods:
//			MethodGAIndividual

public class MethodGATask extends drm.genetics.AbstractTask
{

	protected lt.ktu.gmj.Task task;
	protected int indCount;

	public MethodGATask(lt.ktu.gmj.Task task, int indCount, int mutationType, double percentMutating, int mutationLevel, int crossoverType, 
			int crossoverStyle, int crossoverLevel)
	{
		this.task = task;
		this.indCount = indCount;
		minWeight = (1.0D / 0.0D);
		switch(mutationType)
		{
		case 0: // '\0'
			mutation = new SingleGeneMutation();
			break;

		case 1: // '\001'
			mutation = new SimpleMutation(percentMutating);
			break;

		case 2: // '\002'
			mutation = new BestSelMutation(percentMutating, mutationLevel);
			break;
		}
		switch(crossoverType)
		{
		case 0: // '\0'
			crossover = new SimpleCrossover();
			break;

		case 1: // '\001'
			crossover = new BestSelCrossover(crossoverLevel);
			break;
		}
		switch(crossoverStyle)
		{
		case 0: // '\0'
			crossover.setType(1);
			break;

		case 1: // '\001'
			crossover.setType(2);
			break;

		case 2: // '\002'
			crossover.setType(-1);
			break;
		}
	}

	public Individual[] createIndividuals()
	{
		int size = task.domain().defaultPoint.x.length;
		Gene genom[] = new Gene[size];
		Individual inds[] = new Individual[indCount];
		for(int i = 0; i < indCount; i++)
		{
			MethodGAIndividual uin = new MethodGAIndividual();
			uin.init(task);
			inds[i] = uin;
		}

		return inds;
	}
}
