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

Java AllowedSolution类代码示例

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

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



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

示例1: solve

import org.apache.commons.math3.analysis.solvers.AllowedSolution; //导入依赖的package包/类
/**
 * Solve for a zero in the given interval, start at {@code startValue}.
 * A solver may require that the interval brackets a single zero root.
 * Solvers that do require bracketing should be able to handle the case
 * where one of the endpoints is itself a root.
 *
 * @param maxEval Maximum number of evaluations.
 * @param f Function to solve.
 * @param min Lower bound for the interval.
 * @param max Upper bound for the interval.
 * @param startValue Start value to use.
 * @param allowedSolution The kind of solutions that the root-finding algorithm may
 * accept as solutions.
 * @return a value where the function is zero.
 * @exception NullArgumentException if f is null.
 * @exception NoBracketingException if root cannot be bracketed
 */
public Dfp solve(final int maxEval, final UnivariateDfpFunction f,
                 final Dfp min, final Dfp max, final Dfp startValue,
                 final AllowedSolution allowedSolution)
    throws NullArgumentException, NoBracketingException {

    // checks
    MathUtils.checkNotNull(f);

    // wrap the function
    RealFieldUnivariateFunction<Dfp> fieldF = new RealFieldUnivariateFunction<Dfp>() {

        /** {@inheritDoc} */
        public Dfp value(final Dfp x) {
            return f.value(x);
        }
    };

    // delegate to general field solver
    return solve(maxEval, fieldF, min, max, startValue, allowedSolution);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:39,代码来源:BracketingNthOrderBrentSolverDFP.java


示例2: testConvergenceOnFunctionAccuracy

import org.apache.commons.math3.analysis.solvers.AllowedSolution; //导入依赖的package包/类
@Test
public void testConvergenceOnFunctionAccuracy() {
    BracketingNthOrderBrentSolverDFP solver =
            new BracketingNthOrderBrentSolverDFP(relativeAccuracy, absoluteAccuracy,
                                                 field.newDfp(1.0e-20), 20);
    UnivariateDfpFunction f = new UnivariateDfpFunction() {
        public Dfp value(Dfp x) {
            Dfp one     = field.getOne();
            Dfp oneHalf = one.divide(2);
            Dfp xMo     = x.subtract(one);
            Dfp xMh     = x.subtract(oneHalf);
            Dfp xPh     = x.add(oneHalf);
            Dfp xPo     = x.add(one);
            return xMo.multiply(xMh).multiply(x).multiply(xPh).multiply(xPo);
        }
    };

    Dfp result = solver.solve(20, f, field.newDfp(0.2), field.newDfp(0.9),
                              field.newDfp(0.4), AllowedSolution.BELOW_SIDE);
    Assert.assertTrue(f.value(result).abs().lessThan(solver.getFunctionValueAccuracy()));
    Assert.assertTrue(f.value(result).negativeOrNull());
    Assert.assertTrue(result.subtract(field.newDfp(0.5)).subtract(solver.getAbsoluteAccuracy()).positiveOrNull());
    result = solver.solve(20, f, field.newDfp(-0.9), field.newDfp(-0.2),
                          field.newDfp(-0.4), AllowedSolution.ABOVE_SIDE);
    Assert.assertTrue(f.value(result).abs().lessThan(solver.getFunctionValueAccuracy()));
    Assert.assertTrue(f.value(result).positiveOrNull());
    Assert.assertTrue(result.add(field.newDfp(0.5)).subtract(solver.getAbsoluteAccuracy()).negativeOrNull());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:29,代码来源:BracketingNthOrderBrentSolverDFPTest.java


示例3: solve

import org.apache.commons.math3.analysis.solvers.AllowedSolution; //导入依赖的package包/类
/**
 * Solve for a zero in the given interval.
 * A solver may require that the interval brackets a single zero root.
 * Solvers that do require bracketing should be able to handle the case
 * where one of the endpoints is itself a root.
 *
 * @param maxEval Maximum number of evaluations.
 * @param f Function to solve.
 * @param min Lower bound for the interval.
 * @param max Upper bound for the interval.
 * @param allowedSolution The kind of solutions that the root-finding algorithm may
 * accept as solutions.
 * @return a value where the function is zero.
 * @exception NullArgumentException if f is null.
 * @exception NoBracketingException if root cannot be bracketed
 */
public Dfp solve(final int maxEval, final UnivariateDfpFunction f,
                 final Dfp min, final Dfp max, final AllowedSolution allowedSolution)
    throws NullArgumentException, NoBracketingException {
    return solve(maxEval, f, min, max, min.add(max).divide(2), allowedSolution);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:BracketingNthOrderBrentSolverDFP.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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