subject to
is solved.
using System; using Imsl.Math; public class MinConGenLinEx1 : MinConGenLin.IFunction { public double F(double[] x) { return x[0] * x[0] + x[1] * x[1] + x[2] * x[2] + x[3] * x[3] + x[4] * x[4] - 2.0 * x[1] * x[2] - 2.0 * x[3] * x[4] - 2.0 * x[0]; } public static void Main(String[] args) { int neq = 2; int ncon = 2; int nvar = 5; double[] a = new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, - 2.0, - 2.0}; double[] b = new double[]{5.0, - 3.0}; double[] xlb = new double[]{0.0, 0.0, 0.0, 0.0, 0.0}; double[] xub = new double[]{10.0, 10.0, 10.0, 10.0, 10.0}; MinConGenLin.IFunction fcn = new MinConGenLinEx1(); MinConGenLin zf = new MinConGenLin(fcn, nvar, ncon, neq, a, b, xlb, xub); zf.Solve(); new PrintMatrix("Solution").Print(zf.GetSolution()); } }
Solution 0 0 1 1 1 2 1 3 1 4 1Link to C# source.