subject to
is solved.
import com.imsl.math.*;
public class MinConGenLinEx1 {
public static void main(String args[]) throws Exception {
int neq = 2;
int ncon = 2;
int nvar = 5;
double a[] = {1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, -2.0, -2.0};
double b[] = {5.0, -3.0};
double xlb[] = {0.0, 0.0, 0.0, 0.0, 0.0};
double xub[] = {10.0, 10.0, 10.0, 10.0, 10.0};
MinConGenLin.Function fcn = new MinConGenLin.Function() {
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];
}
};
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 Java source.