本文整理汇总了Java中org.apache.commons.math.optimization.MultivariateRealOptimizer类的典型用法代码示例。如果您正苦于以下问题:Java MultivariateRealOptimizer类的具体用法?Java MultivariateRealOptimizer怎么用?Java MultivariateRealOptimizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultivariateRealOptimizer类属于org.apache.commons.math.optimization包,在下文中一共展示了MultivariateRealOptimizer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
* @param func Function to optimize.
* @param optimum Expected optimum.
* @param init Starting point.
* @param goal Minimization or maximization.
* @param fTol Tolerance (relative error on the objective function) for
* "Powell" algorithm.
* @param pointTol Tolerance for checking that the optimum is correct.
*/
private void doTest(MultivariateRealFunction func,
double[] optimum,
double[] init,
GoalType goal,
double fTol,
double pointTol) {
final MultivariateRealOptimizer optim = new PowellOptimizer(fTol, Math.ulp(1d));
final RealPointValuePair result = optim.optimize(1000, func, goal, init);
final double[] found = result.getPoint();
for (int i = 0, dim = optimum.length; i < dim; i++) {
Assert.assertEquals(optimum[i], found[i], pointTol);
}
}
示例2: doTest
import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
* @param func Function to optimize.
* @param startPoint Starting point.
* @param inSigma Individual input sigma.
* @param boundaries Upper / lower point limit.
* @param goal Minimization or maximization.
* @param lambda Population size used for offspring.
* @param isActive Covariance update mechanism.
* @param diagonalOnly Simplified covariance update.
* @param stopValue Termination criteria for optimization.
* @param fTol Tolerance relative error on the objective function.
* @param pointTol Tolerance for checking that the optimum is correct.
* @param maxEvaluations Maximum number of evaluations.
* @param expected Expected point / value.
*/
private void doTest(MultivariateRealFunction func,
double[] startPoint,
double[] inSigma,
double[][] boundaries,
GoalType goal,
int lambda,
boolean isActive,
int diagonalOnly,
double stopValue,
double fTol,
double pointTol,
int maxEvaluations,
RealPointValuePair expected)
throws MathException {
int dim = startPoint.length;
// test diagonalOnly = 0 - slow but normally fewer feval#
MultivariateRealOptimizer optim =
new CMAESOptimizer(
lambda, inSigma, boundaries, 30000,
stopValue, isActive, diagonalOnly, 0, new MersenneTwister(),false);
RealPointValuePair result = optim.optimize(maxEvaluations, func, goal, startPoint);
Assert.assertEquals(expected.getValue(),
result.getValue(), fTol);
for (int i = 0; i < dim; i++) {
Assert.assertEquals(expected.getPoint()[i],
result.getPoint()[i], pointTol);
}
}
示例3: doTest
import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
* @param func Function to optimize.
* @param startPoint Starting point.
* @param inSigma Individual input sigma.
* @param boundaries Upper / lower point limit.
* @param goal Minimization or maximization.
* @param lambda Population size used for offspring.
* @param isActive Covariance update mechanism.
* @param diagonalOnly Simplified covariance update.
* @param stopValue Termination criteria for optimization.
* @param fTol Tolerance relative error on the objective function.
* @param pointTol Tolerance for checking that the optimum is correct.
* @param maxEvaluations Maximum number of evaluations.
* @param expected Expected point / value.
*/
private void doTest(MultivariateRealFunction func,
double[] startPoint,
double[] inSigma,
double[][] boundaries,
GoalType goal,
int lambda,
boolean isActive,
int diagonalOnly,
double stopValue,
double fTol,
double pointTol,
int maxEvaluations,
RealPointValuePair expected) {
int dim = startPoint.length;
// test diagonalOnly = 0 - slow but normally fewer feval#
MultivariateRealOptimizer optim =
new CMAESOptimizer(
lambda, inSigma, boundaries, 30000,
stopValue, isActive, diagonalOnly, 0, new MersenneTwister(),false);
RealPointValuePair result = optim.optimize(maxEvaluations, func, goal, startPoint);
Assert.assertEquals(expected.getValue(),
result.getValue(), fTol);
for (int i = 0; i < dim; i++) {
Assert.assertEquals(expected.getPoint()[i],
result.getPoint()[i], pointTol);
}
}
示例4: doTest
import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
* @param func Function to optimize.
* @param startPoint Starting point.
* @param boundaries Upper / lower point limit.
* @param goal Minimization or maximization.
* @param fTol Tolerance relative error on the objective function.
* @param pointTol Tolerance for checking that the optimum is correct.
* @param maxEvaluations Maximum number of evaluations.
* @param expected Expected point / value.
*/
private void doTest(MultivariateRealFunction func,
double[] startPoint,
double[][] boundaries,
GoalType goal,
double fTol,
double pointTol,
int maxEvaluations,
RealPointValuePair expected) {
System.out.println(func.getClass().getName() + " BEGIN"); // XXX
int dim = startPoint.length;
// MultivariateRealOptimizer optim =
// new PowellOptimizer(1e-13, Math.ulp(1d));
// RealPointValuePair result = optim.optimize(100000, func, goal, startPoint);
final double[] lB = boundaries == null ? null : boundaries[0];
final double[] uB = boundaries == null ? null : boundaries[1];
MultivariateRealOptimizer optim =
new BOBYQAOptimizer(2 * dim + 1, lB, uB);
RealPointValuePair result = optim.optimize(maxEvaluations, func, goal, startPoint);
// System.out.println(func.getClass().getName() + " = "
// + optim.getEvaluations() + " f(");
// for (double x: result.getPoint()) System.out.print(x + " ");
// System.out.println(") = " + result.getValue());
Assert.assertEquals(expected.getValue(),
result.getValue(), fTol);
for (int i = 0; i < dim; i++) {
Assert.assertEquals(expected.getPoint()[i],
result.getPoint()[i], pointTol);
}
System.out.println(func.getClass().getName() + " END"); // XXX
}