import java.io.*;
import javax.swing.*;


class fa extends f_xj
{
//çözümü istenen fonksiyon	
 double func(double x[])
 {
    double ff= 1.0+Math.cos(Math.PI*(x[0]-3.0))*Math.cos(2.0*Math.PI*(x[1]-2.0))/
    (1+(x[0]-3.0)*(x[0]-3.0)+(x[1]-2.0)*(x[1]-2.0));
    return ff; //maksimum testi;
  }
}

class fb extends f_xj
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff;
fa fx=new fa();
return -fx.func(x); //maksimum testi
}
}

class NA109
{
    public static void main(String args[]) throws IOException
    {
	int N=18;
	int POPSIZE=200;
    int MAXGENS=200;
    int NVARS=2;
    double PXOVER=0.3;
    double PMUTATION=0.03;
    fa fax=new fa();
    fb fbx=new fb();
    Genetic3 xx=new Genetic3(POPSIZE,MAXGENS,NVARS,N,PXOVER,PMUTATION);
    double low[]=new double[NVARS];
    double high[]=new double[NVARS];
    low[0]=-10.0;high[0]=10.0;
    low[1]=-10.0;high[1]=10.0;
    xx.setPopulation(low,high,fax);
    double a[]=xx.calculate(fax,false);
    double x0[]=new double[NVARS];
    for(int i=0;i<NVARS;i++) x0[i]=a[i];
    String s="results of genetic algorithms =\n"+Matrix.toStringT(a);
     String s2="Genetic algorithm multi-variable optimisation:";
     JOptionPane.showMessageDialog(null,s,s2,JOptionPane.PLAIN_MESSAGE);     
    }
}
