subject to
is solved with an initial guess of , and .
using System; using Imsl.Math; public class MinConGenLinEx2 : MinConGenLin.IGradient { public double F(double[] x) { return - x[0] * x[1] * x[2]; } public void Gradient(double[] x, double[] g) { g[0] = - x[1] * x[2]; g[1] = - x[0] * x[2]; g[2] = - x[0] * x[1]; } public static void Main(String[] args) { int neq = 0; int ncon = 2; int nvar = 3; double[] a = new double[]{- 1.0, - 2.0, - 2.0, 1.0, 2.0, 2.0}; double[] xlb = new double[]{0.0, 0.0, 0.0}; double[] xub = new double[]{20.0, 11.0, 42.0}; double[] b = new double[]{0.0, 72.0}; MinConGenLin.IGradient fcn = new MinConGenLinEx2(); MinConGenLin zf = new MinConGenLin(fcn, nvar, ncon, neq, a, b, xlb, xub); zf.SetGuess(new double[]{10.0, 10.0, 10.0}); zf.Solve(); new PrintMatrix("Solution").Print(zf.GetSolution()); Console.Out.WriteLine("Objective value = " + zf.ObjectiveValue); } }
Solution 0 0 20 1 11 2 15 Objective value = -3300Link to C# source.