本文整理汇总了C++中nomad::Double::is_defined方法的典型用法代码示例。如果您正苦于以下问题:C++ Double::is_defined方法的具体用法?C++ Double::is_defined怎么用?C++ Double::is_defined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nomad::Double
的用法示例。
在下文中一共展示了Double::is_defined方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*-----------------------------------------------*/
int NOMAD::Priority_Eval_Point::compare_hf_values ( const NOMAD::Double & hx1 ,
const NOMAD::Double & fx1 ,
const NOMAD::Double & hx2 ,
const NOMAD::Double & fx2 ) const
{
if ( fx1.is_defined() && fx2.is_defined() )
{
if ( hx1.is_defined() && hx2.is_defined() )
{
// x1 is feasible:
if ( hx1 <= _h_min )
{
// both points are feasible:
if ( hx2 <= _h_min )
{
if ( fx1 < fx2 )
return 1;
if ( fx2 < fx1 )
return -1;
}
// x1 feasible and x2 infeasible:
else
return 1;
}
// x1 is infeasible:
else
{
// x2 is feasible:
if ( hx2 <= _h_min )
return -1;
// both points are infeasible:
if ( ( hx1 < hx2 && fx1 < fx2 ) ||
( hx1 == hx2 && fx1 < fx2 ) ||
( hx1 < hx2 && fx1 == fx2 ) )
return 1;
if ( ( hx2 < hx1 && fx2 < fx1 ) ||
( hx2 == hx1 && fx2 < fx1 ) ||
( hx2 < hx1 && fx2 == fx1 ) )
return -1;
}
}
// we only have f values:
else
{
if ( fx1 < fx2 )
return 1;
if ( fx2 < fx1 )
return -1;
}
}
return 0;
}
示例2:
/*---------------------------------------------------------*/
void NOMAD::TGP_Model::get_Ds2x_points(std::set<int> &pts_indexes) const
{
pts_indexes.clear();
if (!_Ds2x || _n_XX == 0)
return;
int i , j , k , m = _bbot.size();
for (i = 0 ; i < m ; ++i)
if (_Ds2x[i])
{
NOMAD::Double max;
k = -1;
for (j = 0 ; j < _n_XX ; ++j)
if (!max.is_defined() || _Ds2x[i][j] > max)
{
max = _Ds2x[i][j];
k = j;
}
if (k >= 0)
pts_indexes.insert(k);
}
}
示例3: 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;
}
示例4: rp
/*-----------------------------------------------------------*/
void NOMAD::LH_Search::values_for_var_i ( int p ,
const NOMAD::Double & delta ,
const NOMAD::Double & delta_max ,
const NOMAD::bb_input_type & bbit ,
const NOMAD::Double & lb ,
const NOMAD::Double & ub ,
NOMAD::Point & x ) const
{
// categorical variables have already been treated as fixed variables:
if ( bbit == NOMAD::CATEGORICAL )
return;
int i;
NOMAD::Double v;
NOMAD::Random_Pickup rp (p);
bool rounding = ( bbit != NOMAD::CONTINUOUS );
bool lb_def = lb.is_defined();
bool ub_def = ub.is_defined();
double w = ( ( lb_def && ub_def ) ?
ub.value()-lb.value() : 1.0 ) / p;
// main loop:
for ( i = 0 ; i < p ; ++i )
{
// both bounds exist:
if ( lb_def && ub_def )
v = lb + ( i + NOMAD::RNG::rand()/NOMAD::D_INT_MAX ) * w;
// one of the bounds does not exist:
else
{
// lb exists, and ub not: mapping [0;1] --> [lb;+INF[
if ( lb_def )
v = lb + 10 * delta_max * sqrt ( - log ( NOMAD::DEFAULT_EPSILON +
( i + NOMAD::RNG::rand()/NOMAD::D_INT_MAX ) * w ) );
// lb does not exist:
else
{
// ub exists, and lb not: mapping [0;1] --> ]-INF;ub]
if ( ub_def )
v = ub - delta_max * 10 *
sqrt ( -log ( NOMAD::DEFAULT_EPSILON +
( i +NOMAD::RNG::rand()/NOMAD::D_INT_MAX ) * w ) );
// there are no bounds: mapping [0;1] --> ]-INF;+INF[
else
v = (NOMAD::RNG::rand()%2 ? -1.0 : 1.0) * delta_max * 10 *
sqrt ( - log ( NOMAD::DEFAULT_EPSILON +
( i + NOMAD::RNG::rand()/NOMAD::D_INT_MAX ) * w ) );
}
}
// rounding:
if ( rounding )
v = v.round();
// projection to mesh (with ref=0):
v.project_to_mesh ( 0.0 , delta , lb , ub );
// affectation + permutation:
x[rp.pickup()] = v;
}
}
示例5: if
/*--------------------------------------------------*/
bool NOMAD::Eval_Point::check(int m , NOMAD::check_failed_type &cf) const
{
if (size() <= 0 || !_signature || m != _bb_outputs.size())
{
std::string err = "Eval_Point::check() could not procede";
if (!_signature)
err += " (no signature)";
else if (m != _bb_outputs.size())
err += " (wrong number of blackbox outputs)";
else
err += " (point size <= 0 !)";
throw NOMAD::Exception("Eval_Point.cpp" , __LINE__ , err);
}
cf = NOMAD::CHECK_OK;
const std::vector<NOMAD::bb_input_type>
&input_types = _signature->get_input_types();
const NOMAD::Point &lb = _signature->get_lb();
const NOMAD::Point &ub = _signature->get_ub();
const NOMAD::Point &fv = _signature->get_fixed_variables();
int n = size();
NOMAD::bb_input_type iti;
for (int i = 0 ; i < n ; ++i)
{
const NOMAD::Double xi = (*this)[i];
// undefined coordinates ?
if (!xi.is_defined())
throw NOMAD::Exception("Eval_Point.cpp" , __LINE__ ,
"Eval_Point::check() could not procede (undefined coordinates)");
// check the bounds:
const NOMAD::Double &lbi = lb[i];
if (lbi.is_defined() && xi < lbi)
{
cf = NOMAD::LB_FAIL;
return false;
}
const NOMAD::Double &ubi = ub[i];
if (ubi.is_defined() && xi > ubi)
{
cf = NOMAD::UB_FAIL;
return false;
}
// check the integer/categorical/binary variables:
iti = input_types[i];
if (iti == NOMAD::BINARY && !xi.is_binary())
{
cf = NOMAD::BIN_FAIL;
return false;
}
if ((iti == NOMAD::INTEGER || iti == NOMAD::CATEGORICAL)
&& !xi.is_integer())
{
cf = (iti == NOMAD::INTEGER) ? NOMAD::INT_FAIL : NOMAD::CAT_FAIL;
return false;
}
// check the fixed-variables:
const NOMAD::Double &fvi = fv[i];
if (fvi.is_defined() && fvi != xi)
{
cf = NOMAD::FIX_VAR_FAIL;
return false;
}
}
return true;
}
示例6: Point
/*------------------------------------------------*/
bool NOMAD::Priority_Eval_Point::dominates
( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const
{
if ( this == &x )
return false;
const NOMAD::Eval_Point * x1 = get_element();
const NOMAD::Eval_Point * x2 = x.get_element();
// criterion 0: lexicographic order
if (_lexicographic_order)
return NOMAD::Point(*x1) < NOMAD::Point(*x2);
// criterion 1: user criterion:
// ------------
const NOMAD::Double uep1 = x1->get_user_eval_priority();
if ( uep1.is_defined() )
{
const NOMAD::Double uep2 = x2->get_user_eval_priority();
if ( uep2.is_defined() )
{
if ( uep1 > uep2 )
return true;
if ( uep2 > uep1 )
return false;
}
}
// specific Priority_Eval_Point elements of comparison:
NOMAD::Double x_f_sgte;
NOMAD::Double x_h_sgte;
NOMAD::Double x_f_model;
NOMAD::Double x_h_model;
NOMAD::Double x_angle_success_dir;
NOMAD::Double x_angle_simplex_grad;
x.get_priority_criteria ( x_f_sgte ,
x_h_sgte ,
x_f_model ,
x_h_model ,
x_angle_success_dir ,
x_angle_simplex_grad );
// criterion 2: give priority to already evaluated cache points:
// ------------
if ( x1->is_in_cache() && !x2->is_in_cache() )
return true;
if ( x2->is_in_cache() && !x1->is_in_cache() )
return false;
// criterion 3: give priority to already evaluated points
// ------------ that are eval_ok:
if ( x1->is_eval_ok() && !x2->is_eval_ok() )
return true;
if ( x2->is_eval_ok() && !x1->is_eval_ok() )
return false;
// criterion 4: true f and h values:
// -----------
int flag = compare_hf_values ( x1->get_h() ,
x1->get_f() ,
x2->get_h() ,
x2->get_f() );
if ( flag )
return ( flag > 0 );
// criterion 5: surrogate f and h values:
// ------------
flag = compare_hf_values ( _h_sgte , _f_sgte , x_h_sgte , x_f_sgte );
if ( flag )
return ( flag > 0 );
// criterion 6: model f and h values:
// ------------
flag = compare_hf_values ( _h_model , _f_model , x_h_model , x_f_model );
if ( flag )
return ( flag > 0 );
// criterion 7: check the angle with the last successful direction:
// ------------
if ( _angle_success_dir.is_defined() && x_angle_success_dir.is_defined() )
{
if ( _angle_success_dir < x_angle_success_dir )
return true;
if ( x_angle_success_dir < _angle_success_dir )
return false;
}
// criterion 8: take the point with the best h value:
// ------------
flag = compare_h_values ( x1->get_h() , x2->get_h() );
if ( flag )
return ( flag > 0 );
flag = compare_h_values ( _h_sgte , x_h_sgte );
if ( flag )
//.........这里部分代码省略.........
示例7: 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();
}
示例8: Exception
//.........这里部分代码省略.........
// the evaluation:
{
int signal = system ( cmd.c_str() );
// catch the ctrl-c signal:
if ( signal == SIGINT )
raise ( SIGINT );
// other evaluation error:
failed = ( signal != 0 );
}
// the evaluation failed (we stop the evaluations):
if ( failed )
{
it_count=list_count_eval.begin();
for (it=it_begin;it!=it_end;++it,++it_count)
{
(*it)->set_eval_status ( NOMAD::EVAL_FAIL );
(*it_count)=true; //
}
break;
}
// reading of the blackbox output file:
// ------------------------------------
else
{
// bb-output file reading:
fin.open ( bb_output_file_name.c_str() );
string s;
bool is_defined,is_inf;
bool list_all_failed_eval=true;
bool list_all_interrupt=true;
// loop on the points
it_count=list_count_eval.begin();
for (it=it_begin;it!=it_end;++it,++it_count)
{
failed = false;
is_defined = true;
is_inf = false;
// loop on the number of outputs for this blackbox:
nbbok = _bb_nbo[k];
ibbo=0;
for ( j = 0 ; j < nbbok ; ++j )
{
fin >> s;
if ( fin.fail() )
{
failed = true;
break;
}
toupper(s);
if (s.compare("REJECT")==0)
{
*it_count=false; // Rejected points are not counted
(*it)->set_eval_status(NOMAD::EVAL_USER_REJECT);
break;