本文整理汇总了C++中nomad::Eval_Point::is_eval_ok方法的典型用法代码示例。如果您正苦于以下问题:C++ Eval_Point::is_eval_ok方法的具体用法?C++ Eval_Point::is_eval_ok怎么用?C++ Eval_Point::is_eval_ok使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nomad::Eval_Point
的用法示例。
在下文中一共展示了Eval_Point::is_eval_ok方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Insert_Error
/*---------------------------------------------------------*/
void NOMAD::Barrier::insert ( const NOMAD::Eval_Point & x )
{
// we compare the eval types (_SGTE_ or _TRUTH_) of x and *this:
if ( x.get_eval_type() != _eval_type )
throw Barrier::Insert_Error ( "Barrier.cpp" , __LINE__ ,
"insertion of an Eval_Point into the bad Barrier object" );
// basic check:
if ( !x.is_eval_ok() )
{
_one_eval_succ = NOMAD::UNSUCCESSFUL;
return;
}
// pre-filter: if tag(x) is already in the pre-filter,
// then return _UNSUCCESSFUL_:
size_t size_before = _prefilter.size();
_prefilter.insert ( x.get_tag() );
if ( _prefilter.size() == size_before )
{
_one_eval_succ = NOMAD::UNSUCCESSFUL;
return;
}
// insertion in _all_inserted:
_all_inserted.push_back ( &x );
// other checks:
const NOMAD::Double & h = x.get_h();
if ( !x.is_EB_ok () ||
!x.get_f().is_defined () ||
!h.is_defined () ||
h.value() > _h_max.value() )
{
_one_eval_succ = NOMAD::UNSUCCESSFUL;
return;
}
// insert_feasible or insert_infeasible:
_one_eval_succ = ( x.is_feasible ( _p.get_h_min() ) ) ?
insert_feasible ( x ) : insert_infeasible(x);
if ( _one_eval_succ > _success )
_success = _one_eval_succ;
}
示例2:
/*-----------------------------------------------------------------*/
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();
}
示例3: Exception
//.........这里部分代码省略.........
int rank;
MPI_Comm_rank ( MPI_COMM_WORLD, &rank);
_p.out() << "command(rank=" << rank
<< ") = \'" << cmd << "\'" << std::endl;
#else
_p.out() << "command=\'" << cmd << "\'" << std::endl;
#endif
#endif
// the evaluation:
{
int signal = system ( cmd.c_str() );
// catch the ctrl-c signal:
if ( signal == SIGINT )
raise ( SIGINT );
// other evaluation error:
failed = ( signal != 0 );
count_eval = true;
}
// the evaluation failed (we stop the evaluations):
if ( failed )
{
x.set_eval_status ( NOMAD::EVAL_FAIL );
break;
}
// reading of the blackbox output file:
// ------------------------------------
else
{
// bb-output file reading:
fin.open ( bb_output_file_name.c_str() );
failed = false;
bool is_defined = true;
bool is_inf = false;
// loop on the number of outputs for this blackbox:
nbbok = _bb_nbo[k];
for ( j = 0 ; j < nbbok ; ++j )
{
fin >> d;
if ( !d.is_defined() )
{
is_defined = false;
break;
}
if ( fin.fail() )
{
failed = true;
break;
}
if ( d.value() >= NOMAD::INF )
{
is_inf = true;
break;
}
x.set_bb_output ( ibbo++ , d );
}
fin.close();
// the evaluation failed:
if ( failed || !is_defined || is_inf )
{
x.set_eval_status ( NOMAD::EVAL_FAIL );
break;
}
// stop the evaluations if h > h_max or if a 'EB' constraint is violated:
if ( k < _bb_exe.size() - 1 && interrupt_evaluations ( x , h_max ) )
break;
}
}
if ( x.get_eval_status() == NOMAD::EVAL_IN_PROGRESS )
x.set_eval_status ( NOMAD::EVAL_OK );
// delete the blackbox input and output files:
// -------------------------------------------
remove ( bb_input_file_name.c_str () );
remove ( bb_output_file_name.c_str() );
// check the CNT_EVAL output:
// --------------------------
int index_cnt_eval = _p.get_index_cnt_eval();
if ( index_cnt_eval >= 0 && x.get_bb_outputs()[index_cnt_eval] == 0.0 )
count_eval = false;
return x.is_eval_ok();
}