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