本文整理汇总了C++中Case::numberOfConstraints方法的典型用法代码示例。如果您正苦于以下问题:C++ Case::numberOfConstraints方法的具体用法?C++ Case::numberOfConstraints怎么用?C++ Case::numberOfConstraints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Case
的用法示例。
在下文中一共展示了Case::numberOfConstraints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval_x
//-----------------------------------------------------------------------------------------------
// evaluates the model
//-----------------------------------------------------------------------------------------------
bool LshNomadEvaluator::eval_x(NOMAD::Eval_Point &x, const NOMAD::Double &h_max, bool &count_eval) const
{
// generating a case from the evaluation point
Case *c = generateCase(x);
CaseQueue *cq = new CaseQueue();
cq->push_back(c);
// sending the case off for evaluation
p_optimizer->sendCasesToOptimizer(cq);
///p_optimizer->runCase(c);
// extracting the objective
x.set_bb_output(0, -c->objectiveValue());
// extracting the constraint values
// the constraints in NOMAD must be on the form: c <= 0
for(int i = 0; i < c->numberOfConstraints(); ++i)
{
double val_input;
double val = c->constraintValue(i);
double max = p_optimizer->runner()->model()->constraints().at(i)->max();
double min = p_optimizer->runner()->model()->constraints().at(i)->min();
if(val > max) val_input = val - max;
else if(val < min) val_input = min - val;
else
{
double u_slack = max - val;
double l_slack = val - min;
val_input = (u_slack > l_slack) ? -u_slack : -l_slack;
}
x.set_bb_output(i+1, val_input);
}
// deleting the case from the heap
delete c;
delete cq;
return true;
}