public void Unimodal_SquareReversed()
        {
            var    f = new SquareReversedTestFunction().FunctionValueAnalysisFor1D();
            var    a = f.ValueWithDerivative(-1);
            Number b = 2;

            ushort i = _method.FindOptimal(in f, a, b, out NumberFunctionPointWithDerivative solution);

            solution.X.AssertIsEqualTo(-1);
            i.AssertIsEqualTo(23);
        }
        public void Unimodal_SquareReversed()
        {
            var f = new SquareReversedTestFunction().FunctionValueAnalysisFor1D();
            var a = f.ValueWithDerivative(-1);
            var b = f.ValueWithDerivative(2);

            var point = new NumberFunctionOptimizationSearchRange(a: a, b: b);

            point.BorderSmaller.X.AssertIsEqualTo(-1);
            point.BorderSmaller.Y.AssertIsEqualTo(-1);

            ushort i = _method.FindOptimal(in f, ref point);

            point.BorderSmaller.X.AssertIsEqualTo(-1);
            i.AssertIsEqualTo(23);
        }
Ejemplo n.º 3
0
        public void Unimodal_SquareReversed_Maximum()
        {
            var f = new SquareReversedTestFunction().FunctionValueAnalysisFor1D();
            var a = f.ValueWithDerivative(-1);
            var b = f.ValueWithDerivative(3);

            try
            {
                _optimizer.MoveNext(f, in a, b.X, out _);
                throw new Exception("I should never get here");
            }
            catch (AssertException)
            {
                // all is fine
            }
        }
        public void Unimodal_SquareReversed()
        {
            var f = new SquareReversedTestFunction().FunctionValueAnalysisFor1D();
            var a = f.ValueWithDerivative(-1);
            var b = f.ValueWithDerivative(2);

            var point = new NumberFunctionOptimizationSearchRange(a: a, b: b);

            point.BorderSmaller.X.AssertIsEqualTo(-1);
            point.BorderSmaller.Y.AssertIsEqualTo(-1);

            point.IsEmptyRange.AssertIsFalse();
            try
            {
                _method.MoveNext(in f, ref point);
                throw new Exception("I should never get here");
            }
            catch (AssertException)
            {
                // all is fine
            }
        }