Example #1
0
        public NewtonSystem(QpProblem data, Variables initialPoint)
        {
            this.Q = data.Q;
            this.A = data.A;

            this.initialCholeskyFactor = this.Factorize(initialPoint);
        }
Example #2
0
        public NewtonSystem(QpProblem data, Variables initialPoint)
        {
            this.Q = data.Q;
            this.A = data.A;

            this.initialCholeskyFactor = this.Factorize(initialPoint);
        }
Example #3
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);
        }
Example #4
0
        private Variables BuildVariables(QpProblem problem, Vector<double> x)
        {
            double sqrtDataNorm = System.Math.Sqrt(problem.InfinityNorm());

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

            return new Variables(x, z, s);
        }
Example #5
0
        public Residuals(QpProblem data, Variables iterate)
        {
            this.Q = data.Q;
            this.c = data.c;
            this.A = data.A;
            this.b = data.b;

            this.Initialise();
            this.Update(iterate);
        }
Example #6
0
        private Variables BuildVariables(QpProblem problem, Vector <double> x)
        {
            double sqrtDataNorm = System.Math.Sqrt(problem.InfinityNorm());

            Vector <double> z = Vector <double> .Build.Dense(problem.A.ColumnCount, sqrtDataNorm);

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

            return(new Variables(x, z, s));
        }
Example #7
0
        public Residuals(QpProblem data, Variables iterate)
        {
            this.Q = data.Q;
            this.c = data.c;
            this.A = data.A;
            this.b = data.b;

            this.Initialise();
            this.Update(iterate);
        }
Example #8
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;
        }
        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;
        }
Example #10
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);
        }
Example #11
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;
        }
Example #12
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);
        }
Example #13
0
 public QpProgressAnalyser(QpProblem data, bool includeDeatiledReport)
 {
     this.dataInfinityNorm      = data.InfinityNorm();
     this.includeDetailedReport = includeDeatiledReport;
     this.phiMinimumHistory     = new double[MaxIterations];
 }
 public QpProgressAnalyser(QpProblem data, bool includeDeatiledReport)
 {
     this.dataInfinityNorm = data.InfinityNorm();
     this.includeDetailedReport = includeDeatiledReport;
     this.phiMinimumHistory = new double[MaxIterations];
 }