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 600f7d1 commit d4272be
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/Attic/CbcSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9348,7 +9348,7 @@ int CbcMain1(int argc, const char *argv[],
int nBadDir = 0;
int nBadPri = 0;
int nBadName = 0;
int nBadLine = 0;
//int nBadLine = 0;
int nLine = 0;
iColumn = -1;
int lowestPriority = -COIN_INT_MAX;
Expand Down Expand Up @@ -9392,7 +9392,7 @@ int CbcMain1(int argc, const char *argv[],
if (comma) {
*comma = '\0';
} else if (i < nAcross - 1) {
nBadLine++;
//nBadLine++;
break;
}
switch (order[i]) {
Expand Down
8 changes: 4 additions & 4 deletions src/CbcCutGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,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 @@ -1058,7 +1058,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface
} else {
sum = 0.0;
cs.eraseRowCut(k);
nNull++;
//nNull++;
}
}
}
Expand Down Expand Up @@ -1232,7 +1232,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 @@ -1284,7 +1284,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 src/CbcFollowOn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,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 src/CbcHeuristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,9 +1822,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 @@ -1856,11 +1858,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 @@ -1870,24 +1876,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: 12 additions & 0 deletions src/CbcHeuristicDive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes,

int iteration = 0;
int numberAtBoundFixed = 0;
#if DIVE_PRINT > 1
int numberGeneralFixed = 0; // fixed as satisfied but not at bound
#endif
int numberReducedCostFixed = 0;
while (numberFractionalVariables) {
iteration++;
Expand Down Expand Up @@ -512,7 +514,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 @@ -703,7 +707,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 @@ -1519,14 +1525,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 @@ -1537,7 +1547,9 @@ int CbcHeuristicDive::fixOtherVariables(OsiSolverInterface *solver,
#endif
}
} else {
#ifdef CLP_INVESTIGATE4
numberFixedAlready++;
#endif
}
}
#ifdef GAP
Expand Down
6 changes: 6 additions & 0 deletions src/CbcHeuristicDivePseudoCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,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 @@ -234,7 +238,9 @@ int CbcHeuristicDivePseudoCost::fixOtherVariables(OsiSolverInterface *solver,
* random[i];
}
} else {
#ifdef CLP_INVESTIGATE
numberFixedAlready++;
#endif
}
}
#ifdef CLP_INVESTIGATE
Expand Down
18 changes: 14 additions & 4 deletions src/CbcHeuristicGreedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,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 @@ -1258,7 +1258,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 @@ -1280,7 +1283,6 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
}
}
if (possible) {
//#define REPORT 1
#ifdef REPORT
if ((nAdded % 1000) == 0) {
double gap = 0.0;
Expand All @@ -1294,8 +1296,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 @@ -1374,8 +1378,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 @@ -1428,12 +1434,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 @@ -1445,7 +1453,9 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue,
int iRow = row[j];
rowActivity[iRow] -= element[j];
}
#ifdef REPORT
nEasyDown++;
#endif
}
} else {
which[nPossible++] = iColumn;
Expand Down
18 changes: 18 additions & 0 deletions src/CbcHeuristicRENS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,10 @@ int CbcHeuristicRENS::solution(double &solutionValue,
solver->getDblParam(OsiPrimalTolerance, primalTolerance);

int i;
#ifdef CLP_INVESTIGATE2
int numberTightened = 0;
int numberAtBound = 0;
#endif
int numberContinuous = numberColumns - numberIntegers;
/*
0 - allow fixing
Expand Down Expand Up @@ -783,13 +785,19 @@ int CbcHeuristicRENS::solution(double &solutionValue,
if (dontFix) {
continue;
}
#ifdef CLP_INVESTIGATE2
if (value == lower || value == upper)
numberAtBound++;
#endif
newSolver->setColLower(iColumn, value);
newSolver->setColUpper(iColumn, value);
#ifdef CLP_INVESTIGATE2
numberFixed++;
#endif
} else if (colUpper[iColumn] - colLower[iColumn] >= 2.0) {
#ifdef CLP_INVESTIGATE2
numberTightened++;
#endif
newSolver->setColLower(iColumn, floor(value));
newSolver->setColUpper(iColumn, ceil(value));
}
Expand All @@ -799,7 +807,9 @@ int CbcHeuristicRENS::solution(double &solutionValue,
continue;
}
value = floor(value + 0.5);
#ifdef CLP_INVESTIGATE2
numberAtBound++;
#endif
newSolver->setColLower(iColumn, value);
newSolver->setColUpper(iColumn, value);
numberFixed++;
Expand All @@ -808,12 +818,16 @@ int CbcHeuristicRENS::solution(double &solutionValue,
if (dontFix) {
continue;
}
#ifdef CLP_INVESTIGATE2
numberAtBound++;
#endif
newSolver->setColLower(iColumn, value);
newSolver->setColUpper(iColumn, value);
numberFixed++;
} else if (colUpper[iColumn] - colLower[iColumn] >= 2.0 && djTolerance < 0.0) {
#ifdef CLP_INVESTIGATE2
numberTightened++;
#endif
if (fabs(value - floor(value + 0.5)) < 1.0e-8) {
value = floor(value + 0.5);
if (value < upper) {
Expand Down Expand Up @@ -955,8 +969,10 @@ int CbcHeuristicRENS::solution(double &solutionValue,
#endif
for (int iPass = 0; iPass < RENS_PASS; iPass++) {
int nFixed = 0;
#ifdef CLP_INVESTIGATE2
int nFixedAlready = 0;
int nFixedContinuous = 0;
#endif
for (int iColumn = 0; iColumn < numberColumns; iColumn++) {
if (colUpper[iColumn] > colLower[iColumn]) {
if (newSolver->isInteger(iColumn)) {
Expand All @@ -969,10 +985,12 @@ int CbcHeuristicRENS::solution(double &solutionValue,
newSolver->setColUpper(iColumn, fixTo);
}
}
#ifdef CLP_INVESTIGATE2
} else if (newSolver->isInteger(iColumn)) {
nFixedAlready++;
} else {
nFixedContinuous++;
#endif
}
}
#ifdef CLP_INVESTIGATE2
Expand Down
Loading

0 comments on commit d4272be

Please sign in to comment.