Class MinConNLPEx2

java.lang.Object
com.imsl.test.example.math.MinConNLPEx2
All Implemented Interfaces:
MinConNLP.Function, MinConNLP.Gradient

public class MinConNLPEx2 extends Object implements 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$$

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    f(double[] x, int iact, boolean[] ierr)
    Defines the objective function and constraints.
    void
    gradient(double[] x, int iact, double[] result)
    Defines the gradients of the objective and the constraints.
    static void
    main(String[] args)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      f in interface MinConNLP.Function
      Parameters:
      x - a double array containing the variable values
      iact - an int specifying the return value. If iact=0 this function returns the objective function evaluated at x. If iact=\(1, 2, 3,...\), this function returns the constraint with that index evaluated at x.
      ierr - a boolean array of length 1, where ierr[0]=false when no error or undesirable condition occurs during evaluation, and ierr[0]=true indicates some issue during evaluation
      Returns:
      a double the value specified by iact
    • gradient

      public void gradient(double[] x, int iact, double[] result)
      Defines the gradients of the objective and the constraints.
      Specified by:
      gradient in interface MinConNLP.Gradient
      Parameters:
      x - a double array containing the variable values
      iact - an int specifying what should be returned. If iact=0 the gradient is returned evaluated at x. Otherwise, the gradient of the constraint with given index iact=1,2,.. evaluated at x is returned.
      result - a double array containing results on output
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception