コード例 #1
0
ファイル: BisectionSolver.cs プロジェクト: JohannesMP/Essence
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        protected internal override double DoSolve()
        {
            double min = this.Min;
            double max = this.Max;

            this.VerifyInterval(min, max);
            double absoluteAccuracy = this.AbsoluteAccuracy;
            double m;
            double fm;
            double fmin;

            while (true)
            {
                m    = UnivariateSolverUtils.Midpoint(min, max);
                fmin = this.ComputeObjectiveValue(min);
                fm   = this.ComputeObjectiveValue(m);

                if (fm * fmin > 0)
                {
                    // max and m bracket the root.
                    min = m;
                }
                else
                {
                    // min and m bracket the root.
                    max = m;
                }

                if (FastMath.Abs(max - min) <= absoluteAccuracy)
                {
                    m = UnivariateSolverUtils.Midpoint(min, max);
                    return(m);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        protected internal override double DoSolve()
        {
            double min = GetMin();
            double max = GetMax();

            VerifyInterval(min, max);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double absoluteAccuracy = getAbsoluteAccuracy();
            double absoluteAccuracy = GetAbsoluteAccuracy();
            double m;
            double fm;
            double fmin;

            while (true)
            {
                m    = UnivariateSolverUtils.Midpoint(min, max);
                fmin = ComputeObjectiveValue(min);
                fm   = ComputeObjectiveValue(m);

                if (fm * fmin > 0)
                {
                    // max and m bracket the root.
                    min = m;
                }
                else
                {
                    // min and m bracket the root.
                    max = m;
                }

                if (FastMath.Abs(max - min) <= absoluteAccuracy)
                {
                    m = UnivariateSolverUtils.Midpoint(min, max);
                    return(m);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Find a zero near the midpoint of {@code min} and {@code max}.
        /// </summary>
        /// <param name="f"> Function to solve. </param>
        /// <param name="min"> Lower bound for the interval. </param>
        /// <param name="max"> Upper bound for the interval. </param>
        /// <param name="maxEval"> Maximum number of evaluations. </param>
        /// <returns> the value where the function is zero. </returns>
        /// <exception cref="org.apache.commons.math3.exception.TooManyEvaluationsException">
        /// if the maximum evaluation count is exceeded. </exception>
        /// <exception cref="org.apache.commons.math3.exception.NumberIsTooLargeException">
        /// if {@code min >= max}. </exception>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public double solve(int maxEval, final org.apache.commons.math3.analysis.DifferentiableUnivariateFunction f, final double min, final double max) throws org.apache.commons.math3.exception.TooManyEvaluationsException
        public virtual double Solve(int maxEval, DifferentiableUnivariateFunction f, double min, double max)
        {
            return(base.Solve(maxEval, f, UnivariateSolverUtils.Midpoint(min, max)));
        }
コード例 #4
0
        /// <summary>
        /// Find a zero near the midpoint of {@code min} and {@code max}.
        /// </summary>
        /// <param name="f"> Function to solve. </param>
        /// <param name="min"> Lower bound for the interval. </param>
        /// <param name="max"> Upper bound for the interval. </param>
        /// <param name="maxEval"> Maximum number of evaluations. </param>
        /// <returns> the value where the function is zero. </returns>
        /// <exception cref="org.apache.commons.math3.exception.TooManyEvaluationsException">
        /// if the maximum evaluation count is exceeded. </exception>
        /// <exception cref="org.apache.commons.math3.exception.NumberIsTooLargeException">
        /// if {@code min >= max}. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public double solve(int maxEval, final org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction f, final double min, final double max) throws org.apache.commons.math3.exception.TooManyEvaluationsException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        public override double Solve(int maxEval, UnivariateDifferentiableFunction f, double min, double max)
        {
            return(base.Solve(maxEval, f, UnivariateSolverUtils.Midpoint(min, max)));
        }