|
WebCab Optimization v2.6 (J2EE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
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.
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:
getNoDimensions() - Returning the number of independent variables of the function.
getValueAtVector(double[]) - Returns the value of the function f,
at a given point.
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;
}
}
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;
}
}
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 |
public double getValueAtVector(double[] x)
throws InvalidMultiDimensionalFunctionException,
Exception
x.
x - a vector containing the values of the variables
x
InvalidMultiDimensionalFunctionException
Exception
public int getNoDimensions()
throws Exception
Exception
|
WebCab Optimization v2.6 (J2EE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||