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 solverHack = new PredictorCorrectorSolver(
                new QpPreSolver(problem.A, problem.b),
                warmStarter,
                new QpProgressAnalyser(problem, true),
                publisher);

            return solverHack.Solve(problem);
        }
Exemple #2
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));
        }