Below is example code in C# using the SOCP Barrier Solver to optimize the problem:
Minimize x4 + x5
Subject to x0 + x1 + x2 + x3 = 1
x4,x0,x1 belong to a cone
x5,x2,x3 belong to a cone
C# code
using (Problem problem = new Problem(Solver_Type.Minimize, nvars, ncons))
{
problem.Model.AllLinear[Function_Type.Objective] =
new DoubleMatrix(Array_Order.ByRow, 1, nvars, objcoeff);
problem.Model.AllLinear[Function_Type.Constraint] =
new DoubleMatrix(Array_Order.ByRow, ncons, nvars, concoeff);
problem.FcnConstraint.LowerBound.Array = rhsvalue;
problem.FcnConstraint.UpperBound.Array = rhsvalue;
problem.VarDecision.NonNegative();
// Specify the second order cone constraints
problem.VarDecision.ConeType.Array =
new Cone_Type [] { Cone_Type.SOC, Cone_Type.SOC, Cone_Type.SOC,
Cone_Type.SOC, Cone_Type.SOC_Start, Cone_Type.SOC_Start };
problem.VarDecision.ConeIndex.Array = new int [] { 1, 2, 1, 2, 1, 2 };
problem.Engine = problem.Engines[Engine.SOCPName];
problem.Solver.Optimize();
Optimize_Status status = problem.Solver.OptimizeStatus;
m_Log.Dump("Status = " + status);
m_Log.Dump("x1 = " + problem.VarDecision.FinalValue[0]);
...
}
The SOCP Barrier Solver automatically recognizes quadratic objectives and constraints and converts them to second order cone (SOC) constraints internally before solving the problem. It provides several options for computing the search direction in each Interior Point iteration, and it allows you control tolerances such as the feasibility tolerance, the primal-dual gap tolerance, and the relative step size to the constraint boundary.