当前位置: 首页>>代码示例>>C++>>正文


C++ Eval_Point::get_bb_outputs方法代码示例

本文整理汇总了C++中nomad::Eval_Point::get_bb_outputs方法的典型用法代码示例。如果您正苦于以下问题:C++ Eval_Point::get_bb_outputs方法的具体用法?C++ Eval_Point::get_bb_outputs怎么用?C++ Eval_Point::get_bb_outputs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nomad::Eval_Point的用法示例。


在下文中一共展示了Eval_Point::get_bb_outputs方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Exception

/*------------------------------------------------------------------*/
void NOMAD::Phase_One_Evaluator::compute_f(NOMAD::Eval_Point &x) const
{
    if (x.get_bb_outputs().size() != _p.get_bb_nb_outputs())
    {
        std::ostringstream err;
        err << "Phase_One_Evaluator::compute_f(x): "
            << "x has a wrong number of blackbox outputs ("
            << x.get_bb_outputs().size() <<  " != " << _p.get_bb_nb_outputs() << ")";
        throw NOMAD::Exception("Phase_One_Evaluator.cpp" , __LINE__ , err.str());
    }

    // objective value for MADS phase 1: the squared sum of all EB constraint violations
    // (each EB constraint has been previously transformed into OBJ values):
    const std::list<int>                &index_obj = _p.get_index_obj();
    const std::list<int>::const_iterator end       = index_obj.end();
    const NOMAD::Point                  &bbo       = x.get_bb_outputs();
    NOMAD::Double                        h_min     = _p.get_h_min();
    NOMAD::Double                        sum       = 0.0;
    NOMAD::Double                        v;

    for (std::list<int>::const_iterator it = index_obj.begin() ; it != end ; ++it)
    {
        v = bbo[*it];
        if (v > h_min)
            sum += v.pow2();
    }

    x.set_f(sum);
}
开发者ID:TheLoutre,项目名称:nomad,代码行数:30,代码来源:Phase_One_Evaluator.cpp

示例2: Exception

/*--------------------------------------------------------*/
void NOMAD::Evaluator::compute_h ( NOMAD::Eval_Point & x ) const
{
  if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) {
    std::ostringstream err;
    err << "Evaluator::compute_h(x): x has a wrong number of blackbox outputs ("
	<< x.get_bb_outputs().size() << " != "
	<< _p.get_bb_nb_outputs() << ")";
    throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err.str() );
  }

  int                                        nbo  = _p.get_bb_nb_outputs();
  const std::vector<NOMAD::bb_output_type> & bbot = _p.get_bb_output_type();
  const NOMAD::Point                       & bbo  = x.get_bb_outputs();
  NOMAD::Double                              h    = 0.0 , bboi;

  x.set_EB_ok ( true );

  for ( int i = 0 ; i < nbo ; ++i ) {

    bboi = bbo[i];

    if ( bboi.is_defined()                                  &&
	 (bbot[i] == NOMAD::EB || bbot[i] == NOMAD::PEB_E ) &&
	 bboi > _p.get_h_min() ) {
      h.clear();
      x.set_h     ( h     );
      x.set_EB_ok ( false );
      return;
    }
    
    if ( bboi.is_defined() &&
	 ( bbot[i] == NOMAD::FILTER ||
	   bbot[i] == NOMAD::PB     ||
	   bbot[i] == NOMAD::PEB_P     ) ) {
      if ( bboi > _p.get_h_min() ) {
	switch ( _p.get_h_norm() ) {
	case NOMAD::L1:
	  h += bboi;
	  break;
	case NOMAD::L2:
	  h += bboi * bboi;
	  break;
	case NOMAD::LINF:
	  if ( bboi > h )
	    h = bboi;
	  break;
	}
      }
    }
  }

  if ( _p.get_h_norm() == NOMAD::L2 )
    h = h.sqrt();

  x.set_h ( h );
}
开发者ID:martinjrobins,项目名称:dakota,代码行数:57,代码来源:Evaluator.cpp

示例3: Exception

 /*--------------------------------------------------------*/
 void NOMAD::Evaluator::compute_f ( NOMAD::Eval_Point & x ) const
 {
     if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) {
         std::ostringstream err;
         err << "Evaluator::compute_f(x): x has a wrong number of blackbox outputs ("
         << x.get_bb_outputs().size() << " != "
         << _p.get_bb_nb_outputs() << ")";
         throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err.str() );
     }
     
     x.set_f ( x.get_bb_outputs()[*(_p.get_index_obj().begin())] );
 }
开发者ID:OpenSolver,项目名称:OpenSolverNomadLib,代码行数:13,代码来源:Evaluator.cpp

示例4: if

 /*-----------------------------------------------------------------------*/
 bool NOMAD::Evaluator::interrupt_evaluations ( const NOMAD::Eval_Point & x     ,
                                               const NOMAD::Double     & h_max   ) const
 {
     int                                        nbo     = _p.get_bb_nb_outputs();
     const NOMAD::Point                       & bbo     = x.get_bb_outputs();
     const std::vector<NOMAD::bb_output_type> & bbot    = _p.get_bb_output_type();
     NOMAD::Double                              h       = 0.0;
     bool                                       check_h = h_max.is_defined();
     
     for ( int i = 0 ; i < nbo ; ++i ) {
         
         if ( bbo[i].is_defined()                                 &&
             ( bbot[i] == NOMAD::EB || bbot[i] == NOMAD::PEB_E ) &&
             bbo[i] > _p.get_h_min() )
             return true;
         
         if ( check_h && bbo[i].is_defined() &&
             (bbot[i] == NOMAD::FILTER ||
              bbot[i] == NOMAD::PB     ||
              bbot[i] == NOMAD::PEB_P     ) ) {
                 
                 if ( bbo[i] > _p.get_h_min() ) {
                     switch ( _p.get_h_norm() ) {
                         case NOMAD::L1:
                             h += bbo[i];
                             break;
                         case NOMAD::L2:
                             h += bbo[i].pow2();
                             break;
                         case NOMAD::LINF:
                             if ( bbo[i] > h )
                                 h = bbo[i];
                             break;
                     }
                     
                     if ( _p.get_h_norm() == NOMAD::L2 ) {
                         if ( h > h_max.pow2() )
                             return true;
                     }
                     else if ( h > h_max )
                         return true;
                 }
             }
     }
     return false;
 }
开发者ID:OpenSolver,项目名称:OpenSolverNomadLib,代码行数:47,代码来源:Evaluator.cpp

示例5:

/*-----------------------------------------------------------------*/
void NOMAD::Cache::update ( NOMAD::Eval_Point       & cache_x ,
                           const NOMAD::Eval_Point & x         ) const
{
    const NOMAD::Point & bbo_x = x.get_bb_outputs();
    
    if ( &cache_x == &x         ||
        !x.is_eval_ok()        ||
        !cache_x.is_in_cache() ||
        bbo_x.empty()          ||
        cache_x != x              )
        return;
    
    // check the eval types:
    if ( x.get_eval_type      () != _eval_type ||
        cache_x.get_eval_type() != _eval_type    )
        throw NOMAD::Cache::Cache_Error ( "Cache.cpp" , __LINE__ ,
                                         "NOMAD::Cache:update(): problem with the eval. types" );
    
    const NOMAD::Point & bbo_cache_x = cache_x.get_bb_outputs();
    int                  m           = bbo_cache_x.size();
    
    _sizeof -= cache_x.size_of();
    
    // if the current point could not evaluate and x did,
    // or if the number of bb outputs is different, we set cache_x = x:
    if ( !cache_x.is_eval_ok() || m != bbo_x.size() )
    {
        cache_x.set_eval_status ( NOMAD::EVAL_OK     );
        cache_x.set_bb_output   ( bbo_x              );
        cache_x.set_signature   ( x.get_signature () );
        cache_x.set_direction   ( x.get_direction () );
        
        _sizeof += cache_x.size_of();
        return;
    }
    
    // we complete _bb_outputs:
    int c1 = 0;
    int c2 = 0;
    
    for ( int i = 0 ; i < m ; ++i ) {
        
        if ( bbo_cache_x[i].is_defined() )
            ++c1;
        
        if ( bbo_x[i].is_defined() )
            ++c2;
        
        if ( !bbo_cache_x[i].is_defined() && bbo_x[i].is_defined() )
            cache_x.set_bb_output ( i , bbo_x[i] );
    }
    
    // the two points are 'eval_ok' and have comparable outputs:
    // we select the best as the one with the more defined bb_outputs:
    if ( c2 > c1 ) {
        cache_x.set_signature  ( x.get_signature () );
        cache_x.set_direction  ( x.get_direction () );
        
    }
    
    _sizeof += cache_x.size_of();
}
开发者ID:OpenSolver,项目名称:OpenSolverNomadLib,代码行数:63,代码来源:Cache.cpp

示例6: switch

