Primal-dual interior-point method
s.t.
,
where are convex and twice differentiable, and with .
There are two ways for using this optimizer:
- call the PrimalDualMethod's constructor directly
- instantiate a Solver4J object, and specify Solver4J.PRIMAL_DUAL_METHOD as the preferred interior-point method (you can also leave it blank, this is the default).
Code example 1
Consider the following linear problem: s.t.
// Objective function (linear)
LinearMultivariateRealFunction objectiveFunction = new LinearMultivariateRealFunction(new double[] { 2, 1 }, 0);
// Inquality constraints
ConvexMultivariateRealFunction[] inequalities = new ConvexMultivariateRealFunction[2];
inequalities[0] = new LinearMultivariateRealFunction(new double[] { -1, 0 }, 0);
inequalities[1] = new LinearMultivariateRealFunction(new double[] { 0, -1 }, 0);
OptimizationRequest or = new OptimizationRequest();
or.setF0(objectiveFunction);
or.setInitialPoint(new double[] { 0.9, 0.1 });
or.setFi(inequalities);
// Equality constraints
or.setA(new double[][] { { 1, 1} });
or.setB(new double[] { 1 });
or.setTolerance(1.E-9);
// optimization
PrimalDualMethod opt = new PrimalDualMethod();
opt.setOptimizationRequest(or);
opt.optimize();
double[] sol = opt.getOptimizationResponse().solution; sol[0] = 0; sol[1] = 1
Code example 2
Consider the following linear objective with quadratic inequalities problem (the same as barrier-method example 1): s.t.
// Objective function (linear)
double c = 0.1;
LinearMultivariateRealFunction objectiveFunction = new LinearMultivariateRealFunction(new double[] { c, c }, 0);
// Inequality constraints
ConvexMultivariateRealFunction[] inequalities = new ConvexMultivariateRealFunction[1];
inequalities[0] = FunctionsUtils.createCircle(2, 1);
OptimizationRequest or = new OptimizationRequest();
or.setF0(objectiveFunction);
or.setInitialLagrangian(new double[]{10});
or.setFi(inequalities);
or.setInteriorPointMethod(Solver4J.PRIMAL_DUAL_METHOD);//this is also the default
or.setToleranceFeas(5.E-6);
//or.setCheckKKTSolutionAccuracy(true);
//or.setCheckProgressConditions(true);
// optimization
Solver4J opt = new Solver4J();
opt.setOptimizationRequest(or);
opt.optimize();
double[] sol = opt.getOptimizationResponse().solution; sol[0] = -Math.sqrt(2)/2; sol[1] = -Math.sqrt(2)/2;

