本文整理汇总了C++中nomad::Eval_Point::get_m方法的典型用法代码示例。如果您正苦于以下问题:C++ Eval_Point::get_m方法的具体用法?C++ Eval_Point::get_m怎么用?C++ Eval_Point::get_m使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nomad::Eval_Point
的用法示例。
在下文中一共展示了Eval_Point::get_m方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval_x
bool eval_x ( NOMAD::Eval_Point & x ,
const NOMAD::Double & h_max ,
bool & count_eval ) const {
R_CheckUserInterrupt();
double *x0;
int n = x.get_n();
int m = x.get_m();
x0 = (double *)malloc(sizeof(double)*n);
for(int i=0;i<n;i++)
{
x0[i]=x[i].value();
}
double *ret_value = eval_f(m, n, x0);
for(int i=0;i<m;i++)
x.set_bb_output ( i , ret_value[i] ); // objective value
count_eval = true; // count a black-box evaluation
free(x0);
free(ret_value);
return true; // the evaluation succeeded
}
示例2:
/*--------------------------------------------*/
bool NOMAD::TGP_Model::predict(NOMAD::Eval_Point &x , bool pred_outside_bnds)
{
if (!_error_str.empty())
return false;
if (!_model_computed)
{
_error_str = "NOMAD::TGP_Model::compute() has not been called";
return false;
}
int i , i0 , ix , m = x.get_m() , nx = x.size();
// reset point outputs:
x.set_eval_status(NOMAD::EVAL_FAIL);
for (i = 0 ; i < m ; ++i)
x.set_bb_output(i , NOMAD::Double());
// check dimensions:
if (m != static_cast<int>(_bbot.size()) ||
(nx != _n0 && nx != _n))
{
_error_str = "predict error: bad x dimensions";
return false;
}
double ZZ , * XX = new double[_n];
// set the coordinates and check the bounds:
for (i = 0 ; i < _n ; ++i)
{
ix = (nx == _n0) ? _fv_index[i] : i;
if (!pred_outside_bnds)
{
i0 = _fv_index[i];
if (x[ix] < _lb[i0] || x[ix] > _ub[i0])
{
delete [] XX;
return false; // this is not an error
}
}
XX[i] = x[ix].value();
}
// predictions (one for each output):
for (i = 0 ; i < m ; ++i)
if (_tgp_models[i])
{
if (!_tgp_models[i]->predict(XX ,
_n ,
ZZ ,
_tgp_rect))
{
std::ostringstream oss;
oss << "predict error: problem with model #" << i;
_error_str = oss.str();
break;
}
x.set_bb_output(i , ZZ);
}
delete [] XX;
if (!_error_str.empty())
{
x.set_eval_status(NOMAD::EVAL_FAIL);
return false;
}
x.set_eval_status(NOMAD::EVAL_OK);
return true;
}