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);
        }
Example #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));
        }
 public void PrintResults(QpProgressReport results, SpreadSheetExample example, Int64 elapsedMs, StringBuilder stringBuilder)
 {
     this.Display(new String('*', 50), stringBuilder);
     this.Display(example.Name, stringBuilder);
     this.Display(string.Format("Iterations: {0}", results.Iterations), stringBuilder);
     this.Display(string.Format("Elapsed time: {0}ms", elapsedMs), stringBuilder);
     this.Display("Solution: " + results.SolveStatus.ToString(), stringBuilder);
     this.Display(results.X, stringBuilder);
     this.Display(string.Empty, stringBuilder);
 }
Example #4
0
 public void PrintResults(QpProgressReport results, SpreadSheetExample example, Int64 elapsedMs, StringBuilder stringBuilder)
 {
     this.Display(new String('*', 50), stringBuilder);
     this.Display(example.Name, stringBuilder);
     this.Display(string.Format("Iterations: {0}", results.Iterations), stringBuilder);
     this.Display(string.Format("Elapsed time: {0}ms", elapsedMs), stringBuilder);
     this.Display("Solution: " + results.SolveStatus.ToString(), stringBuilder);
     this.Display(results.X, stringBuilder);
     this.Display(string.Empty, stringBuilder);
 }