本文整理汇总了C++中Problem::getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C++ Problem::getConfiguration方法的具体用法?C++ Problem::getConfiguration怎么用?C++ Problem::getConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem
的用法示例。
在下文中一共展示了Problem::getConfiguration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
ProblemsReader::readConstraint(Problem& problem, unsigned int /*i*/) {
LinearConstraint constraint;
double value;
char rel[2];
unsigned int numVariables;
*_stream >> value >> rel >> numVariables;
Relation relation;
if (rel[0] == '<')
relation = GreaterEqual; // switch relation, since in file: value rel term
else if (rel[0] == '>')
relation = LessEqual; // switch relation, since in file: value rel term
else
relation = Equal;
constraint.setRelation(relation);
constraint.setValue(value);
for (unsigned int j = 0; j < numVariables; j++) {
int id;
*_stream >> id;
if (id >= 0) {
unsigned int varNum = problem.getConfiguration()->getVariable(id);
constraint.setCoefficient(varNum, 1.0);
} else {
unsigned int varNum = problem.getConfiguration()->getVariable(-id);
constraint.setCoefficient(varNum, -1.0);
}
}
problem.getLinearConstraints()->add(constraint);
LOG_ALL(streamproblemreaderlog) << "found constraint " << constraint << std::endl;
}
示例2:
void
ProblemsReader::readVariable(Problem& problem, unsigned int i) {
unsigned int id;
float costs;
*_stream >> id;
*_stream >> costs;
LOG_ALL(streamproblemreaderlog) << "found variable " << i << " (id " << id << ") with costs " << costs << std::endl;
// set costs in objective
problem.getObjective()->setCoefficient(i, costs);
// remember mapping from id to variable num
problem.getConfiguration()->setVariable(id, i);
}