WebCab Optimization
v2.6
(J2EE Edition)

com.webcab.ejb.math.optimization.multidimensional
Interface MultiDimensionalFunction

All Superinterfaces:
Function, Remote, Serializable
All Known Subinterfaces:
Gradient

public interface MultiDimensionalFunction
extends Function

This interface should be implemented by all user supplied functions that are multidimensional. Multidimensional functions are functions that depend on more than one variable. If, in addition, you want to supply a gradient you should implement the Gradient interface instead.

Source Code Examples

With this section we provide source code examples which illustrate explicitly how a multi-dimensional function is implemented. In particular, we provide the source code for the implementation of a polynomial. In particular, we provide the source code which implements the object function: f(x,y) = xy + 2x + 3.

In order to provide an implementation for this interface you are required to provide an implementation for the following methods:

  1. getNoDimensions() - Returning the number of independent variables of the function.
  2. getValueAtVector(double[]) - Returns the value of the function f, at a given point.

Source Code Implemention of the Function on the Java (J2SE) Platform

Here we provide the source code for the implementation of the function f(x,y) = xy + 2x + 3, on the Java (J2SE) Platform.

 import webcab.lib.math.optimization.multidimensional.*;

 public class MyFunction implements MultiDimensionalFunction {

   // The constructor of the class.
   //
   public MyFunction() throws Exception {}
	
   // Returns the number of independent variables which in this case is 2, since
   // the function f(x,y) has two independent variables.
   //
   public int getNoDimensions () {
         return 2;
   }

   // Returns the value of the objective function f(x,y) = xy + 2x +3, at a given point.
   //
   public double getValueAtVector(double[] evaluationPoint) {
        return evaluationPoint[0]*evaluationPoint[1] + 2*evaluationPoint[0] + 3;
   }
}

Source Code Implementation of the Function for the EJB (J2EE) Platform

Here we provide the source code for the implementation of the function f(x,y) = xy + 2x + 3, for the EJB (J2EE) Platform.

 import webcab.lib.math.optimization.multidimensional.*;
 import java.rmi.*;
 import javax.rmi.*;
 import javax.naming.*;
 import javax.ejb.*;

 public class MyFunction implements MultiDimensionalFunction {
   
   // The constructor of the class.
   //
   public MyFunction() throws Exception {}
	
   // Returns the number of independent variables which in this case is 2, since
   // the function f(x,y) has two independent variables.
   //
   public int getNoDimensions () {
         return 2;
   }

   // Returns the value of the objective function f(x,y) = xy + 2x +3, at a given point.
   //
   public double getValueAtVector(double[] evaluationPoint) {
        return evaluationPoint[0]*evaluationPoint[1] + 2*evaluationPoint[0] + 3;
   }
}

See Also:
Inherits from this interface and allows the gradient of this function to be provided.

Method Summary
 int getNoDimensions()
          This method returns the number of dimensions over which the multi-dimensional function is defined.
 double getValueAtVector(double[] x)
          Computes the value of the function in the point x.
 

Method Detail

getValueAtVector

public double getValueAtVector(double[] x)
                        throws InvalidMultiDimensionalFunctionException,
                               Exception
Computes the value of the function in the point x.

Parameters:
x - a vector containing the values of the variables
Returns:
the value of the function in the point x
InvalidMultiDimensionalFunctionException
Exception

getNoDimensions

public int getNoDimensions()
                    throws Exception
This method returns the number of dimensions over which the multi-dimensional function is defined.

Exception

WebCab Optimization
v2.6
(J2EE Edition)