本文整理汇总了C++中nomad::Double::pow2方法的典型用法代码示例。如果您正苦于以下问题:C++ Double::pow2方法的具体用法?C++ Double::pow2怎么用?C++ Double::pow2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nomad::Double
的用法示例。
在下文中一共展示了Double::pow2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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;
}