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

Java BOBYQAOptimizer类代码示例

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

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



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

示例1: applyToNetwork

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer; //导入依赖的package包/类
@Override
public double applyToNetwork(final MixedClearingNetwork network) {
   Preconditions.checkNotNull(network);
   final int dimension = network.getNumberOfEdges();
   
   final ResidualCostFunction aggregateCostFunction =
      super.getResidualScalarCostFunction(network);
   final RealVector
      start = new ArrayRealVector(network.getNumberOfEdges());
   start.set(1.0);                                       // Initial rate guess.
   
   final BOBYQAOptimizer optimizer = new BOBYQAOptimizer(2*dimension + 1, 1.2, 1.e-8);
   final PointValuePair result = optimizer.optimize(
      new MaxEval(maximumEvaluations),
      new ObjectiveFunction(aggregateCostFunction),
      GoalType.MINIMIZE,
      new SimpleBounds(new double[dimension], ArrayUtil.ones(dimension)),
      new InitialGuess(start.toArray())
      );
   
   final double residualCost = result.getValue();
   System.out.println("Network cleared: residual cost: " + residualCost + ".");
   
   return residualCost;
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:26,代码来源:BoundedQuadraticEstimationClearingAlgorithm.java


示例2: findOptimum

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer; //导入依赖的package包/类
@Override
public TreeMap<Double, TariffSpecification> findOptimum(TariffUtilityEstimate tariffUtilityEstimate,
    int NUM_RATES, int numEval) {

  double[] startingVertex = new double[NUM_RATES]; // start from the fixed-rate tariff's offset
  Arrays.fill(startingVertex, 0.0);
  //Arrays.fill(startingVertex, 0.5 * INITIAL_TRUST_REGION_RADIUS);
  //Arrays.fill(startingVertex, 1 * INITIAL_TRUST_REGION_RADIUS);

  final int numIterpolationPoints = 2 * NUM_RATES + 1; // BOBYQA recommends 2n+1 points
  BOBYQAOptimizer optimizer = new BOBYQAOptimizer(numIterpolationPoints , INITIAL_TRUST_REGION_RADIUS, STOPPING_TRUST_REGION_RADIUS);

  // needed since one optimization found positive 
  // charges (paying customer to consume...)
  double[][] boundaries = createBoundaries(NUM_RATES);
 
  final PointValuePair optimum
      = optimizer.optimize(
          new MaxEval(numEval),
          new ObjectiveFunction(new OptimizerWrapperApacheObjective(tariffUtilityEstimate)),
          GoalType.MAXIMIZE,
          new InitialGuess(startingVertex),
          //new SimpleBounds(boundaries[0], boundaries[1]));
          SimpleBounds.unbounded(NUM_RATES));
          
  
  TreeMap<Double, TariffSpecification> eval2TOUTariff = new TreeMap<Double, TariffSpecification>();
  eval2TOUTariff.put(optimum.getValue(), tariffUtilityEstimate.getCorrespondingSpec(optimum.getKey()));
  return eval2TOUTariff;
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:31,代码来源:OptimizerWrapperApacheBOBYQA.java


示例3: run

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer; //导入依赖的package包/类
@Override
public void run() throws Exception {
	// Let's find optimum for beta0, beta1, beta2
	NelderMeadSimplex optMethod = new NelderMeadSimplex(3);
	
	/*
	SimplexOptimizer optimizer = new SimplexOptimizer(1e-5, 1e-10);
	final PointValuePair optimum =
			optimizer.optimize(
				new MaxEval(150), 
                new ObjectiveFunction(this), 
                GoalType.MAXIMIZE, 
                new InitialGuess(new double[]{ Math.log(.6), Math.log(.2), Math.log(0.05) }), 
                optMethod);
	 */
     // new NelderMeadSimplex(new double[]{ 0.2, 0.2 }));
	
	/*
	SimplexOptimizer optimizer = new SimplexOptimizer(1e-5, 1e-10);
	final PointValuePair optimum =
			optimizer.optimize(
				new MaxEval(200), 
                new ObjectiveFunction(this), 
                GoalType.MAXIMIZE, 
                new InitialGuess(new double[]{ .6, .2, 0.05 }), 
                optMethod);
	*/
	
	
	//PowellOptimizer optimizer = new PowellOptimizer(1e-8, 1e-5, 1e-4, 1e-4);
	BOBYQAOptimizer optimizer = new BOBYQAOptimizer(2*3+1+2); // 2*point.length + 1+additional
	final PointValuePair optimum =
			optimizer.optimize(
				new MaxEval(150), 
                new ObjectiveFunction(this), 
                GoalType.MAXIMIZE, 
                new InitialGuess(new double[]{ 1.0, 1.0, 1.0 }),
                new SimpleBounds(new double[] { 0.0 , 0.0 , 0.0 },
                          new double[] { 3.5 , 3.5, 3.5 }));

	
	double[] point = optimum.getPoint();
	System.out.print("point= ");
	for(int i=0; i< point.length; i++) System.out.print("  "+ point[i]);
	System.out.println(" ");
	System.out.println("value = "+ optimum.getValue());
	
}
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:49,代码来源:PopModelParameterEstimation.java


示例4: bobyqa

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer; //导入依赖的package包/类
private PointValuePair bobyqa(final double[] initialValues) {
	return optimize(new BOBYQAOptimizer(2 * initialValues.length), initialValues);
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:4,代码来源:AbstractOptimizable.java


示例5: estimateAlphaBeta

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer; //导入依赖的package包/类
/**
     * Estimate alpha, beta given c, t
     *
     * @param c Counts
     * @param t Branch lengths
     * @return Point, containing (alpha, beta), and associated log-likelihood
     */
    @VisibleForTesting
    static PointValuePair estimateAlphaBeta(final double[] c, final double[] t) {
        // Optimize. point[0] = alpha, point[1] = beta
        final int dim = 2;
        BOBYQAOptimizer optimizer = new BOBYQAOptimizer(2 * dim + ADDL_INTERPOLATION_PTS);

        final MultivariateFunction fn = new MultivariateFunction() {
            @Override
            public double value(double[] point) {
                Preconditions.checkArgument(point.length == 2,
                        "Invalid data size: %s", point.length);
                return logLikelihood(point[0], point[1], c, t);
            }
        };

        // Start with method-of-moments
        final double mean = StatUtils.mean(c),
                var = StatUtils.variance(c);

        double mom_alpha, mom_beta;
        if (var > mean) {
            mom_alpha = (mean * mean) / (var - mean);
            mom_beta = mean / (var - mean);
        } else {
            mom_alpha = 1;
            mom_beta = 1;
        }

        // Bounds - both must be positive
        final double lowerBounds[] = new double[]{1e-7, 1e-7};
        final double upperBounds[] = new double[]{Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY};
        final double initial[] = new double[]{mom_alpha, mom_beta};
        try {
            PointValuePair result = optimizer.optimize(
                    new MaxEval(2000),
                    new InitialGuess(initial),
                    GoalType.MAXIMIZE,
                    new ObjectiveFunction(fn),
                    new SimpleBounds(lowerBounds, upperBounds));
            logger.log(Level.FINE, "BOBYQA finished in {0} iterations", optimizer.getIterations());
            return result;
        } catch (Exception e) {
//            logger.log(Level.SEVERE,
//                    "Optimization failed [mom_alpha: {0}, mom_beta: {1}]\nc={2}\nt={3}",
//                    new Object[]{mom_alpha, mom_beta,
//                            java.util.Arrays.toString(c),
//                            java.util.Arrays.toString(t)});
            throw e;
        }
    }
 
开发者ID:cmccoy,项目名称:startreerenaissance,代码行数:58,代码来源:TLambdaPoissonSmoother.java


示例6: solve

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer; //导入依赖的package包/类
@Override
public synchronized void solve(Objenome o, List<SetNumericValue> variables) {
    
    this.variables = variables;
    this.objenome = o;
    
    if (numStarts==-1)
        numStarts = variables.size() * 2;
    
    double[] lower = new double[variables.size()];
    double[] upper = new double[variables.size()];
    double[] mid = new double[variables.size()];
    int j = 0;
    for (SetNumericValue n : variables) {
        lower[j] = n.getMin().doubleValue();
        upper[j] = n.getMax().doubleValue();
        mid[j] = (lower[j] + upper[j]) * 0.5f;
        j++;
    }
    
    //TODO add MultiStart
    
    MultivariateOptimizer optimize = 
            new BOBYQAOptimizer(variables.size()*2);
            //new PowellOptimizer(0.01, 0.05);
    
    RandomGenerator rng = getRandomGenerator();
    
    MultiStartMultivariateOptimizer multiOptimize = new MultiStartMultivariateOptimizer(optimize, numStarts, new UncorrelatedRandomVectorGenerator(variables.size(), new UniformRandomGenerator(rng)));
    
    PointValuePair result = multiOptimize.optimize(
            new MaxEval(evaluations),
            new SimpleBounds(lower, upper),
            goal,
            new InitialGuess(mid),
            new ObjectiveFunction(this)
            );        
    
    apply(result.getPointRef());
            
    this.bestValue = result.getValue();
}
 
开发者ID:automenta,项目名称:objenome_prototype,代码行数:43,代码来源:OptimizeMultivariate.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java BoostingQuery类代码示例发布时间:2022-05-23
下一篇:
Java SVNDeltaGenerator类代码示例发布时间: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