/*---------------------------------------------------------------------*/
NOMAD::Cache_File_Point::Cache_File_Point(const NOMAD::Eval_Point &x)
    : _n(x.size()) ,
      _m(0) ,
      _m_def(0) ,
      _coords(NULL) ,
      _bbo_def(NULL) ,
      _bbo_index(NULL)
{
    int i;

    // eval_status:
    switch (x.get_eval_status())
    {
        case NOMAD::EVAL_FAIL:
            _eval_status = 0;
            break;
        case NOMAD::EVAL_OK:
            _eval_status = 1;
            break;
        case NOMAD::EVAL_IN_PROGRESS:
            _eval_status = 2;
            break;
        case NOMAD::UNDEFINED_STATUS:
            _eval_status = 3;
            break;
        case NOMAD::EVAL_USER_REJECT:
            _eval_status = 3;
            break;
    }

    // inputs:
    if (_n > 0)
    {
        _coords = new double [_n];
        for (i = 0 ; i < _n ; ++i)
            _coords[i] = x[i].value();
    }
    else
        _n = 0;

    // outputs:
    const NOMAD::Point &bbo = x.get_bb_outputs();
    _m = bbo.size();
    if (_m > 0)
    {

        std::vector<double> vd;
        std::vector<int>    vi;

        for (i = 0 ; i < _m ; ++i)
            if (bbo[i].is_defined())
            {
                vd.push_back(bbo[i].value());
                vi.push_back(i);
            }

        _m_def = static_cast<int>(vd.size());
        if (_m_def > 0)
        {
            _bbo_def   = new double [_m_def];
            _bbo_index = new int    [_m_def];
            for (i = 0 ; i < _m_def ; ++i)
            {
                _bbo_def  [i] = vd[i];
                _bbo_index[i] = vi[i];
            }
        }
    }
    else
        _m = 0;

#ifdef MEMORY_DEBUG
    ++NOMAD::Cache_File_Point::_cardinality;
    if (NOMAD::Cache_File_Point::_cardinality >
        NOMAD::Cache_File_Point::_max_cardinality)
        ++NOMAD::Cache_File_Point::_max_cardinality;
#endif
}
开发者ID:TheLoutre,项目名称:nomad,代码行数:79,代码来源:Cache_File_Point.cpp

示例7: while

/*--------------------------------------------------------*/
void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool display )
{
    const NOMAD::Double                      & h_min = _p.get_h_min();
    const std::vector<NOMAD::bb_output_type> & bbot  = _p.get_bb_output_type();
    const NOMAD::Point                       & bbo   = x.get_bb_outputs();
    int                                        nb    = static_cast<int>(bbot.size());
    std::list<int>                             ks;
    
    for ( int k = 0 ; k < nb ; ++k )
    {
        if ( bbot[k] == NOMAD::PEB_P && bbo[k] <= h_min )
        {
            if ( display )
                _p.out() << std::endl
                << "change status of blackbox output " << k
                << " from progressive barrier constraint to extreme barrier constraint"
                << std::endl;
            ++_peb_changes;
            _p.change_PEB_constraint_status (k);
            ks.push_back(k);
        }
    }
    
    // at least one constraint changed status, so we have to update the filter
    // and remove all points that have their h value changed to infinity
    // (it can add new dominant points from the list _peb_lop):
    if ( !ks.empty() )
    {
        
        std::list<int>::const_iterator it_k , end_k = ks.end() , begin_k = ks.begin();
        
        // we inspect the filter points if some have to be removed; if so,
        // all filter candidates (stored in _peb_lop) will be re-inserted
        // into the filter:
        bool reset_filter = false;
        std::set<NOMAD::Filter_Point>::const_iterator end = _filter.end() , it;
        
        for ( it = _filter.begin() ; it != end ; ++it )
        {
            
            const NOMAD::Point & bbo_cur = it->get_point()->get_bb_outputs();
            for ( it_k = begin_k ; it_k != end_k ; ++it_k )
                if ( bbo_cur[*it_k] > h_min )
                {
                    reset_filter = true;
                    break;
                }
            if ( reset_filter )
                break;
        }
        
        if ( reset_filter )
        {
            
            if ( display )
                _p.out() << std::endl << "PEB change of status: filter reset" << std::endl;
            
            ++_peb_filter_reset;
            
            _filter.clear();
            bool insert;
            
            std::list<const NOMAD::Eval_Point *>::const_iterator end2 = _peb_lop.end  ();
            std::list<const NOMAD::Eval_Point *>::iterator       it2  = _peb_lop.begin();
            
            while ( it2 != end2 )
            {
                
                insert = true;
                const NOMAD::Point & bbo_cur = (*it2)->get_bb_outputs();
                
                for ( it_k = begin_k ; it_k != end_k ; ++it_k )
                    if ( bbo_cur[*it_k] > h_min )
                    {
                        insert = false;
                        break;
                    }
                
                // if insert==true: this point is potentially a new filter point:
                if ( insert )
                {
                    filter_insertion ( **it2 , insert );
                    ++it2;
                }
                
                // if insert==false: it means that the current filter point
                // has to be removed from filter and from _peb_lop, and
                // in addition, its h is put to INF:
                else
                {
                    
                    NOMAD::Cache::get_modifiable_point ( **it2 ).set_h ( NOMAD::Double() );
                    _peb_lop.erase(it2++);
                }
            }
        }
    }
}
开发者ID:JeffreyRacine,项目名称:R-Package-crs,代码行数:99,代码来源:Barrier.cpp

