本文整理汇总了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;未经允许,请勿转载。 |
请发表评论