本文整理汇总了C++中MIP::sol方法的典型用法代码示例。如果您正苦于以下问题:C++ MIP::sol方法的具体用法?C++ MIP::sol怎么用?C++ MIP::sol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MIP
的用法示例。
在下文中一共展示了MIP::sol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: augmentStructure
void LinearConstraint::augmentStructure(MIP &mip, Cost &cost, int varindex, map<Value, Cost> &delta) {
for (map<Value, Cost>::iterator i = delta.begin(); i != delta.end();i++) {
int var1 = mapvar[varindex][i->first];
mip.objCoeff(var1, mip.objCoeff(var1)-i->second); // update unary cost
if (mip.sol(var1) == 1){ // using this value?
cost -= i->second;
}
}
}
示例2: checkRemoved
void LinearConstraint::checkRemoved(MIP &mip, Cost &cost, vector<int> &rmv) {
pair<Cost, bool> result;
vector<int> cDomain, cDomain2;
//bool deleted = false;
bool flag = false;
for (int i=0;i<arity_;i++) {
cDomain.clear();
getDomainFromMIP(mip, i, cDomain); // getDomain
sort(cDomain.begin(), cDomain.end());
EnumeratedVariable* y = (EnumeratedVariable*)getVar(i);
for (EnumeratedVariable::iterator v = y->begin(); v != y->end();++v) {
vector<int>::iterator it = find(cDomain.begin(), cDomain.end(), *v);
if (it == cDomain.end()) {
cout << "non exist a value ?" << endl;
for (vector<int>::iterator v=cDomain.begin();v != cDomain.end();v++) {
cout << *v << " ";
} cout << endl;
for (EnumeratedVariable::iterator v = y->begin(); v != y->end();++v) {
cout << *v << " ";
} cout << endl;
exit(0);
}
cDomain.erase(it);
//deleted = true;
}
if (!cDomain.empty()) {
cDomain2.clear();
rmv.push_back(i);
for (vector<int>::iterator v=cDomain.begin();v != cDomain.end();v++) {
int var1 = mapvar[i][*v];
if (mip.sol(var1) == 1){ // checking if this value is being used
flag = true;
}
mip.colUpperBound(var1, 0); // removeDomain
}
//deleted = true;
}
}
if (flag){
cost = solveMIP(); // solve
}
}
示例3: sol
virtual int sol(int var1) {
if (solver) return solver->sol(var1);
return 0;
}