Esempio n. 1
0
        public void Unimodal_Square_Optimum()
        {
            var f = new SquareTestFunction().FunctionValueAnalysisFor1D();
            var a = f.ValueWithDerivative(0);
            var b = f.ValueWithDerivative(3);

            NumberFunctionPointWithDerivative actual = _optimizer.MoveNext(f, in a, b.X, out uint complexity);

            actual.X.AssertIsEqualTo(1);
            complexity.AssertIsEqualTo(1u);
        }
        public void AssignBorderGreater()
        {
            NumberFunctionPointWithDerivative     a     = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(0);
            NumberFunctionPointWithDerivative     b     = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(3);
            NumberFunctionOptimizationSearchRange range = new(in a, in b);

            range.BorderSmaller.X.AssertIsEqualTo(a.X);
            range.BorderGreater.X.AssertIsEqualTo(b.X);

            range.BorderGreater = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(3.5);

            range.BorderSmaller.X.AssertIsEqualTo(a.X);
            range.BorderGreater.X.AssertIsEqualTo(3.5);
        }
        public void AssignBorderLowestDerivative()
        {
            NumberFunctionPointWithDerivative     a     = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(0);
            NumberFunctionPointWithDerivative     b     = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(3);
            NumberFunctionOptimizationSearchRange range = new(in a, in b);

            range.BorderLowestDerivative.X.AssertIsEqualTo(a.X);
            range.BorderHighestDerivative.X.AssertIsEqualTo(b.X);

            range.BorderLowestDerivative = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(1.5);

            range.BorderLowestDerivative.X.AssertIsEqualTo(1.5);
            range.BorderHighestDerivative.X.AssertIsEqualTo(b.X);
        }
        public void ReadConstructorOptimum()
        {
            NumberFunctionPointWithDerivative     a     = _function.FunctionValueAnalysisFor1D().ValueWithDerivative(0);
            NumberFunctionOptimizationSearchRange range = new(in a, in a);

            range.Start.X.AssertIsEqualTo(a.X);
            range.End.X.AssertIsEqualTo(a.X);
            range.Width.AssertIsEqualTo(0);
            range.IsEmptyRange.AssertIsTrue();

            range.BorderSmaller.X.AssertIsEqualTo(a.X);
            range.BorderGreater.X.AssertIsEqualTo(a.X);

            range.BorderLowestDerivative.X.AssertIsEqualTo(a.X);
            range.BorderHighestDerivative.X.AssertIsEqualTo(a.X);
        }