• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UnivariateOptimizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math3.optim.univariate.UnivariateOptimizer的典型用法代码示例。如果您正苦于以下问题:Java UnivariateOptimizer类的具体用法?Java UnivariateOptimizer怎么用?Java UnivariateOptimizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UnivariateOptimizer类属于org.apache.commons.math3.optim.univariate包,在下文中一共展示了UnivariateOptimizer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findMin

import org.apache.commons.math3.optim.univariate.UnivariateOptimizer; //导入依赖的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;
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:23,代码来源:FIRE.java


示例2: getStartPointPhase

import org.apache.commons.math3.optim.univariate.UnivariateOptimizer; //导入依赖的package包/类
/**
 * Calculates the 'canonical' start point. This version uses 
 * (a) a coarse search for a global maximum of fp() and subsequently 
 * (b) a numerical optimization using Brent's method
 * (implemented with Apache Commons Math).
 * 
 * @param Mp number of Fourier coefficient pairs
 * @return start point phase
 */
public double getStartPointPhase(int Mp) {
	Mp = Math.min(Mp, (G.length-1)/2);
	UnivariateFunction fp =  new TargetFunction(Mp);
	// search for the global maximum in coarse steps
	double cmax = Double.NEGATIVE_INFINITY;
	int kmax = -1;
	int K = 25;	// number of steps over 180 degrees
	for (int k = 0; k < K; k++) {
		final double phi = Math.PI * k / K; 	// phase to evaluate
		final double c = fp.value(phi);
		if (c > cmax) {
			cmax = c;
			kmax = k;
		}
	}
	// optimize using previous and next point as the bracket.
	double minPhi = Math.PI * (kmax - 1) / K;
	double maxPhi = Math.PI * (kmax + 1) / K;	

	UnivariateOptimizer optimizer = new BrentOptimizer(1E-4, 1E-6);
	int maxIter = 20;
	UnivariatePointValuePair result = optimizer.optimize(
			new MaxEval(maxIter),
			new UnivariateObjectiveFunction(fp),
			GoalType.MAXIMIZE,
			new SearchInterval(minPhi, maxPhi)
			);
	double phi0 = result.getPoint();
	return phi0;	// the canonical start point phase
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:40,代码来源:FourierDescriptor.java


示例3: doLineSearch

import org.apache.commons.math3.optim.univariate.UnivariateOptimizer; //导入依赖的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;
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:59,代码来源:BrentLineSearch.java



注:本文中的org.apache.commons.math3.optim.univariate.UnivariateOptimizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BitmapUtils类代码示例发布时间:2022-05-23
下一篇:
Java ViewportLayer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap