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

Java SimplexOptimizer类代码示例

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

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



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

示例1: optimize

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
/**
 * Optimizes parameters using the Nelder-Mead Method
 * @param initialGuess initial guess / state required for Nelder-Mead-Method
 * @param costFunction which defines that the Mean Squared Error has to be minimized
 * @return the optimized values
 */
private static double[] optimize(double[] initialGuess, MultivariateFunctionMappingAdapter costFunction) {
    double[] result;

    SimplexOptimizer optimizer = new SimplexOptimizer(simplexRelativeThreshold, simplexAbsoluteThreshold);

    PointValuePair unBoundedResult = optimizer.optimize(
            GoalType.MINIMIZE,
            new MaxIter(MAX_ALLOWED_NUMBER_OF_ITERATION),
            new MaxEval(MAX_ALLOWED_NUMBER_OF_EVALUATION),
            new InitialGuess(initialGuess),
            new ObjectiveFunction(costFunction),
            new NelderMeadSimplex(initialGuess.length));

    result = costFunction.unboundedToBounded(unBoundedResult.getPoint());
    return result;
}
 
开发者ID:lidox,项目名称:reaction-test,代码行数:23,代码来源:NelderMeadOptimizer.java


示例2: testStartSimplexInsideRange

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testStartSimplexInsideRange() {
    final BiQuadratic biQuadratic = new BiQuadratic(2.0, 2.5, 1.0, 3.0, 2.0, 3.0);
    final MultivariateFunctionMappingAdapter wrapped
        = new MultivariateFunctionMappingAdapter(biQuadratic,
                                                 biQuadratic.getLower(),
                                                 biQuadratic.getUpper());

    SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[][] {
            wrapped.boundedToUnbounded(new double[] { 1.5, 2.75 }),
            wrapped.boundedToUnbounded(new double[] { 1.5, 2.95 }),
            wrapped.boundedToUnbounded(new double[] { 1.7, 2.90 })
        });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(300),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(wrapped.boundedToUnbounded(new double[] { 1.5, 2.25 })));
    final double[] bounded = wrapped.unboundedToBounded(optimum.getPoint());

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), bounded[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), bounded[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:MultivariateFunctionMappingAdapterTest.java


示例3: testOptimumOutsideRange

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testOptimumOutsideRange() {
    final BiQuadratic biQuadratic = new BiQuadratic(4.0, 0.0, 1.0, 3.0, 2.0, 3.0);
    final MultivariateFunctionMappingAdapter wrapped
        = new MultivariateFunctionMappingAdapter(biQuadratic,
                                                 biQuadratic.getLower(),
                                                 biQuadratic.getUpper());

    SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[][] {
            wrapped.boundedToUnbounded(new double[] { 1.5, 2.75 }),
            wrapped.boundedToUnbounded(new double[] { 1.5, 2.95 }),
            wrapped.boundedToUnbounded(new double[] { 1.7, 2.90 })
        });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(100),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(wrapped.boundedToUnbounded(new double[] { 1.5, 2.25 })));
    final double[] bounded = wrapped.unboundedToBounded(optimum.getPoint());

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), bounded[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), bounded[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:MultivariateFunctionMappingAdapterTest.java


示例4: testStartSimplexInsideRange

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testStartSimplexInsideRange() {
    final BiQuadratic biQuadratic = new BiQuadratic(2.0, 2.5, 1.0, 3.0, 2.0, 3.0);
    final MultivariateFunctionPenaltyAdapter wrapped
          = new MultivariateFunctionPenaltyAdapter(biQuadratic,
                                                   biQuadratic.getLower(),
                                                   biQuadratic.getUpper(),
                                                   1000.0, new double[] { 100.0, 100.0 });

    SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[] { 1.0, 0.5 });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(300),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { 1.5, 2.25 }));

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), optimum.getPoint()[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), optimum.getPoint()[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:23,代码来源:MultivariateFunctionPenaltyAdapterTest.java


示例5: testStartSimplexOutsideRange

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testStartSimplexOutsideRange() {
    final BiQuadratic biQuadratic = new BiQuadratic(2.0, 2.5, 1.0, 3.0, 2.0, 3.0);
    final MultivariateFunctionPenaltyAdapter wrapped
          = new MultivariateFunctionPenaltyAdapter(biQuadratic,
                                                   biQuadratic.getLower(),
                                                   biQuadratic.getUpper(),
                                                   1000.0, new double[] { 100.0, 100.0 });

    SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[] { 1.0, 0.5 });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(300),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { -1.5, 4.0 }));

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), optimum.getPoint()[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), optimum.getPoint()[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:23,代码来源:MultivariateFunctionPenaltyAdapterTest.java


示例6: testOptimumOutsideRange

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testOptimumOutsideRange() {
    final BiQuadratic biQuadratic = new BiQuadratic(4.0, 0.0, 1.0, 3.0, 2.0, 3.0);
    final MultivariateFunctionPenaltyAdapter wrapped
        =  new MultivariateFunctionPenaltyAdapter(biQuadratic,
                                                  biQuadratic.getLower(),
                                                  biQuadratic.getUpper(),
                                                  1000.0, new double[] { 100.0, 100.0 });

    SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<PointValuePair>(1.0e-11, 1.0e-20));
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[] { 1.0, 0.5 });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(600),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { -1.5, 4.0 }));

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), optimum.getPoint()[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), optimum.getPoint()[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:23,代码来源:MultivariateFunctionPenaltyAdapterTest.java


示例7: testUnbounded

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testUnbounded() {
    final BiQuadratic biQuadratic = new BiQuadratic(4.0, 0.0,
                                                    Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
                                                    Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    final MultivariateFunctionPenaltyAdapter wrapped
        = new MultivariateFunctionPenaltyAdapter(biQuadratic,
                                                 biQuadratic.getLower(),
                                                 biQuadratic.getUpper(),
                                                 1000.0, new double[] { 100.0, 100.0 });

    SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[] { 1.0, 0.5 });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(300),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { -1.5, 4.0 }));

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), optimum.getPoint()[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), optimum.getPoint()[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:MultivariateFunctionPenaltyAdapterTest.java


示例8: testHalfBounded

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Test
public void testHalfBounded() {
    final BiQuadratic biQuadratic = new BiQuadratic(4.0, 4.0,
                                                    1.0, Double.POSITIVE_INFINITY,
                                                    Double.NEGATIVE_INFINITY, 3.0);
    final MultivariateFunctionPenaltyAdapter wrapped
          = new MultivariateFunctionPenaltyAdapter(biQuadratic,
                                                   biQuadratic.getLower(),
                                                   biQuadratic.getUpper(),
                                                   1000.0, new double[] { 100.0, 100.0 });

    SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<PointValuePair>(1.0e-10, 1.0e-20));
    final AbstractSimplex simplex = new NelderMeadSimplex(new double[] { 1.0, 0.5 });

    final PointValuePair optimum
        = optimizer.optimize(new MaxEval(400),
                             new ObjectiveFunction(wrapped),
                             simplex,
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { -1.5, 4.0 }));

    Assert.assertEquals(biQuadratic.getBoundedXOptimum(), optimum.getPoint()[0], 2e-7);
    Assert.assertEquals(biQuadratic.getBoundedYOptimum(), optimum.getPoint()[1], 2e-7);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:MultivariateFunctionPenaltyAdapterTest.java


