Commit cde3c8ec authored by Simon de Givry's avatar Simon de Givry
Browse files

[code] cd src ; clang-format-4.0 -i *.hpp *.cpp

parent 45105072
......@@ -67,7 +67,7 @@ void Constraint::projectLB(Cost cost)
wcsp->decreaseLb(cost);
} else {
wcsp->increaseLb(cost); // done before cluster LB because of #CSP (assuming a contradiction will occur here)
}
}
if (wcsp->td) {
if (ToulBar2::verbose >= 2)
cout << " in cluster C" << getCluster() << " (from " << wcsp->td->getCluster(getCluster())->getLb() << " to " << wcsp->td->getCluster(getCluster())->getLb() + cost << ")" << endl;
......
......@@ -1686,7 +1686,8 @@ int _tmain(int argc, TCHAR* argv[])
if (ToulBar2::uai || ToulBar2::uaieval) {
char* tmpPath = new char[strlen(argv[0]) + 1];
strcpy(tmpPath, argv[0]);
if (strcmp(tmpPath,"toulbar2") == 0) strcpy(tmpPath, ".");
if (strcmp(tmpPath, "toulbar2") == 0)
strcpy(tmpPath, ".");
char* tmpFile = new char[strlen(strfile.c_str()) + 1];
strcpy(tmpFile, strfile.c_str());
string filename(tmpPath);
......
......@@ -190,7 +190,8 @@ Cost NaryConstraint::eval(const String& tin, EnumeratedVariable** scope_in)
evalTuple[pos] = tin[i];
}
return eval(evalTuple);
} else return eval(tin);
} else
return eval(tin);
}
Cost NaryConstraint::eval(const String& s)
......@@ -418,10 +419,10 @@ void NaryConstraint::separate(EnumeratedVariable* vx, EnumeratedVariable* vz)
String t(a, '0'), tX(a - 1, '0'), tZ(a - 1, '0');
int index, k;
EnumeratedVariable* var = NULL;
Constraint *existX = NULL;
Constraint *existZ = NULL;
Constraint *naryx = NULL;
Constraint *naryz = NULL;
Constraint* existX = NULL;
Constraint* existZ = NULL;
Constraint* naryx = NULL;
Constraint* naryz = NULL;
EnumeratedVariable* scope_in[a];
EnumeratedVariable* subscopeX[a - 1];
EnumeratedVariable* subscopeZ[a - 1];
......@@ -1329,8 +1330,10 @@ void NaryConstraint::print(ostream& os)
os << "," << conflictWeights[i];
}
}
if (pf) os << " |f| = " << size() << " / " << totaltuples;
else os << " |f| = " << size();
if (pf)
os << " |f| = " << size() << " / " << totaltuples;
else
os << " |f| = " << size();
os << " default_cost: " << default_cost;
os << " arity: " << arity_;
os << " unassigned: " << (int)nonassigned << "/" << unassigned_ << " ";
......
......@@ -1178,12 +1178,12 @@ void WCSP::solution_UAI(Cost res, bool opt)
rewind(ToulBar2::solution_uai_file);
fprintf(ToulBar2::solution_uai_file, "MPE\n");
// ToulBar2::solution_file << "1" << endl; // we assume a single evidence sample
// if (ToulBar2::showSolutions && !ToulBar2::uaieval) {
// cout << "t " << cpuTime() - ToulBar2::startCpuTime << endl;
// cout << "s " << -(Cost2LogProb(res) + ToulBar2::markov_log) << endl;
// cout << numberOfVariables();
// printSolution(cout);
// }
// if (ToulBar2::showSolutions && !ToulBar2::uaieval) {
// cout << "t " << cpuTime() - ToulBar2::startCpuTime << endl;
// cout << "s " << -(Cost2LogProb(res) + ToulBar2::markov_log) << endl;
// cout << numberOfVariables();
// printSolution(cout);
// }
fprintf(ToulBar2::solution_uai_file, "%d ", numberOfVariables());
printSolution(ToulBar2::solution_uai_file);
fprintf(ToulBar2::solution_uai_file, "\n");
......
......@@ -947,7 +947,6 @@ int WCSP::postGlobalConstraint(int* scopeIndex, int arity, string& gcname, istre
return -1;
if (file) {
gc->read(file);
}
gc->init();
return gc->wcspIndex;
......@@ -1373,7 +1372,7 @@ int WCSP::postSupxyc(int xIndex, int yIndex, Value cst, Value delta)
vector<Cost> costs;
for (unsigned int a = 0; a < x->getDomainInitSize(); a++) {
for (unsigned int b = 0; b < y->getDomainInitSize(); b++) {
costs.push_back(max((y->toValue(b) + cst - x->toValue(a) <= delta) ? ((Cost)((y->toValue(b) + cst - x->toValue(a))*ToulBar2::costMultiplier)) : getUb(), MIN_COST));
costs.push_back(max((y->toValue(b) + cst - x->toValue(a) <= delta) ? ((Cost)((y->toValue(b) + cst - x->toValue(a)) * ToulBar2::costMultiplier)) : getUb(), MIN_COST));
}
}
return postBinaryConstraint(xIndex, yIndex, costs);
......@@ -2598,7 +2597,7 @@ void WCSP::propagate()
revise(NULL);
if (ToulBar2::vac)
vac->iniThreshold();
for (vector<GlobalConstraint*>::iterator it = globalconstrs.begin(); it != globalconstrs.end(); it++) {
(*(it))->init();
}
......@@ -2660,7 +2659,12 @@ void WCSP::propagate()
}
}
propagateNC();
if (ToulBar2::LcLevel == LC_EDAC && eac_iter > MAX_EAC_ITER) {EAC1.clear(); cout << "c automatically switch from EDAC to FDAC." << endl; ToulBar2::LcLevel = LC_FDAC; break;} // avoids pathological cases with too many very slow lower bound increase by EAC
if (ToulBar2::LcLevel == LC_EDAC && eac_iter > MAX_EAC_ITER) {
EAC1.clear();
cout << "c automatically switch from EDAC to FDAC." << endl;
ToulBar2::LcLevel = LC_FDAC;
break;
} // avoids pathological cases with too many very slow lower bound increase by EAC
}
} while (!Eliminate.empty());
if (ToulBar2::DEE_) {
......@@ -3015,7 +3019,7 @@ Constraint* WCSP::sum(Constraint* ctr1, Constraint* ctr2)
}
} else if (arityU == 3) {
EnumeratedVariable* z = scopeU[2];
EnumeratedVariable* scopeTernary[3]= {x,y,z};
EnumeratedVariable* scopeTernary[3] = { x, y, z };
String t;
t.resize(3);
for (vxi = 0; vxi < x->getDomainInitSize(); vxi++)
......@@ -3793,9 +3797,9 @@ Cost WCSP::LogProb2Cost(TLogProb p) const
Cost c;
if (res > to_double(MAX_COST / 2)) {
c = (MAX_COST - UNIT_COST) / MEDIUM_COST / MEDIUM_COST / MEDIUM_COST / MEDIUM_COST;
// if (ToulBar2::verbose >= 2) {
// cout << "Warning: converting energy " << -p << " to Top\n";
// }
// if (ToulBar2::verbose >= 2) {
// cout << "Warning: converting energy " << -p << " to Top\n";
// }
} else
c = (Cost)res;
return c;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment