size_t invasion, part II

This commit is contained in:
Tiago Gomes 2012-05-28 14:01:05 +01:00
parent 4a02997484
commit a9c369aac1
5 changed files with 17 additions and 17 deletions

View File

@ -273,7 +273,7 @@ BpSolver::calculateFactor2VariableMsg (SpLink* link)
unsigned repetitions = 1;
Params msgProduct (msgSize, LogAware::multIdenty());
if (Globals::logDomain) {
for (int i = links.size() - 1; i >= 0; i--) {
for (size_t i = links.size(); i-- > 0; ) {
if (links[i]->getVariable() != dst) {
if (Constants::SHOW_BP_CALCS) {
cout << " message from " << links[i]->getVariable()->label();
@ -291,7 +291,7 @@ BpSolver::calculateFactor2VariableMsg (SpLink* link)
}
}
} else {
for (int i = links.size() - 1; i >= 0; i--) {
for (size_t i = links.size(); i-- > 0; ) {
if (links[i]->getVariable() != dst) {
if (Constants::SHOW_BP_CALCS) {
cout << " message from " << links[i]->getVariable()->label();

View File

@ -214,7 +214,7 @@ CbpSolver::calculateFactor2VariableMsg (SpLink* _link)
unsigned repetitions = 1;
Params msgProduct (msgSize, LogAware::multIdenty());
if (Globals::logDomain) {
for (int i = links.size() - 1; i >= 0; i--) {
for (size_t i = links.size(); i-- > 0; ) {
const CbpSolverLink* cl = static_cast<const CbpSolverLink*> (links[i]);
if ( ! (cl->getVariable() == dst && cl->index() == link->index())) {
if (Constants::SHOW_BP_CALCS) {
@ -233,7 +233,7 @@ CbpSolver::calculateFactor2VariableMsg (SpLink* _link)
}
}
} else {
for (int i = links.size() - 1; i >= 0; i--) {
for (size_t i = links.size(); i-- > 0; ) {
const CbpSolverLink* cl = static_cast<const CbpSolverLink*> (links[i]);
if ( ! (cl->getVariable() == dst && cl->index() == link->index())) {
if (Constants::SHOW_BP_CALCS) {

View File

@ -363,7 +363,7 @@ FactorGraph::exportToLibDaiFormat (const char* fileName) const
for (size_t i = 0; i < facNodes_.size(); i++) {
const VarNodes& factorVars = facNodes_[i]->neighbors();
out << factorVars.size() << endl;
for (int j = factorVars.size() - 1; j >= 0; j--) {
for (size_t j = factorVars.size(); j-- > 0; ) {
out << factorVars[j]->varId() << " " ;
}
out << endl;

View File

@ -322,10 +322,10 @@ runLiftedSolver (void)
}
YAP_Term list = YAP_TermNil();
for (int i = results.size() - 1; i >= 0; i--) {
for (size_t i = results.size(); i-- > 0; ) {
const Params& beliefs = results[i];
YAP_Term queryBeliefsL = YAP_TermNil();
for (int j = beliefs.size() - 1; j >= 0; j--) {
for (size_t j = beliefs.size(); j-- > 0; ) {
YAP_Int sl1 = YAP_InitSlot (list);
YAP_Term belief = YAP_MkFloatTerm (beliefs[j]);
queryBeliefsL = YAP_MkPairTerm (belief, queryBeliefsL);
@ -359,10 +359,10 @@ runGroundSolver (void)
}
YAP_Term list = YAP_TermNil();
for (int i = results.size() - 1; i >= 0; i--) {
for (size_t i = results.size(); i-- > 0; ) {
const Params& beliefs = results[i];
YAP_Term queryBeliefsL = YAP_TermNil();
for (int j = beliefs.size() - 1; j >= 0; j--) {
for (size_t j = beliefs.size(); j-- > 0; ) {
YAP_Int sl1 = YAP_InitSlot (list);
YAP_Term belief = YAP_MkFloatTerm (beliefs[j]);
queryBeliefsL = YAP_MkPairTerm (belief, queryBeliefsL);

View File

@ -633,10 +633,10 @@ Parfactor::expandPotential (
params_.clear();
params_.reserve (newSize);
unsigned prod = 1;
vector<unsigned> offsets_ (ranges_.size());
for (int i = ranges_.size() - 1; i >= 0; i--) {
offsets_[i] = prod;
size_t prod = 1;
vector<size_t> offsets (ranges_.size());
for (size_t i = ranges_.size(); i-- > 0; ) {
offsets[i] = prod;
prod *= ranges_[i];
}
@ -651,19 +651,19 @@ Parfactor::expandPotential (
if (i == fIdx) {
if (indices[i] != ranges_[i]) {
int diff = sumIndexes[indices[i]] - sumIndexes[indices[i] - 1];
index += diff * offsets_[i];
index += diff * offsets[i];
break;
} else {
// last index contains the old range minus 1
index -= sumIndexes.back() * offsets_[i];
index -= sumIndexes.back() * offsets[i];
indices[i] = 0;
}
} else {
if (indices[i] != ranges_[i]) {
index += offsets_[i];
index += offsets[i];
break;
} else {
index -= (ranges_[i] - 1) * offsets_[i];
index -= (ranges_[i] - 1) * offsets[i];
indices[i] = 0;
}
}