Skip to content

Commit

Permalink
fix #4 -- make SVDSchurKKTSolver the default for NewtonOptimizer (#7)
Browse files Browse the repository at this point in the history
* make SVDSchurKKTSolver the default for NewtonOptimizer

* add SVDSchurKKTSolver to the unit testing
  • Loading branch information
erikerlandson authored Jan 16, 2019
1 parent 560142d commit 5d71a7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class NewtonOptimizer extends ConvexOptimizer {
private LinearEqualityConstraint eqConstraint;
private KKTSolver kktSolver = new CholeskySchurKKTSolver();
private KKTSolver kktSolver = new SVDSchurKKTSolver();
private RealVector xStart;
private double epsilon = ConvergenceEpsilon.CONVERGENCE_EPSILON_DEFAULT;
private double alpha = BacktrackAlpha.BACKTRACK_ALPHA_DEFAULT;
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/manyangled/gibbous/KKTSolverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.manyangled.gibbous.optim.convex.KKTSolver;
import com.manyangled.gibbous.optim.convex.KKTSolution;
import com.manyangled.gibbous.optim.convex.CholeskySchurKKTSolver;
import com.manyangled.gibbous.optim.convex.SVDSchurKKTSolver;

import static com.manyangled.gibbous.COTestingUtils.eps;

Expand Down Expand Up @@ -82,6 +83,7 @@ public void testSchurConstrained1() {
double[] g = { 1.0, 2.0 };
double[] h = { 3.0 };
testWithConstraints(new CholeskySchurKKTSolver(), H, A, g, h);
testWithConstraints(new SVDSchurKKTSolver(), H, A, g, h);
}

@Test
Expand All @@ -94,13 +96,15 @@ public void testSchurConstrained2() {
double[] g = { 1.0, 4.0, 9.0 };
double[] h = { 3.0, 7.0 };
testWithConstraints(new CholeskySchurKKTSolver(), H, A, g, h);
testWithConstraints(new SVDSchurKKTSolver(), H, A, g, h);
}

@Test
public void testSchurUnconstrained1() {
double[][] H = { { 5.0, 1.0 }, { 1.0, 5.0 } };
double[] g = { 3.0, 7.0 };
testNoConstraints(new CholeskySchurKKTSolver(), H, g);
testNoConstraints(new SVDSchurKKTSolver(), H, g);
}

@Test
Expand All @@ -110,5 +114,6 @@ public void testSchurUnconstrained2() {
{ 1.0, 2.0, 7.0 } };
double[] g = { 9.0, 4.0, 1.0 };
testNoConstraints(new CholeskySchurKKTSolver(), H, g);
testNoConstraints(new SVDSchurKKTSolver(), H, g);
}
}

0 comments on commit 5d71a7f

Please # to comment.