private Pair EighthStep() { if (functionHandler.Calculate(xPairs[k + 1].x1, xPairs[k + 1].x2) - functionHandler.Calculate(xPairs[k].x1, xPairs[k].x2) < 0 || functionHandler.Calculate(xPairs[k + 1].x1, xPairs[k + 1].x2) - functionHandler.Calculate(xPairs[k].x1, xPairs[k].x2) < -e * Math.Pow(Quadratic(deltaFResults[k]), 2)) { return(NinthStep()); } tk /= 2.0; return(SeventhStep()); }
public void Calculate_ShouldReturnXPosWhereFunctionResultIsMinimum() { var functionHandler = new TwoVarsFunc("2 * x1 ^ 2 + x1 * x2 + x2 ^ 2"); var constantStepGradientDescent = new ConstantStepGradientDescent(0.5, 1, 0.5, 0.1, 0.15, 10, 0.5, functionHandler); var pair = constantStepGradientDescent.Calculate(); var result = Math.Round(functionHandler.Calculate(pair.x1, pair.x2) * 10000) / 10000; Assert.AreEqual(0.0075, result); }