class faa extends f_xj
{
double func(double x[])
{
double top=0.0;
for(int i=0;i<x.length;i++)
{top+=(x[i]-1.0)*(x[i]-1.0);}	
return top;	
}	
}



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

class fb extends f_xj // De Jongs first function 2.1
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff=0;
int n=x.length;
for(int i=0;i<n;i++)
{ff+=x[i]*x[i];}
return ff;
}
} 

class fc extends f_xj //Axis parallel hyper-ellipsoid 2.2
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff=0;
int n=x.length;

for(int i=0;i<n;i++)
{ff+=i*x[i]*x[i];}
return ff;
}
}

class fd extends f_xj //Rotated hyper-ellipsoid function 2.3
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff=0;
int n=x.length;

for(int i=0;i<n;i++)
{
  for(int j=0;j<i;j++)
  {ff+=x[j]*x[j];}	
}
return ff;
}
}

class fe extends f_xj //Rastrigins function 2.5
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff=0;
int n=x.length;
double nn=10.0;
double r=Math.PI/180;
for(int i=0;i<n;i++)
{
ff+=x[i]*x[i]-10*Math.cos(r*2.0*Math.PI*x[i]);
}
return ff+10*n;
}
}

class fj extends f_xj //sum of a different function 2.8
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff=0;
int n=x.length;

double r=Math.PI/180;
double top=0;
for(int i=0;i<n;i++)
{top+=Math.pow(Math.abs(x[i]),(i+2));}
return top;
}
} 

class fk extends f_xj //Ackleys function 2.9
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double a=20.0;
double b=0.2;
double c=2.*Math.PI;

int n=x.length;

double r=Math.PI/180;
double top1=0.0;
for(int i=0;i<n;i++)
{top1+=x[i]*x[i];}
top1=Math.sqrt(top1/n);
double top2=0.0;
for(int i=0;i<n;i++)
{top2+=Math.cos(r*c*x[i]);}
top2=top2/n;
double top=-a*Math.exp(-b*top1)-Math.exp(top2)+a+Math.exp(1);
return top;
}
}

class fr extends f_xj //Drop wave function ++
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double r=Math.PI/180;
double top1=-(1+Math.cos(r*(12*Math.sqrt(x[0]*x[0]+x[1]*x[1]))))/(0.5*(x[0]*x[0]+x[1]*x[1])+2);
return top1;
}
}

class fs extends f_xj //Shuberts function  2.18
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	

double r=Math.PI/180;
double top1=0;
double top2=0;
for(int i=1;i<=5;i++)     
{top1+=i*Math.cos((i+1)*x[0]+1);}
for(int i=1;i<=5;i++)     
{top2+=i*Math.cos((i+1)*x[1]+1);}
return -top1*top2;
}
}





public class gravitational_algorithm_test
{
    public static void main(String args[])
    {
       int N=100;  
	   int maxiter=100000;
	   double[] Lowerbound={-5.0,-5.0};
	   double[] Upperbound={5.0,5.0};
	   fa ff=new fa();
	   gravitional_search_algorithm gsa=new gravitional_search_algorithm(ff,N,maxiter,Lowerbound,Upperbound);  
	   gsa.toStringnew();
    }

}