|
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 unidimensional. Unidimensional functions are functions that depend
upon only one variable. If, in addition, you want to supply a derivative
you should implement Derivative instead.
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:
f(x) = 3x2 + 4x + 3.
In order to provide an implementation for this function you are required to provide an implementation for the following method:
getValueAtVector(double) - Returns the value of the function at a given point.Here we provide the source code for the implementation of the function f(x) = 3x2 + 4x + 3,
for the J2SE Platform.
import webcab.lib.math.optimization.unidimensional.*;
public class PolynomialFunction implements UniDimensionalFunction {
//
// The default constructor of the class.
//
public PolynomialFunction() throws Exception {}
//
// Returns the value of the object function at a given point.
//
public double getValueAt(double evaluationPoint) {
return (3 * evaluationPoint * evaluationPoint + 2 * evaluationPoint + 3);
}
}
Here we provide the source code for the implementation of the function f(x) = 3x2 + 4x + 3,
for the EJB (J2EE) Platform.
import webcab.lib.math.optimization.unidimensional.*;
import java.rmi.*;
import javax.rmi.*;
import javax.naming.*;
import javax.ejb.*;
public class PolynomialFunction implements UniDimensionalFunction {
//
// The default constructor of the PolynomialFunction class.
//
public PolynomialFunction() throws Exception {}
//
// Returns the value of the object function at a given point.
//
public double getValueAt(double evaluationPoint) {
return (3 * evaluationPoint * evaluationPoint + 2 * evaluationPoint + 3);
}
}
- Inherits from this interface and allows the derivative of the function
be provided.| Method Summary | |
double |
getValueAt(double evaluationPoint)
Computes the value of the function at a given point. |
| Method Detail |
public double getValueAt(double evaluationPoint)
throws InvalidUniDimensionalFunctionException,
Exception
The following code implements this method for the function f(x) = 3x2 + 4x + 3:
public double getValueAt(double evaluationPoint) {
return (3 * evaluationPoint * evaluationPoint + 2 * evaluationPoint + 3);
}
evaluationPoint - the value of the real variable at which is the function is evaluated.
evaluationPoint
InvalidUniDimensionalFunctionException
Exception
|
WebCab Optimization v2.6 (J2EE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||