subject to
is solved with an initial guess of , and .
import com.imsl.math.*; public class MinConGenLinEx2 { public static void main(String args[]) throws Exception { int neq = 0; int ncon = 2; int nvar = 3; double a[] = {-1.0, -2.0, -2.0, 1.0, 2.0, 2.0}; double xlb[] = {0.0, 0.0, 0.0}; double xub[] = {20.0, 11.0, 42.0}; double xguess[] = {10.0, 10.0, 10.0}; double b[] = {0.0, 72.0}; MinConGenLin.Gradient grad = new MinConGenLin.Gradient() { 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]; } }; MinConGenLin zf = new MinConGenLin(grad, nvar, ncon, neq, a, b, xlb, xub); zf.setGuess(xguess); zf.solve(); new PrintMatrix("Solution").print(zf.getSolution()); System.out.println("Objective value = " + zf.getObjectiveValue()); } }
Solution 0 0 20 1 11 2 15 Objective value = -3300.0Link to Java source.