本文整理汇总了C++中nomad::Double::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Double::clear方法的具体用法?C++ Double::clear怎么用?C++ Double::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nomad::Double
的用法示例。
在下文中一共展示了Double::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: b
/*---------------------------------------------------------*/
bool NOMAD::Directions::compute_halton_dir ( int halton_index ,
int mesh_index ,
NOMAD::Double & alpha_t_l ,
NOMAD::Direction & halton_dir ) const
{
alpha_t_l.clear();
int i;
NOMAD::Double d , norm = 0.0;
NOMAD::Point b ( _nc );
for ( i = 0 ; i < _nc ; ++i )
{
d = Directions::get_phi ( halton_index , _primes[i] );
b[i] = 2*d - 1.0;
norm += b[i].pow2();
}
norm = norm.sqrt();
// desired squared norm for q:
NOMAD::direction_type hdt = halton_dir.get_type();
NOMAD::Double target = ( hdt == NOMAD::ORTHO_2N || hdt == NOMAD::ORTHO_NP1_QUAD || hdt == NOMAD::ORTHO_NP1_NEG ) ?
pow ( NOMAD::Mesh::get_mesh_update_basis() , abs(mesh_index) / 2.0 ) :
pow ( NOMAD::Mesh::get_mesh_update_basis() , abs(mesh_index) );
NOMAD::Double x = target.sqrt();
NOMAD::Double fx = eval_ortho_norm ( x , norm , b , halton_dir );
NOMAD::Double y = 1.0 , fy , delta_x , abs_dx , min , delta_min , diff , eps;
bool inc , possible , set_eps = false;
int cnt = 0;
while ( fx != target )
{
// safety test:
if ( ++cnt > 1000 )
{
#ifdef DEBUG
_out << std::endl << "Warning (" << "Directions.cpp" << ", " << __LINE__
<< "): could not compute Halton direction for (t="
<< halton_index << ", ell=" << mesh_index
<< ")" << std::endl << std::endl;
#endif
alpha_t_l.clear();
halton_dir.clear();
return false;
}
if ( set_eps )
{
eps = 1e-8;
set_eps = false;
}
else
eps = 0.0;
inc = ( fx < target );
possible = false;
min = 1e+20;
for ( i = 0 ; i < _nc ; ++i )
{
if ( b[i] != 0.0 )
{
if ( b[i] > 0.0 )
{
if ( inc )
diff = 0.5+eps;
else
diff = -0.5-eps;
}
else
{
if ( inc )
diff = -0.5-eps;
else
diff = 0.5+eps;
}
delta_x = norm * ( halton_dir[i] + diff) / b[i] - x;
y = x + delta_x;
if ( y > 0 )
{
abs_dx = delta_x.abs();
if ( abs_dx < min )
{
min = abs_dx;
delta_min = delta_x;
possible = true;
}
}
}
}
//.........这里部分代码省略.........
示例3: Exception
/*----------------------------------------------------------------*/
void NOMAD::TGP_Model::eval_hf(const NOMAD::Point &bbo ,
const NOMAD::Double &h_min ,
NOMAD::hnorm_type h_norm ,
NOMAD::Double &h ,
NOMAD::Double &f) const
{
f.clear();
h = 0.0;
int m = bbo.size();
if (m != static_cast<int>(_bbot.size()))
throw NOMAD::Exception("TGP_Model.cpp" , __LINE__ ,
"TGP_Model::eval_hf() called with an invalid bbo argument");
NOMAD::Double bboi;
for (int i = 0 ; i < m ; ++i)
{
bboi = bbo[i];
if (bboi.is_defined())
{
if (_bbot[i] == NOMAD::EB || _bbot[i] == NOMAD::PEB_E)
{
if (bboi > h_min)
{
h.clear();
return;
}
}
else if ((_bbot[i] == NOMAD::FILTER ||
_bbot[i] == NOMAD::PB ||
_bbot[i] == NOMAD::PEB_P))
{
if (bboi > h_min)
{
switch (h_norm)
{
case NOMAD::L1:
h += bboi;
break;
case NOMAD::L2:
h += bboi * bboi;
break;
case NOMAD::LINF:
if (bboi > h)
h = bboi;
break;
}
}
}
else if (_bbot[i] == NOMAD::OBJ)
f = bboi;
}
}
if (h_norm == NOMAD::L2)
h = h.sqrt();
}