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


class fa extends f_xj
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff;
ff=2.0*x[0]*x[1]+2.0*x[0]-x[0]*x[0]-2.0*x[1]*x[1]+10.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 OPO18
{
    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.02;
    fa fax=new fa();
    fb fbx=new fb();
    Genetic1 xx=new Genetic1(POPSIZE,MAXGENS,NVARS,N,PXOVER,PMUTATION);
    double low[]=new double[NVARS];
    double high[]=new double[NVARS];
    low[0]=-1.0;high[0]=5.0;
    low[1]=-1.0;high[1]=5.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="genetik algoritma sonucu =\n"+Matrix.toStringT(a);
    double [] r1= opt.powell(fbx,x0);
     s+="Powell çözüm seti  : \n"+Matrix.toStringT(r1);
     String s2="Genetik algoritma ve Powell çok değişkenli fonksiyon optimizasyonun birlikte kullanımı:";
     JOptionPane.showMessageDialog(null,s,s2,JOptionPane.PLAIN_MESSAGE);     
    }
}