示例9: applyToNetwork

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
@Override
public double applyToNetwork(final MixedClearingNetwork network) {
   Preconditions.checkNotNull(network);
   final SimplexOptimizer optimizer = new SimplexOptimizer(relErrorTarget, absErrorTarget);
   
   final ResidualCostFunction aggregateCostFunction =
      super.getResidualScalarCostFunction(network);
   final RealVector
      start = new ArrayRealVector(network.getNumberOfEdges());
   for(int i = 0; i< network.getNumberOfEdges(); ++i)
      start.setEntry(i, network.getEdges().get(i).getMaximumRateAdmissibleByBothParties());
   start.set(1.);
   
   final PointValuePair result = optimizer.optimize(
      new MaxEval(maximumEvaluations),
      new ObjectiveFunction(aggregateCostFunction),
      GoalType.MINIMIZE,
      new InitialGuess(start.toArray()),
      new NelderMeadSimplex(network.getNumberOfEdges())
      );
   
   final double residualCost = result.getValue();
   System.out.println("Network cleared: residual cost: " + residualCost + ".");
   
   return residualCost;
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:27,代码来源:NelderMeadClearingAlgorithm.java


示例10: findMin

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的package包/类
private UnivariatePointValuePair findMin(UnivariatePointValuePair current, SimplexOptimizer o,
		MultivariateFunction f, double qValue)
{
	try
	{
		NelderMeadSimplex simplex = new NelderMeadSimplex(1);
		double[] initialSolution = { qValue };
		PointValuePair solution = o.optimize(new MaxEval(1000), new InitialGuess(initialSolution), simplex,
				new ObjectiveFunction(f), GoalType.MINIMIZE);
		UnivariatePointValuePair next = (solution == null) ? null
				: new UnivariatePointValuePair(solution.getPointRef()[0], solution.getValue());
		if (next == null)
			return current;
		//System.out.printf("Simplex [%f]  %f = %f\n", qValue, 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,代码行数:24,代码来源:FIRE.java


示例11: findOptimum

import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer; //导入依赖的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.5 * SIMPLEX_EDGE);
  //Arrays.fill(startingVertex, -1 * SIMPLEX_EDGE);

  // TODO if there are convergence issues, change these guessed thresholds
  //SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30); 
  //SimplexOptimizer optimizer = new SimplexOptimizer(1e-4, 1e-4); 
  //SimplexOptimizer optimizer = new SimplexOptimizer(1e-2, 10); 
  SimplexOptimizer optimizer = new SimplexOptimizer(1e-3, 5); 
  //SimplexOptimizer optimizer = new SimplexOptimizer(1e-2, 5); 
 
  final PointValuePair optimum
      = optimizer.optimize(
          new MaxEval(numEval),
          new ObjectiveFunction(new OptimizerWrapperApacheObjective(tariffUtilityEstimate)),
          GoalType.MAXIMIZE,
          new InitialGuess(startingVertex), 
          //new NelderMeadSimplex(NUM_RATES, -1 * SIMPLEX_EDGE)); 
          new NelderMeadSimplex(NUM_RATES, SIMPLEX_EDGE));// should be positive since this reflects decrease in (negative) charges
  
  TreeMap<Double, TariffSpecification> eval2TOUTariff = new TreeMap<Double, TariffSpecification>();
  eval2TOUTariff.put(optimum.getValue(), tariffUtilityEstimate.getCorrespondingSpec(optimum.getKey()));
  return eval2TOUTariff;
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:28,代码来源:OptimizerWrapperApacheAmoeba.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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