|
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-defined functions that are unidimensional and have a derivative. Unidimensional functions are functions that have only one variable.
With this section we provide source code examples which illustrate explicitly how a uni-dimensional function is implemented. In particular, we provide the source code for the implementation of a polynomial.
Here we provide the definition of the object function:f(x) = 3x^2 + 4x + 3
which is a linear function.
In order to provide an implementation for this interface you are required to provide an implementation for the following methods:
getValueAtVector(double[]) - Returns the value of the function f, at a given point. getDerivativeAt(double[]) - Returns the value of the derivative of the function f,
at a given point.Here we provide the source code for the implementation of the function
f(x) = 3x^2 + 4x + 3, on the Java Platform.
import webcab.lib.math.optimization.unidimensional.*;
public class PolynomialFunction implements UniDimensionalFunction, Derivative {
public PolynomialFunction() throws Exception {}
// Returns the value of the objective function at a given point.
//
public double getValueAt(double evaluationPoint) {
return (3*evaluationPoint*evaluationPoint + 2*evaluationPoint + 3);
}
// Returns the value of the derivative of the objective function
// evaluated at a given point.
//
public double getDerivativeAt(double evaluationPoint) {
return (6*evaluationPoint + 4);
}
Here we provide the source code for the implementation of the function
f(x) = 3x^2 + 4x + 3, on the EJB (J2EE) Platform.
import com.webcab.ejb.math.optimization.unidimensional.*;
import java.rmi.*;
import javax.rmi.*;
import javax.naming.*;
import javax.ejb.*;
public class PolynomialFunction implements UniDimensionalFunction, Derivative {
public PolynomialFunction() throws Exception {}
// Returns the value of the objective function at a given point.
//
public double getValueAt(double evaluationPoint) {
return (3*evaluationPoint*evaluationPoint + 2*evaluationPoint + 3);
}
// Returns the value of the derivative of the objective function
// evaluated at a given point.
//
public double getDerivativeAt(double evaluationPoint) {
return (6*evaluationPoint + 4);
}
This interface inherits from this interface.| Method Summary | |
double |
getDerivativeAt(double x)
Computes the derivative of the function at the point x. |
| Methods inherited from interface com.webcab.ejb.math.optimization.unidimensional.UniDimensionalFunction |
getValueAt |
| Method Detail |
public double getDerivativeAt(double x)
throws InvalidUniDimensionalFunctionException,
Exception
x.
x - the value of the variable of the function for which the derivative is evaluated.
RemoteException
InvalidUniDimensionalFunctionException
Exception
|
WebCab Optimization v2.6 (J2EE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||