本文整理汇总了Java中org.apache.commons.math3.optim.univariate.UnivariatePointValuePair.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java UnivariatePointValuePair.getValue方法的具体用法?Java UnivariatePointValuePair.getValue怎么用?Java UnivariatePointValuePair.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.optim.univariate.UnivariatePointValuePair
的用法示例。
在下文中一共展示了UnivariatePointValuePair.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: optimizeUni
import org.apache.commons.math3.optim.univariate.UnivariatePointValuePair; //导入方法依赖的package包/类
public double optimizeUni() throws Exception {
double maxLh=0;
BrentOptimizer optimizer = new BrentOptimizer(1e-6, 1e-12);
UnivariatePointValuePair optimum =
optimizer.optimize(new UnivariateObjectiveFunction(this),
new MaxEval(100),
GoalType.MAXIMIZE,
new SearchInterval(pfBoundsLower[0],pfBoundsUpper[0]));
//double point = optimum.getPoint();
//System.out.print("--> "+paramName+": "+paramValue+" point= "+point);
//System.out.print(" ");
//System.out.println("value = "+ optimum.getValue());
maxLh = optimum.getValue();
optPoint[0] = optimum.getPoint();
return maxLh;
}
示例2: findMin
import org.apache.commons.math3.optim.univariate.UnivariatePointValuePair; //导入方法依赖的package包/类
private UnivariatePointValuePair findMin(UnivariatePointValuePair current, UnivariateOptimizer o,
UnivariateFunction f, double qValue, double factor)
{
try
{
BracketFinder bracket = new BracketFinder();
bracket.search(f, GoalType.MINIMIZE, qValue * factor, qValue / factor);
UnivariatePointValuePair next = o.optimize(GoalType.MINIMIZE, new MaxEval(3000),
new SearchInterval(bracket.getLo(), bracket.getHi(), bracket.getMid()),
new UnivariateObjectiveFunction(f));
if (next == null)
return current;
//System.out.printf("LineMin [%.1f] %f = %f\n", factor, next.getPoint(), next.getValue());
if (current != null)
return (next.getValue() < current.getValue()) ? next : current;
return next;
}
catch (Exception e)
{
return current;
}
}
示例3: doLineSearch
import org.apache.commons.math3.optim.univariate.UnivariatePointValuePair; //导入方法依赖的package包/类
/**
* Perform a line search minimization. This function accepts as input:
* (a) a starting point (a vector),
* (b) a direction in which to travel (a vector),
* (c) limits on the total distance to travel along (b).
*
* With these inputs the function attempts to find the minimum of a
* scalar-valued multivariate function along the line starting at
* (a) and pointing in the direction of (b).
*
* @param function
* A scalar-valued multivariate function to minimize,
* @param startingPoint
* A vector starting point from which to begin the minimization (P),
* @param vectorDirection
* A vector direction along which to travel from P, (V)
* @param maximumDistanceToTravel
* The maximum distance to travel in the direction of V,
* @param maximumEvaluations
* The maximum number of function evaluations to identify the minimum,
* @param relativeErrorGoal
* The relative error target of the minimization,
* @param absoluteErrorGoal
* The absolute error target of the minimization.
* @return
* A lightweight immutable struct containing the vector solution and
* the evaluation of the function at this point.
*/
static public LineSearchResult doLineSearch(
final MultivariateFunction function,
final double[] startingPoint,
final double[] vectorDirection,
final double maximumDistanceToTravel,
final int maximumEvaluations,
final double relativeErrorGoal,
final double absoluteErrorGoal
) {
Preconditions.checkArgument(maximumEvaluations > 0);
Preconditions.checkArgument(relativeErrorGoal > 0. || absoluteErrorGoal > 0.);
Preconditions.checkArgument(maximumDistanceToTravel > 0.);
final LineSearchObjectiveFunction lineSearcher =
new LineSearchObjectiveFunction(function, startingPoint, vectorDirection);
final UnivariateOptimizer optimizer =
new BrentOptimizer(relativeErrorGoal, absoluteErrorGoal);
UnivariatePointValuePair result = optimizer.optimize(
new MaxEval(maximumEvaluations),
new UnivariateObjectiveFunction(lineSearcher),
GoalType.MINIMIZE,
new SearchInterval(0, maximumDistanceToTravel, 0)
);
final double[] vectorSolution = new double[startingPoint.length];
for(int i = 0; i< vectorDirection.length; ++i)
vectorSolution[i] = lineSearcher.startingPoint[i] +
lineSearcher.normalizedDirection[i] * result.getPoint();
final LineSearchResult solution =
new LineSearchResult(vectorSolution, result.getValue());
return solution;
}