bool eval_x ( Eval_Point & x , const Double & h_max , bool & count_eval ) const { int n = x.size(); int m = x.get_bb_outputs().size(); int i; double * xx = new double [n]; double * fx = new double [m]; for ( i = 0 ; i < x.size() ; ++i ) xx[i] = x[i].value(); // call the FORTRAN routine: bb_ ( xx , fx ); for ( i = 0 ; i < m ; ++i ) x.set_bb_output ( i , fx[i] ); count_eval = true; // count a black-box evaluation return true; // the evaluation succeeded }
bool eval_x ( Eval_Point & x , const Double & h_max , bool & count_eval ) const { Double c1 = 0.0 , c2 = 0.0; for ( int i = 0 ; i < 5 ; i++ ) { c1 += (x[i]-1).pow2(); c2 += (x[i]+1).pow2(); } x.set_bb_output ( 0 , x[4] ); // objective 1 x.set_bb_output ( 1 , c1-25 ); // objective 2 x.set_bb_output ( 2 , 25-c2 ); // constraint 1 count_eval = true; // count a black-box evaluation return true; // the evaluation succeeded }
bool eval_x ( Eval_Point & x , const Double & h_max , bool & count_eval ) const { double xx[42]; double fx[1]; int i; // cout << "eval_x: values of x\n"; for ( i = 0 ; i < 42 ; ++i ) { xx[i] = x[i].value(); // cout << i << " " << xx[i] << "\n" ; } // call the FORTRAN routine: // cout << "Calling bb_kleed\n"; bb_kleed_ ( xx , fx ); for ( i = 0 ; i < 1 ; ++i ) x.set_bb_output ( i , fx[i] ); count_eval = true; // count a black-box evaluation return true; // the evaluation succeeded }
// eval_x: bool My_Evaluator::eval_x ( Eval_Point & ep , const Double & h_max , bool & count_eval ) const { count_eval = true; int epi = 0; _x[0] = ep[epi++].value(); _y[0] = 0.0; _x[1] = ep[epi++].value(); _y[1] = 0.0; _y[2] = ep[epi++].value(); _x[2] = 0.0; _x[3] = ep[epi++].value(); _y[3] = ep[epi++].value(); int ic = 0 , i , j; double constraint = 0.0; for ( i = 4 ; i < _NBC ; ++i ) { _x[i] = ep[epi++].value(); _y[i] = ep[epi++].value(); } ep.set_bb_output ( ic++ , constraint ); double dist , distmax = 0.0, avg_dist = 0.0; constraint = 1.0; /*for ( i = 0 ; i < _NBC ; ++i ) { for( j = i+1 ; j < _NBC ; ++j ) { dist = pow(_x[i]-_x[j],2) + pow(_y[i]-_y[j],2); avg_dist += sqrt(dist); if ( dist > distmax ) distmax = dist; if( dist < 1 ) constraint *= dist; } } ep.set_bb_output ( ic++ , 1.0-constraint ); ep.set_bb_output ( _M , sqrt(distmax) ); */ for ( i = 0 ; i < _NBC-1 ; ++i ) { // out << " ( "<< _x[i] << ", " << _y[i] << " ) \n"; for( j = i+1 ; j < _NBC ; ++j ) { dist = pow(_x[i]-_x[j],2) + pow(_y[i]-_y[j],2); if ( dist > distmax ) distmax = dist; if( dist < 1 ) { constraint *= sqrt(dist); } else if( dist > 14) avg_dist += sqrt(dist); // out << i << " " << j << " . " << sqrt(dist) << endl; } } // out << distmax << " " << avg_dist << " " << constraint << " "; if (constraint < 0.9999) constraint = 1001.0-constraint; else constraint = sqrt(distmax) + avg_dist/(10.0*_NBC); // out << constraint << "\n"; ep.set_bb_output ( ic++ , 0.0 ); ep.set_bb_output ( _M , constraint); return true; }