private static async Task PerformTesting( int[] sizes, MatrixProvider provider, ResultsSaver saver, IEquationSolver solver, Action <Matrix> matrixAction = null) { Stopwatch stopwatch = new Stopwatch(); foreach (int size in sizes) { Matrix matrix = provider.GetMatrix(size); if (matrixAction != null) { matrixAction(matrix); } stopwatch.Start(); CalculationResult result = solver.Solve(matrix); stopwatch.Stop(); Console.WriteLine($"{size}x{size} ({result.Answers.Length}): {stopwatch.ElapsedMilliseconds}ms, {stopwatch.ElapsedTicks} ticks"); stopwatch.Reset(); string outputFile = string.Format(OutputFileTemplate, $"{size}x{size}", solver.GetType()); await saver.SaveAsync(outputFile, result); } }
public void Initialize() { var webCalcItem = new WebCalculator.Models.CalculatorInput(); var operatorTypes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(ass => ass.GetTypes()) .Where(type => type.GetInterfaces().Contains(typeof(IOperator)) && !type.IsAbstract && !type.IsInterface && type.IsPublic); this.EquationSolver = new EquationSolver(operatorTypes); }
/// <summary> /// Ctor using start DateTime for when this Scheduler becomes active /// </summary> /// <param name="start">the starting DateTime</param> /// <param name="interval">How often to check the scheduled items</param> /// <param name="duration">How long will this Scheduler be active</param> public Orchestrator(string name, DateTime start, TimeSpan interval, TimeSpan duration, IOrchestratorRepository <T> repository, IEquationSolver solver = null) { StartDateTime = start; Interval = interval; EndDateTime = DateTime.Now + duration; Name = name; Repository = repository; if (solver != null) { Solver = solver; } }
public void Setup() { _formatter = new EquationSolver(); }
/// <summary> /// Ctor using DateTime.Now as starting DateTime /// </summary> /// <param name="interval">Timespan interval of execution on eligible ScheduleItems</param> /// <param name="duration">How long for this scheduler to remain active</param> public Orchestrator(string name, TimeSpan interval, TimeSpan duration, IOrchestratorRepository <T> repository, IEquationSolver solver = null) : this(name, DateTime.Now, interval, duration, repository, solver) { }
/// <summary> /// Ctor for defining interval and name of orchestrator /// </summary> /// <param name="name">Name of the Orchestrator</param> /// <param name="interval">the interval to use for schedule items</param> /// <param name="solver">the equation solver to use for orchestrating schedule items</param> public Orchestrator(string name, TimeSpan interval, IOrchestratorRepository <T> repository, IEquationSolver solver = null) : this(name, interval, TimeSpan.FromDays(365 * 10), repository, solver) { }
/// <summary> /// Minimal Ctor /// </summary> /// <param name="name">Name of Orchestrator</param> /// <param name="solver">the equation solver to use for orchestrating schedule items</param> public Orchestrator(string name, IOrchestratorRepository <T> repository, IEquationSolver solver = null) : this(name, TimeSpan.FromSeconds(1), repository, solver) { }
public CalculatorController(IEquationSolver solver, IOperatorTypeLoader typeLoader) { this.Solver = solver; this.OperatorTypeLoader = typeLoader; }
public OperatorLoadingEquationSolver() { var types = new OperatorTypeLoader().LoadOperatorTypes(); DefaultSolver = new EquationSolver(types); }