Skip to content

Commit

Permalink
remove or disable unused-but-set variables
Browse files Browse the repository at this point in the history
- from clang 14.0.3 warnings
  • Loading branch information
svigerske committed Jul 4, 2023
1 parent f6ffd96 commit 354c2e4
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 49 deletions.
8 changes: 4 additions & 4 deletions Cbc/src/CbcCutGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface
int nEls = 0;
int nCuts = numberRowCutsAfter - numberRowCutsBefore;
// Remove NULL cuts!
int nNull = 0;
//int nNull = 0;
const double *solution = solver->getColSolution();
bool feasible = true;
double primalTolerance = 1.0e-7;
Expand Down Expand Up @@ -822,7 +822,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface
} else {
sum = 0.0;
cs.eraseRowCut(k);
nNull++;
//nNull++;
}
}
}
Expand Down Expand Up @@ -996,7 +996,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface
}
CoinSort_2(sort, sort + nCuts, which);
// Now see which ones are too similar
int nParallel = 0;
//int nParallel = 0;
double testValue = (depth > 1) ? 0.99 : 0.999999;
for (k = 0; k < nCuts; k++) {
int j = which[k];
Expand Down Expand Up @@ -1048,7 +1048,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface
if (fabs(ub - ubB) > tolerance)
parallel = false;
if (parallel) {
nParallel++;
//nParallel++;
sort[k] = 0.0;
break;
}
Expand Down
4 changes: 4 additions & 0 deletions Cbc/src/CbcFollowOn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,19 @@ int CbcFollowOn::gutsOfFollowOn(int &otherRow, int &preferredWay) const
#endif
for (int k = 0; k < nSort - 1; k++) {
i = sort[k];
#if defined(COUNT) || !defined(NDEBUG)
int numberUnsatisfied = 0;
#endif
int n = 0;
CoinBigIndex j;
for (j = rowStart[i]; j < rowStart[i] + rowLength[i]; j++) {
int iColumn = column[j];
if (columnLower[iColumn] != columnUpper[iColumn]) {
double solValue = solution[iColumn] - columnLower[iColumn];
if (solValue < 1.0 - integerTolerance && solValue > integerTolerance) {
#if defined(COUNT) || !defined(NDEBUG)
numberUnsatisfied++;
#endif
for (CoinBigIndex jj = columnStart[iColumn]; jj < columnStart[iColumn] + columnLength[iColumn]; jj++) {
int iRow = row[jj];
if (rhs_[iRow]) {
Expand Down
14 changes: 14 additions & 0 deletions Cbc/src/CbcHeuristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,9 +1783,11 @@ CbcHeuristicNode::distance(const CbcHeuristicNode *node) const
const double disjointWeight = 1;
const double overlapWeight = 0.4;
const double subsetWeight = 0.2;
#ifdef COIN_DETAIL
int countDisjointWeight = 0;
int countOverlapWeight = 0;
int countSubsetWeight = 0;
#endif
int i = 0;
int j = 0;
double dist = 0.0;
Expand Down Expand Up @@ -1817,11 +1819,15 @@ CbcHeuristicNode::distance(const CbcHeuristicNode *node) const
const int brComp = compare3BranchingObjects(br0, br1);
if (brComp < 0) {
dist += subsetWeight;
#ifdef COIN_DETAIL
countSubsetWeight++;
#endif
++i;
} else if (brComp > 0) {
dist += subsetWeight;
#ifdef COIN_DETAIL
countSubsetWeight++;
#endif
++j;
} else {
const int comp = br0->compareBranchingObject(br1, false);
Expand All @@ -1831,24 +1837,32 @@ CbcHeuristicNode::distance(const CbcHeuristicNode *node) const
break;
case CbcRangeDisjoint: // disjoint decisions
dist += disjointWeight;
#ifdef COIN_DETAIL
countDisjointWeight++;
#endif
break;
case CbcRangeSubset: // subset one way or another
case CbcRangeSuperset:
dist += subsetWeight;
#ifdef COIN_DETAIL
countSubsetWeight++;
#endif
break;
case CbcRangeOverlap: // overlap
dist += overlapWeight;
#ifdef COIN_DETAIL
countOverlapWeight++;
#endif
break;
}
++i;
++j;
}
}
dist += subsetWeight * (numObjects_ - i + node->numObjects_ - j);
#ifdef COIN_DETAIL
countSubsetWeight += (numObjects_ - i + node->numObjects_ - j);
#endif
COIN_DETAIL_PRINT(printf("subset = %i, overlap = %i, disjoint = %i\n", countSubsetWeight,
countOverlapWeight, countDisjointWeight));
return dist;
Expand Down
12 changes: 11 additions & 1 deletion Cbc/src/CbcHeuristicDive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes,

int iteration = 0;
int numberAtBoundFixed = 0;
int numberGeneralFixed = 0; // fixed as satisfied but not at bound
#if DIVE_PRINT > 1
int numberGeneralFixed = 0; // fixed as satisfied but not at bound
int numberReducedCostFixed = 0;
#endif
while (numberFractionalVariables) {
Expand Down Expand Up @@ -511,7 +511,9 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes,
#endif

numberAtBoundFixed = 0;
#if DIVE_PRINT > 1
numberGeneralFixed = 0; // fixed as satisfied but not at bound
#endif
#ifdef DIVE_FIX_BINARY_VARIABLES
// fix binary variables based on pseudo reduced cost
if (binVarIndex_.size()) {
Expand Down Expand Up @@ -702,7 +704,9 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes,
solver->setColUpper(iColumn, lower[iColumn]);
} else {
// fix to interior value
#if DIVE_PRINT > 1
numberGeneralFixed++;
#endif
double fixValue = floor(value + 0.5);
columnFixed[numberAtBoundFixed] = iColumn;
originalBound[numberAtBoundFixed] = upper[iColumn];
Expand Down Expand Up @@ -1518,14 +1522,18 @@ int CbcHeuristicDive::fixOtherVariables(OsiSolverInterface *solver,
}
int nOverGap = 0;
#endif
#ifdef CLP_INVESTIGATE4
int numberFree = 0;
int numberFixedAlready = 0;
#endif
for (int i = 0; i < numberIntegers; i++) {
int iColumn = integerVariable[i];
if (!isHeuristicInteger(solver, iColumn))
continue;
if (upper[iColumn] > lower[iColumn]) {
#ifdef CLP_INVESTIGATE4
numberFree++;
#endif
double value = solution[iColumn];
if (fabs(floor(value + 0.5) - value) <= integerTolerance) {
candidate[cnt].var = iColumn;
Expand All @@ -1536,7 +1544,9 @@ int CbcHeuristicDive::fixOtherVariables(OsiSolverInterface *solver,
#endif
}
} else {
#ifdef CLP_INVESTIGATE4
numberFixedAlready++;
#endif
}
}
#ifdef GAP
Expand Down
6 changes: 6 additions & 0 deletions Cbc/src/CbcHeuristicDivePseudoCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,18 @@ int CbcHeuristicDivePseudoCost::fixOtherVariables(OsiSolverInterface *solver,
bool fixGeneralIntegers = (switches_ & 65536) != 0;
// fix other integer variables that are at their bounds
int cnt = 0;
#ifdef CLP_INVESTIGATE
int numberFree = 0;
int numberFixedAlready = 0;
#endif
for (int i = 0; i < numberIntegers; i++) {
int iColumn = integerVariable[i];
if (!isHeuristicInteger(solver, iColumn))
continue;
if (upper[iColumn] > lower[iColumn]) {
#ifdef CLP_INVESTIGATE
numberFree++;
#endif
double value = solution[iColumn];
if (value - lower[iColumn] <= integerTolerance) {
candidate[cnt].var = iColumn;
Expand All @@ -235,7 +239,9 @@ int CbcHeuristicDivePseudoCost::fixOtherVariables(OsiSolverInterface *solver,
* random[i];
}
} else {
#ifdef CLP_INVESTIGATE
numberFixedAlready++;
#endif
}
}
#ifdef CLP_INVESTIGATE
Expand Down
10 changes: 7 additions & 3 deletions Cbc/src/CbcHeuristicFPump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,9 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
if (matched)
break;
}
#ifdef COIN_DEVELOP
int numberPerturbed = 0;
#endif
if (matched || numberPasses % 100 == 0) {
// perturbation
//sprintf(pumpPrint+strlen(pumpPrint)," perturbation applied");
Expand Down Expand Up @@ -1161,7 +1163,9 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
double value = randomX[i];
double difference = fabs(solution[iColumn] - newSolution[iColumn]);
if (difference + value * factor > 0.5) {
#ifdef COIN_DEVELOP
numberPerturbed++;
#endif
if (newSolution[iColumn] < lower[iColumn] + primalTolerance) {
newSolution[iColumn] += 1.0;
} else if (newSolution[iColumn] > upper[iColumn] - primalTolerance) {
Expand Down Expand Up @@ -2878,24 +2882,24 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution,
double largestInfeasibility = primalTolerance;
#ifdef JJF_ZERO
double sumInfeasibility = 0.0;
#endif
int numberBadRows = 0;
#endif
for (i = 0; i < numberRows; i++) {
double value;
value = rowLower[i] - rowActivity[i];
if (value > primalTolerance) {
numberBadRows++;
largestInfeasibility = CoinMax(largestInfeasibility, value);
#ifdef JJF_ZERO
sumInfeasibility += value;
numberBadRows++;
#endif
}
value = rowActivity[i] - rowUpper[i];
if (value > primalTolerance) {
numberBadRows++;
largestInfeasibility = CoinMax(largestInfeasibility, value);
#ifdef JJF_ZERO
sumInfeasibility += value;
numberBadRows++;
#endif
}
}
Expand Down
18 changes: 14 additions & 4 deletions Cbc/src/CbcHeuristicGreedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ int CbcHeuristicGreedyCover::solution(double &solutionValue,
// use current upper or original upper
if (value + 0.99 < originalUpper[iColumn]) {
double sum = 0.0;
int numberExact = 0;
//int numberExact = 0;
for (j = columnStart[iColumn];
j < columnStart[iColumn] + columnLength[iColumn]; j++) {
int iRow = row[j];
double gap = rowLower[iRow] - rowActivity[iRow];
double elementValue = allOnes ? 1.0 : element[j];
if (gap > 1.0e-7) {
sum += CoinMin(elementValue, gap);
if (fabs(elementValue - gap) < 1.0e-7)
numberExact++;
//if (fabs(elementValue - gap) < 1.0e-7)
// numberExact++;
}
}
// could bias if exact
Expand Down Expand Up @@ -1259,7 +1259,10 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
CoinSort_2(contribution, contribution + numberColumns, which);
// Go through columns
int nAdded = 0;
//#define REPORT 1
#ifdef REPORT
int nSlacks = 0;
#endif
for (int jColumn = 0; jColumn < numberColumns; jColumn++) {
if (contribution[jColumn] >= 1.0e30)
break;
Expand All @@ -1281,7 +1284,6 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
}
}
if (possible) {
//#define REPORT 1
#ifdef REPORT
if ((nAdded % 1000) == 0) {
double gap = 0.0;
Expand All @@ -1295,8 +1297,10 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
}
#endif
nAdded++;
#ifdef REPORT
if (columnLength[iColumn] == 1)
nSlacks++;
#endif
// Increase chosen column
newSolution[iColumn] = 1.0;
double cost = modifiedCost[iColumn];
Expand Down Expand Up @@ -1375,8 +1379,10 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
// get list of columns which can go down without making
// things much worse
int nPossible = 0;
#ifdef REPORT
int nEasyDown = 0;
int nSlackDown = 0;
#endif
for (int iColumn = 0; iColumn < numberColumns; iColumn++) {
if (newSolution[iColumn] && columnUpper[iColumn] > columnLower[iColumn]) {
bool canGoDown = true;
Expand Down Expand Up @@ -1429,12 +1435,14 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
int iRow = row[j];
rowActivity[iRow] += element[j];
}
#ifdef REPORT
nEasyDown++;
if (columnLength[iColumn] > 1) {
//printf("%d is easy down\n",iColumn);
} else {
nSlackDown++;
}
#endif
}
} else if (modifiedCost[iColumn] > 0.0) {
// easy down
Expand All @@ -1446,7 +1454,9 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
int iRow = row[j];
rowActivity[iRow] -= element[j];
}
#ifdef REPORT
nEasyDown++;
#endif
}
} else {
which[nPossible++] = iColumn;
Expand Down
Loading

0 comments on commit 354c2e4

Please sign in to comment.