import java.util.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import javax.swing.*;

class fa extends f_xj
{
int n;
public double func(double x[]) 
{

//çözümü istenen fonksiyon	
double ff=0;
int n=x.length;
for(int i=0;i<n;i++)
{ff+=-Math.sin(x[i])*Math.pow(Math.sin((i+1)*x[i]*x[i]/Math.PI),20);}
return ff; //maksimum testi
}
}

public class particleswarmflytest
{
public static void main(String arg[])
{
fa ff=new fa();
double xmin[]={0.0,0.0};
double xmax[]={Math.PI,Math.PI};
double gamma=1.0;
double alpha0=0.2;
double alphan=0.001;
particle_swarm ps=new particle_swarm(ff,2000,xmin,xmax,2.0,2.0,2000);
double r1[]= ps.nelder(ff,ps.gmin());
String s="Particle swarm optimisation  : \n"+ps.toString()+"\n Nelder-Mead: \n"+ps.toString(r1);     
     String s2="Particle swarm-Nelder-Mead simplex optimization method ";
     JOptionPane.showMessageDialog(null,s,s2,JOptionPane.PLAIN_MESSAGE);
}
}