Skip to content

Commit

Permalink
Fix assertion failure and warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottKolo committed Mar 23, 2018
1 parent 003dbc5 commit 96e0ce5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/Mongoose_QPNapsack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void checkatx(double *x, double *a, Int n, double lo, double hi, double tol)
}
else
{
PR(("a'x = %g * %g = %g\n", 1, x[k], x[k]));
PR(("a'x = %g * %g = %g\n", 1.0, x[k], x[k]));
atx += x[k];
}
}
Expand Down Expand Up @@ -163,6 +163,7 @@ double QPNapsack /* return the final lambda */
double tol /* Gradient projection tolerance */
)
{
(void)tol; // unused variable except during debug
double lambda = Lambda;
PR(("QPNapsack start [\n"));

Expand Down Expand Up @@ -347,6 +348,7 @@ double QPNapsack /* return the final lambda */
for (Int k = 0; k < n; k++)
{
double xi = x[k] - Gw[k] * lambda;

if (xi < 0)
{
x[k] = 0;
Expand All @@ -366,7 +368,7 @@ double QPNapsack /* return the final lambda */
// Correction step if we go too far
if (newatx > hi)
{
double diff = hi - atx;
double diff = hi - atx - 1E-8;
// Need diff = Gw[k] * x[k], so...
x[k] = diff / Gw[k];
newatx = atx + Gw[k] * x[k];
Expand Down

0 comments on commit 96e0ce5

Please sign in to comment.