Skip to content

Commit

Permalink
more accuracy in printing objective value
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhforrest committed Sep 10, 2024
1 parent 209c1e8 commit f657200
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/CbcHeuristicFPump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
for (i = 0; i < numberColumns; i++)
newSolutionValue += saveObjective[i] * newSolution[i];
newSolutionValue *= direction;
sprintf(pumpPrint, "Solution found of %g", trueObjValue(newSolutionValue));
sprintf(pumpPrint, "Solution found of %.13g", trueObjValue(newSolutionValue));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
<< CoinMessageEol;
Expand Down Expand Up @@ -981,7 +981,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
for (i = 0; i < numberColumns; i++) {
newSolutionValue += saveObjective[i] * newSolution[i];
}
sprintf(pumpPrint, "Relaxing continuous gives %g",
sprintf(pumpPrint, "Relaxing continuous gives %.13g",
model_->trueObjValue(newSolutionValue));
//#define DEBUG_BEST
#ifdef DEBUG_BEST
Expand Down Expand Up @@ -1102,7 +1102,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
if (numberSolutions >= maxSolutions)
exitAll = true;
if (general && saveValue != newSolutionValue) {
sprintf(pumpPrint, "Cleaned solution of %g", trueObjValue(solutionValue));
sprintf(pumpPrint, "Cleaned solution of %.13g", trueObjValue(solutionValue));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
<< CoinMessageEol;
Expand All @@ -1116,7 +1116,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
<< CoinMessageEol;
}
} else {
sprintf(pumpPrint, "After further testing solution no better than previous of %g", trueObjValue(solutionValue));
sprintf(pumpPrint, "After further testing solution no better than previous of %.13g", trueObjValue(solutionValue));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
<< CoinMessageEol;
Expand Down Expand Up @@ -1349,7 +1349,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
for (i = 0; i < numberColumns; i++)
newSolutionValue += saveObjective[i] * newSolution[i];
newSolutionValue *= direction;
sprintf(pumpPrint, "Intermediate solution found of %g", trueObjValue(newSolutionValue));
sprintf(pumpPrint, "Intermediate solution found of %.13g", trueObjValue(newSolutionValue));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
<< CoinMessageEol;
Expand Down Expand Up @@ -1951,7 +1951,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
// see if rounding worked!
if (roundingObjective < solutionValue) {
if (roundingObjective < solutionValue - 1.0e-6 * fabs(roundingObjective)) {
sprintf(pumpPrint, "Rounding solution of %g is better than previous of %g\n",
sprintf(pumpPrint, "Rounding solution of %.13g is better than previous of %.13g\n",
trueObjValue(roundingObjective), trueObjValue(solutionValue));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
Expand Down Expand Up @@ -2158,7 +2158,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
}
bool gotSolution = false;
if (returnCode && newSolutionValue < saveValue) {
sprintf(pumpPrint, "Mini branch and bound improved solution from %g to %g (%.2f seconds)",
sprintf(pumpPrint, "Mini branch and bound improved solution from %.13g to %.13g (%.2f seconds)",
trueObjValue(saveValue), trueObjValue(newSolutionValue), model_->getCurrentSeconds());
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
Expand Down Expand Up @@ -2266,7 +2266,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
newSumInfeas);
}
#endif
sprintf(pumpPrint, "Freeing continuous variables gives a solution of %g", trueObjValue(value));
sprintf(pumpPrint, "Freeing continuous variables gives a solution of %.13g", trueObjValue(value));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
<< CoinMessageEol;
Expand Down Expand Up @@ -2307,7 +2307,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
if (newSolver->isProvenOptimal()) {
double value = newSolver->getObjValue() * newSolver->getObjSenseInCbc();
if (value < saveValue) {
sprintf(pumpPrint, "Freeing continuous variables gives a solution of %g", trueObjValue(value));
sprintf(pumpPrint, "Freeing continuous variables gives a solution of %.13g", trueObjValue(value));
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
<< pumpPrint
<< CoinMessageEol;
Expand Down Expand Up @@ -2455,10 +2455,10 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting - took %.2f seconds",
model_->getCurrentSeconds(), CoinCpuTime() - time1);
else if (numberSolutions < maxSolutions)
sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %g - took %.2f seconds",
sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %.13g - took %.2f seconds",
model_->getCurrentSeconds(), trueObjValue(solutionValue), CoinCpuTime() - time1);
else
sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %g (stopping after %d solutions) - took %.2f seconds",
sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %.13g (stopping after %d solutions) - took %.2f seconds",
model_->getCurrentSeconds(), trueObjValue(solutionValue),
numberSolutions, CoinCpuTime() - time1);
model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
Expand Down
4 changes: 2 additions & 2 deletions src/CbcMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ static Cbc_message us_english[] = {
#endif
{ CBC_GAP, 11, 1, "Exiting as integer gap of %g less than %g or %g%%" },
#ifndef CBC_MANY_NODE_COUNTS
{ CBC_ROUNDING, 12, 1, "Integer solution of %g found by %s after %d iterations and %d nodes (%.2f seconds)" },
{ CBC_ROUNDING, 12, 1, "Integer solution of %.13g found by %s after %d iterations and %d nodes (%.2f seconds)" },
#else
{ CBC_ROUNDING, 12, 1, "Integer solution of %g found by %s after %ld iterations and %ld nodes (%.2f seconds)" },
{ CBC_ROUNDING, 12, 1, "Integer solution of %.13g found by %s after %ld iterations and %ld nodes (%.2f seconds)" },
#endif
{ CBC_ROOT, 13, 1, "At root node, %d cuts changed objective from %g to %g in %d passes" },
{ CBC_GENERATOR, 14, 1, "Cut generator %d (%s) - %d row cuts average %.1f elements, %d column cuts (%d active) %? in %.3f seconds - new frequency is %d" },
Expand Down

0 comments on commit f657200

Please sign in to comment.