private static void Main(CommandLineArguments arguments) { var hub = new AlgorithmFacade(arguments.ToFunctionStrategy(), arguments.VariablesCount, arguments.ToModifiedAlgorithmSettings()); hub.StepFinished += HubOnStepFinished; var result = hub.FindExtremeAsync().Result; Console.WriteLine($"Result is {string.Join(",", result)}"); }
private void AssertFuncion(Func <double[], double> func, int variablesCount, int steps, double expected, double eps) { // Assert var all = new List <double>(); var fails = new List <FailResult>(); for (var i = 0; i < RepeatTest; i++) { var performer = new AlgorithmFacade(func, variablesCount, Create(steps)); // Act var result = performer.FindExtremeAsync().Result; // Assert var delta = Math.Abs(expected - result); if (delta > eps) { fails.Add(new FailResult(delta, i)); } all.Add(delta); } if (fails.Count > 0) { var failedSteps = fails.Aggregate("", (result, next) => result + next.Step + ", "); failedSteps.Remove(failedSteps.Length - 2); var deltas = fails.Aggregate("", (result, next) => result + next.Delta + ", "); deltas.Remove(deltas.Length - 2); throw new Exception($"Failed on steps {failedSteps} with delta: {deltas}." + $"Params - {nameof(variablesCount)} = {variablesCount}; " + $"{nameof(steps)} = {steps}; " + $"{nameof(expected)} = {expected}; " + $"{nameof(eps)} = {eps}"); } (all.Average() / eps).ShouldBeGreaterThan(MinDeviation, "Assertion EPS is too big. Decrese EPS"); }