Package com.imsl.test.example.math
Class MinConNLPEx2
java.lang.Object
com.imsl.test.example.math.MinConNLPEx2
- All Implemented Interfaces:
MinConNLP.Function,MinConNLP.Gradient
MinConNLP Example 2: Solves a general nonlinear programming problem with a user supplied gradient.
In this example, a general nonlinear programming problem is solved using a user-supplied gradient. The problem is as follows:$${\rm {min}} \,\, F(x) = (x_1 - 2)^2 + (x_2 - 1)^2$$
subject to
$$g_1(x) = x_1 - 2x_2 + 1 = 0$$
$$g_2(x) = -x_1^2 / 4 - x_2^2 + 1 \ge 0$$
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
MinConNLPEx2
public MinConNLPEx2()
-
-
Method Details
-
f
public double f(double[] x, int iact, boolean[] ierr) Defines the objective function and constraints. ` *This function is called by
MinConNLP.- Specified by:
fin interfaceMinConNLP.Function- Parameters:
x- adoublearray containing the variable valuesiact- anintspecifying the return value. Ifiact=0this function returns the objective function evaluated atx. Ifiact=\(1, 2, 3,...\), this function returns the constraint with that index evaluated atx.ierr- abooleanarray of length 1, whereierr[0]=falsewhen no error or undesirable condition occurs during evaluation, andierr[0]=trueindicates some issue during evaluation- Returns:
- a
doublethe value specified byiact
-
gradient
public void gradient(double[] x, int iact, double[] result) Defines the gradients of the objective and the constraints.- Specified by:
gradientin interfaceMinConNLP.Gradient- Parameters:
x- adoublearray containing the variable valuesiact- anintspecifying what should be returned. Ifiact=0the gradient is returned evaluated atx. Otherwise, the gradient of the constraint with given indexiact=1,2,..evaluated atxis returned.result- adoublearray containing results on output
-
main
- Throws:
Exception
-