Skip to content

Commit

Permalink
fixes #8 - change convergence checking logic to remove infinite loopi…
Browse files Browse the repository at this point in the history
…ng (#9)

* change default convergence epsilon to 1e-9 for a bit more resistance to long convergence times

* change tolerance to 1e-8 to adapt to new default convergence epsilon

* change test for convergence from delta-x to objective function, which catches convergence much better
  • Loading branch information
erikerlandson authored Jan 21, 2019
1 parent b4fd8fc commit 1a53e1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public ConvergenceEpsilon(double eps) {
}

/** Default convergence epsilon value */
public static final double CONVERGENCE_EPSILON_DEFAULT = 1e-10;
public static final double CONVERGENCE_EPSILON_DEFAULT = 1e-9;
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public PointValuePair doOptimize() {
KKTSolution sol = kktSolver.solve(hess, grad);
if (sol.lambdaSquared <= (2.0 * epsilon)) break;
RealVector xDelta = sol.xDelta;
// Halt if there is no further movement in solution space
if (xDelta.getNorm() < epsilon) break;
double gdd = grad.dotProduct(xDelta);
RealVector tx = null;
double tv = 0.0;
Expand Down Expand Up @@ -154,6 +152,8 @@ public PointValuePair doOptimize() {
double vprv = v;
x = tx;
v = tv;
// if improvement becomes very small then we are converged
if (Math.abs(1.0 - (v / vprv)) < epsilon) break;
// Check halting condition if configured
if ((halting != null) && halting.checker.converged(
getIterations(),
Expand Down Expand Up @@ -182,8 +182,6 @@ public PointValuePair doOptimize() {
KKTSolution sol = kktSolver.solve(hess, A, AT, grad, A.operate(x).subtract(b));
RealVector xDelta = sol.xDelta;
RealVector nuDelta = sol.nuPlus.subtract(nu);
// Halt if there is no further movement in solution space
if (xDelta.getNorm() < epsilon) break;
RealVector tx = null;
RealVector tnu = null;
double tv = 0.0;
Expand Down Expand Up @@ -219,6 +217,8 @@ public PointValuePair doOptimize() {
x = tx;
nu = tnu;
v = tv;
// if improvement becomes very small then we are converged
if (Math.abs(1.0 - (v / vprv)) < epsilon) break;
// check halting condition, if it was configured
if ((halting != null) && halting.checker.converged(
getIterations(),
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/manyangled/gibbous/COTestingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.manyangled.gibbous.optim.convex.QuadraticFunction;

public class COTestingUtils {
public static final double eps = 1e-9;
public static final double eps = 1e-8;

public static QuadraticFunction translatedQF(double h, double[] center) {
double[] all1 = new double[center.length];
Expand Down

0 comments on commit 1a53e1c

Please # to comment.