double MyHCJob19::basic_func(int func_no, double *x,int length) {
	double result = 0.0;
	switch(func_no) {
		case 0:
		case 1:
			result = ackley(x,length);
			break;
		case 2:
		case 3:
			result = rastrigin(x,length);
			break;
		case 4:
		case 5:
			result = sphere(x,length);
			break;
		case 6:
		case 7:
			result = weierstrass(x,length);
			break;
		case 8:
		case 9:
			result = griewank(x,length);
			break;
		default:
			printf("func_no is out of range.");
			exit(-1);
	}
	return (result);
}
double F5::compute(vector<double> x){ 
  int    i;
  double result = 0.0;

  if(Ovector == NULL) {
		Ovector   = createShiftVector(dimension,minX,maxX);
	  Pvector   = createPermVector(dimension);
	  RotMatrix = createRotMatrix1D(nonSeparableGroupSize);

/*
		Pvector = new int[dimension];
		for (int i=0; i<dimension; i++){
			Pvector[i] = i; 
		}
		*/
  }

  for(i = 0; i < dimension; i++) {
    anotherz[i] = x[i] - Ovector[i];
  }

  for(i = 0; i < nonSeparableGroupSize; i++) {
    anotherz1[i] = anotherz[Pvector[i]];
  }

  for(i = nonSeparableGroupSize; i < dimension; i++) {
    anotherz2[i - nonSeparableGroupSize] = anotherz[Pvector[i]];
  }

  result =
    rot_rastrigin(anotherz1,nonSeparableGroupSize) * 1.0e6 + rastrigin(
      anotherz2,dimension - nonSeparableGroupSize);
  return(result);
}
Exemple #3
0
double F9::compute(double*x){
  // int k, i;
  int i;
  double result=0.0;

  if(Ovector==NULL){
    Ovector = readOvector();
    Pvector = readPermVector();
    r25 = readR(25);
    r50 = readR(50);
    r100 = readR(100);
    s = readS(s_size);
    w = readW(s_size);
  }

  for( i=0;i<dimension;i++){
    anotherz[i]=x[i]-Ovector[i];
  }
  
  // s_size non-separable part with rotation
  int c = 0;
  for (i = 0; i < s_size; i++)
    {
      // cout<<"c="<<c<<", i="<<i<<endl;
      anotherz1 = rotateVector(i, c);
      // cout<<"done rot"<<endl;
      result += w[i] * rastrigin(anotherz1, s[i]);
      delete []anotherz1;
      // cout<<result<<endl;
    }

  update(result);
  return(result);
}
Exemple #4
0
void Ga::evaluate(Individual *individual) {
    vector<double> x(m_Dimension);
    for(int i=0; i<m_Dimension; i++) {
        vector<char> bit(m_BitSize);
        for(int j=0; j<m_BitSize; j++) {
            bit[j]=(*individual)[j+i*m_BitSize];
        }
        x[i]=decode(bit);
        x[i]=convert(x[i]);
    }
    individual->setFitness(rastrigin(x));
}
// Function body
double F09_shifted_rastrigin::f(double *x,int length) {

    double result = 0.0;

    shift(m_z, x, m_o,length);

    result = rastrigin(m_z,length);

    result += m_bias;

    return (result);
}
double MyHCJob24::basic_func(int func_no, double *x,int length) {
	double result = 0.0;
	// This part is according to Matlab reference code
	switch(func_no) {
		case 0:
			result = weierstrass(x,length);
			break;
		case 1:
			result = EScafferF6(x,length);
			break;
		case 2:
			result = F8F2(x,length);
			break;
		case 3:
			result = ackley(x,length);
			break;
		case 4:
			result = rastrigin(x,length);
			break;
		case 5:
			result = griewank(x,length);
			break;
		case 6:
			result = EScafferF6NonCont(x,length);
			break;
		case 7:
			result = rastriginNonCont(x,length);
			break;
		case 8:
			result = elliptic(x,length);
			break;
		case 9:
			result = sphere_noise(x,length);
			break;
		default:
			puts("func_no is out of range.");
			exit(-1);
	}
	return (result);
}
double F10::compute(vector<double> x){
	int i,k;
	double result=0.0;

	if(Ovector==NULL)
	{
		Ovector=createShiftVector(dimension,minX,maxX);
		Pvector=createPermVector(dimension);
		MultiRotMatrix1D=createMultiRotateMatrix1D(nonSeparableGroupSize,dimension/(2*nonSeparableGroupSize));
	}
	for(i=0;i<dimension;i++)
	{
		anotherz[i]=x[i]-Ovector[i];
	}
	for(k=1;k<=dimension/(2*nonSeparableGroupSize);k++)
	{
		result+=rot_rastrigin(anotherz,nonSeparableGroupSize,k);
	}

//	printf("Rot Rastrigin = %1.16E\n", result);
	
	result+=rastrigin(anotherz, dimension, 2);
	return(result);
}
Exemple #8
0
float eval(const vector<float>& genotype) {
	//return spherical(genotype);
	//return rozenbrock(genotype);
	return rastrigin(genotype);
}