Ejemplo n.º 1
0
  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
  }
Ejemplo n.º 2
0
/*---------------------------------------------------------------------*/
NOMAD::Eval_Point::Eval_Point ( const Eval_Point & x )
    : NOMAD::Point        ( x.get_n()                         ) ,
      _tag                ( NOMAD::Eval_Point::_current_tag++ ) ,
      _signature          ( x._signature                      ) ,
      _f                  ( x._f                              ) ,
      _h                  ( x._h                              ) ,
      _in_cache           ( x._in_cache                       ) ,
      _current_run        ( x._current_run                    ) ,
      _eval_type          ( x._eval_type                      ) ,
      _direction          ( NULL                              ) ,
      _poll_center_type   ( x._poll_center_type               ) ,
      _eval_status        ( x._eval_status                    ) ,
      _EB_ok              ( x._EB_ok                          ) ,
      _bb_outputs         ( x.get_bb_outputs()                ) ,
      _user_eval_priority ( x._user_eval_priority             ) ,
      _rand_eval_priority ( x._rand_eval_priority             )
{
    // point coordinates:
    int n = size();
    for ( int i = 0 ; i < n ; ++i )
        (*this)[i] = x[i];

    // _direction:
    if ( x._direction )
        _direction = new Direction ( *x._direction );

#ifdef MODEL_STATS
    set_model_data ( x );
#endif
}
Ejemplo n.º 3
0
  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
  }
Ejemplo n.º 4
0
  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
  }
Ejemplo n.º 5
0
/*--------------------------------------------*/
void My_Evaluator::update_success ( const Stats & stats , const Eval_Point & x ) {
  if ( x.is_feasible ( _p.get_h_min() ) )
    plot_success ( stats.get_bb_eval()+1 , x.get_f() );
}
Ejemplo n.º 6
0
// 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;
}