当前位置: 首页>>代码示例>>C++>>正文


C++ Problem::getConfiguration方法代码示例

本文整理汇总了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;
}
开发者ID:akreshuk,项目名称:sopnet,代码行数:43,代码来源:ProblemsReader.cpp

示例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);
}
开发者ID:akreshuk,项目名称:sopnet,代码行数:17,代码来源:ProblemsReader.cpp


注:本文中的Problem::getConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。