示例8: Exception

/*-------------------------------------------------------------*/
void NOMAD::Multi_Obj_Evaluator::compute_f ( NOMAD::Eval_Point & x ) const
{
  if ( _i1 < 0 || _i2 < 0 )
    throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ ,
	  "Multi_Obj_Evaluator::compute_f(): no objective indexes defined" );

  int obj_index [2];
  obj_index[0] = _i1;
  obj_index[1] = _i2;

  const NOMAD::Point & bbo = x.get_bb_outputs();

  // a reference is available:
  if ( _ref ) 
  {
      
	  NOMAD::multi_formulation_type mft = _p.get_multi_formulation();
	  
	  if ( mft == NOMAD::UNDEFINED_FORMULATION )
		  throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ ,
								  "Multi_Obj_Evaluator::compute_f(): no formulation type is defined" );
	  
	  // normalized formulation:
	  if ( mft == NOMAD::NORMALIZED || mft == NOMAD::DIST_LINF ) {
		  
		  // f1 - r1:
		  NOMAD::Double d = bbo[obj_index[0]] - (*_ref)[0];
		  
		  // f2 - r2:
		  NOMAD::Double f2mr2 = bbo[obj_index[1]] - (*_ref)[1];
		  
		  // we take the max:
		  if ( f2mr2 > d )
			  d = f2mr2;
		  
		  x.set_f ( d );
	  }
	  
	  // product formulation:
	  else if ( mft == NOMAD::PRODUCT ) {
		  
		  NOMAD::Double prod = 1.0 , ri , fi;
		  
		  for ( int i = 0 ; i < 2 ; ++i ) {
			  
			  ri = (*_ref)[i];
			  fi = bbo[obj_index[i]];
			  
			  if ( fi > ri ) {
				  prod = 0.0;
				  break;
			  }
			  prod = prod * (ri-fi).pow2();
		  }
		  
		  x.set_f ( -prod );
	  }
	  
	  // distance formulation:
	  else {
		  
		  NOMAD::Double d;  
		  NOMAD::Double r1mf1 = (*_ref)[0] - bbo[obj_index[0]];
		  NOMAD::Double r2mf2 = (*_ref)[1] - bbo[obj_index[1]];
		  
		  if ( r1mf1 >= 0.0 && r2mf2 >= 0.0 ) {
			  d = r1mf1.pow2();
			  NOMAD::Double tmp = r2mf2.pow2();
			  if ( tmp < d )
				  d = tmp;
			  d = -d;
		  }
		  else if ( r1mf1 <= 0.0 && r2mf2 <= 0.0 ) {
			  
			  // with L2 norm:
			  if ( mft == NOMAD::DIST_L2 )
				  d = r1mf1.pow2() + r2mf2.pow2();
			  
			  // with L1 norm:
			  else
				  d = (r1mf1.abs() + r2mf2.abs()).pow2();
			  
			  // Linf norm: treated as NORMALIZED
		  }
		  else if ( r1mf1 > 0.0 )
			  d = r2mf2.pow2();
		  else
			  d = r1mf1.pow2();
		  
		  x.set_f ( d );
	  }
  }
    
  // no reference is available (use weights):
  else
    x.set_f ( _w1 * bbo[obj_index[0]] + _w2 * bbo[obj_index[1]] );
}
开发者ID:martinjrobins,项目名称:dakota,代码行数:98,代码来源:Multi_Obj_Evaluator.cpp


注:本文中的nomad::Eval_Point::get_bb_outputs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。