The class NewtonLEUnconstrainedFSP implements a (linear) equality constrained Newton optimizer (see S.Boyd and L.Vandenberghe, "Convex Optimization", p. 521 for more details), and can be used to solve the following problem:

minimize x f ( x )  s.t.
     Ax = b

where f :  R n  R is convex and twice differentiable, and A  R p x n with  rank A = p < n , given a starting point x  dom f with Ax = b

Code example

Consider the following convex problem:

minimize x  x - log ( - x 2 + 1 )  with
 dom f = { x  |  x 2 < 1 }

It can be solved like this:
		// Objective function
		ConvexMultivariateRealFunction objectiveFunction = new ConvexMultivariateRealFunction() {
			
			public double value(DoubleMatrix1D X) {
				double x = X.getQuick(0);
				return x - Math.log(1-x*x);
			}
			
			public DoubleMatrix1D gradient(DoubleMatrix1D X) {
				double x = X.getQuick(0);
				return F1.make(new double[]{1+2*x/(1-x*x)});
			}
			
			public DoubleMatrix2D hessian(DoubleMatrix1D X) {
				double x = X.getQuick(0);
				return F2.make(new double[][]{{4*Math.pow(x, 2)/Math.pow(1-x*x, 2)+2/(1-x*x)}});
			}
			
			public int getDim() {
				return 1;
			}
		};

		OptimizationRequest or = new OptimizationRequest();
		or.setCheckKKTSolutionAccuracy(true);
		or.setF0(objectiveFunction);
		or.setInitialPoint(new double[] {0});//must be feasible
		
		// optimization
		NewtonLEConstrainedFSP opt = new NewtonLEConstrainedFSP();
		opt.setOptimizationRequest(or);
		opt.optimize();
		
This will give the solution (that we expect):
				double[] sol = opt.getOptimizationResponse().solution;
				sol[0] = 1-Math.sqrt(2);
				

Download test source bundle

Download the entire test source bundle from here.

Back to top

Reflow Maven skin maintained by Olivier Lamy.