Пример #1
0
        public QpProgressReport  Run(SpreadSheetExample example)
        {
            Matrix <double> basisVectors = Matrix <double> .Build.DenseOfArray(example.BasisVectors);

            Vector <double> targetVector = Vector <double> .Build.DenseOfEnumerable(example.TargetVector);

            var assembler = new QpLeastSquaresFormulator();

            QpProblem problem = assembler
                                .WithBasisVectors(basisVectors)
                                .WithTargetVector(targetVector)
                                .WithLowerConstraints(example.LowerConstraint)
                                .WithUpperConstraints(example.UpperConstraint)
                                .SetupProblem();

            IQpProgressReportBroadcaster publisher   = new QpProgressReportPublisher();
            IQpInitialPointStrategy      warmStarter = new QpWarmStarter();

            var listener = new ConsoleOutputService();

            listener.Subscribe(publisher);

            var solver = new PredictorCorrectorSolver(
                new QpPreSolver(problem.A, problem.b),
                warmStarter,
                new QpProgressAnalyser(problem, true),
                publisher);

            return(solver.Solve(problem));
        }
Пример #2
0
 // here our dependencies are "injected" into this class, that's depedency injection,
 // really that's it!
 public Magic8BallSimulator(MessageService messageService, ConsoleInputService inputService,
                            ConsoleOutputService outputService)
 {
     _messageService = messageService;
     _inputService   = inputService;
     _outputService  = outputService;
 }
Пример #3
0
        public FileTest(string lpPath, string touPath)
        {
            ConsoleOutputService svc = new ConsoleOutputService();

            this._lpPath  = lpPath;
            this._touPath = touPath;
            _lpService    = new LPService(svc);
            _touService   = new TOUService(svc);
        }
Пример #4
0
        public SortUnitTest(string inputFile)
        {
            ConsoleOutputService svc = new ConsoleOutputService();

            _inputFile              = inputFile;
            _fileService            = new FileOutputService();
            _forwardNameSortWorker  = new NameSortWorker(new ForwardSortStrategy());
            _backwardNameSortWorker = new NameSortWorker(new BackwardSortStrategy());
        }
Пример #5
0
        protected override void Enable()
        {
            // ServiceLoader contains all services currently loaded.
            // There are also PlatformLoader and MuffinLoader.

            this._output = this.ServiceLoader.Get <ConsoleOutputService>();

            this._output.WriteLine("Started working");

            Thread.Sleep(2000);
            this._output.WriteLine("Task 1 complete.");

            Thread.Sleep(5000);
            this._output.WriteLine("Task 2 complete.");
        }
Пример #6
0
        public void AcSolver()
        {
            // Arrange
            IQpProgressReportBroadcaster publisher   = new QpProgressReportPublisher();
            IQpInitialPointStrategy      warmStarter = new QpWarmStarter();
            var listener = new ConsoleOutputService();

            listener.Subscribe(publisher);

            var solver = new PredictorCorrectorSolver(
                new QpPreSolver(problem.A, problem.b),
                new QpWarmStarter(),
                new QpProgressAnalyser(problem, true),
                new QpProgressReportPublisher());

            // Act
            QpProgressReport solution = solver.Solve(problem);

            // Assert
            var check = solution.X + problem.c;

            Assert.IsTrue(check.Norm(2) < (1e-8 * n));
        }
 public Magic8BallSimulatorEvenWorse()
 {
     _messageService = new MessageService();
     _inputService   = new ConsoleInputService();
     _outputService  = new ConsoleOutputService();
 }