예제 #1
0
        public QpProgressReport Solve(QpProblem data)
        {
            QpProgressReport report = this.preSolver.PreSolve();

            if (report.SolveStatus != QpTerminationCode.InProgress)
            {
                return(report);
            }

            // Set up the problem from the warm start strategy
            Variables    currentIterate  = this.warmStartStrategy.GenerateInitialPoint(data, report.X);
            NewtonSystem newtonEquations = this.warmStartStrategy.InitialNewtonEquations;
            Residuals    residuals       = this.warmStartStrategy.InitialResiduals;

            double mu = currentIterate.Mu();

            int count = 0;

            do
            {
                // Analyse and report on the algorithm progress
                report = this.statusReporter.DetermineProgress(currentIterate, residuals, mu, count);
                this.publisher.Publish(report);

                if (report.SolveStatus != QpTerminationCode.InProgress)
                {
                    break;
                }

                // ~~~~~ Predictor Step ~~~~~
                // Factorise the system of equations using a Newton method
                ISolver <double> choleskyFactor = newtonEquations.Factorize(currentIterate, count);
                Variables        step           = newtonEquations.ComputeStep(currentIterate, residuals, choleskyFactor);

                // Calculate the largest permissable step length (alpha affine)
                double alpha = currentIterate.GetLargestAlphaForStep(step);

                // Calculate the complementarity measure and associated centering parameter.
                double muAffine = currentIterate.MuGivenStep(step, alpha);
                double sigma    = Math.Pow(muAffine / mu, 3);

                // ~~~~~ Corrector Step ~~~~~
                // Apply second order step corrections and a re-centering adjustment.
                residuals.ApplyCorrection(step, sigma, mu);

                // Compute the corrected step and largest permitted step length.
                step  = newtonEquations.ComputeStep(currentIterate, residuals, choleskyFactor);
                alpha = currentIterate.GetLargestAlphaForStep(step);

                // Finally take the step and calculate the new complementarity measure.
                currentIterate.ApplyStep(step, alpha);
                residuals.Update(currentIterate);
                mu = currentIterate.Mu();

                count++;
            } while (report.SolveStatus == QpTerminationCode.InProgress && count < 10000);

            return(report);
        }
예제 #2
0
        public Variables GenerateInitialPoint(QpProblem problem, Vector<double> x)
        {
            Vector<double> z = Vector<double>.Build.Dense(problem.A.ColumnCount, 1);
            Vector<double> s = Vector<double>.Build.Dense(problem.A.ColumnCount, 1);

            Variables initialPoint = new Variables(x, z, s);

            this.startingResiduals = new Residuals(problem, initialPoint);
            this.startingEquations = new NewtonSystem(problem, initialPoint);

            return initialPoint;
        }
예제 #3
0
        public Variables GenerateInitialPoint(QpProblem problem, Vector <double> x)
        {
            Vector <double> z = Vector <double> .Build.Dense(problem.A.ColumnCount, 1);

            Vector <double> s = Vector <double> .Build.Dense(problem.A.ColumnCount, 1);

            Variables initialPoint = new Variables(x, z, s);

            this.startingResiduals = new Residuals(problem, initialPoint);
            this.startingEquations = new NewtonSystem(problem, initialPoint);

            return(initialPoint);
        }
예제 #4
0
        public Variables GenerateInitialPoint(QpProblem problem, Vector<double> x)
        {
            var initialPoint = this.BuildVariables(problem, x);

            this.startingResiduals = new Residuals(problem, initialPoint);
            this.startingEquations = new NewtonSystem(problem, initialPoint);

            ISolver<double> choleskyFactor = this.startingEquations.InitialCholeskyFactor;
            Variables step = this.startingEquations.ComputeStep(initialPoint, this.startingResiduals, choleskyFactor);

            initialPoint.UpdateMultipliersWithoutViolation(step);

            this.startingResiduals.Update(initialPoint);

            return initialPoint;
        }
예제 #5
0
        public Variables GenerateInitialPoint(QpProblem problem, Vector <double> x)
        {
            var initialPoint = this.BuildVariables(problem, x);

            this.startingResiduals = new Residuals(problem, initialPoint);
            this.startingEquations = new NewtonSystem(problem, initialPoint);

            ISolver <double> choleskyFactor = this.startingEquations.InitialCholeskyFactor;
            Variables        step           = this.startingEquations.ComputeStep(initialPoint, this.startingResiduals, choleskyFactor);

            initialPoint.UpdateMultipliersWithoutViolation(step);

            this.startingResiduals.Update(initialPoint);

            return(initialPoint);
        }