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