subject to
is solved.
import com.imsl.math.*;
public class MinConNLPEx1 implements MinConNLP.Function {
public double f(double[] x, int iact, boolean[] ierr) {
double result;
ierr[0] = false;
if (iact == 0) {
result = (x[0] - 2.e0) * (x[0] - 2.e0)
+ (x[1] - 1.e0) * (x[1] - 1.e0);
return result;
} else {
switch (iact) {
case 1:
result = (x[0] - 2.e0 * x[1] + 1.e0);
return result;
case 2:
result = (-(x[0] * x[0]) / 4.e0 - (x[1] * x[1]) + 1.e0);
return result;
default:
ierr[0] = true;
return 0.e0;
}
}
}
public static void main(String args[]) throws Exception {
int m = 2;
int me = 1;
int n = 2;
double xinit[] = {2., 2.};
MinConNLP minconnon = new MinConNLP(m, me, n);
minconnon.setGuess(xinit);
MinConNLPEx1 fcn = new MinConNLPEx1();
double[] x = minconnon.solve(fcn);
System.out.println("x is " + x[0] + " " + x[1]);
}
}
x is 0.8228756555325116 0.9114378277662559Link to Java source.