public QpProgressReport DetermineProgress(Variables iterate, Residuals residuals, double mu, int count) { var code = QpTerminationCode.InProgress; double residualsNorm = residuals.InfinityNorm(); double phi = ComputeMeritFunction(residuals, residualsNorm); this.UpdateMeritFunctionHistory(phi, count); bool isMuSatisfied = (mu < Tolerance); bool isRnormSatisfied = (residualsNorm < Tolerance * this.dataInfinityNorm); if (isMuSatisfied && isRnormSatisfied) { code = QpTerminationCode.Success; } else if (count >= MaxIterations) { code = QpTerminationCode.MaxIterationsExceeded; } else if (count > 20 && phi >= 1e-8 && phi >= 1e4 * this.phiMinimumHistory[count - 1]) { code = QpTerminationCode.Infeasible; } else if (count >= 30 && this.phiMinimumHistory[count] >= .5 * this.phiMinimumHistory[count - 30]) { code = QpTerminationCode.Unknown; } return includeDetailedReport || code != QpTerminationCode.InProgress ? new QpProgressReport(code, count, phi, iterate.Clone()) : new QpProgressReport(code, count, phi, null); }
public QpProgressReport DetermineProgress(Variables iterate, Residuals residuals, double mu, int count) { var code = QpTerminationCode.InProgress; double residualsNorm = residuals.InfinityNorm(); double phi = ComputeMeritFunction(residuals, residualsNorm); this.UpdateMeritFunctionHistory(phi, count); bool isMuSatisfied = (mu < Tolerance); bool isRnormSatisfied = (residualsNorm < Tolerance * this.dataInfinityNorm); if (isMuSatisfied && isRnormSatisfied) { code = QpTerminationCode.Success; } else if (count >= MaxIterations) { code = QpTerminationCode.MaxIterationsExceeded; } else if (count > 20 && phi >= 1e-8 && phi >= 1e4 * this.phiMinimumHistory[count - 1]) { code = QpTerminationCode.Infeasible; } else if (count >= 30 && this.phiMinimumHistory[count] >= .5 * this.phiMinimumHistory[count - 30]) { code = QpTerminationCode.Unknown; } return(includeDetailedReport || code != QpTerminationCode.InProgress ? new QpProgressReport(code, count, phi, iterate.Clone()) : new QpProgressReport(code, count, phi, null)); }
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); }
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 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 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; }
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); }
public Variables ComputeStep(Variables currentIterate, Residuals residuals, ISolver<double> CholeskyFactor) { // Define shorter names Vector<double> z = currentIterate.z; Vector<double> s = currentIterate.s; Vector<double> rp = residuals.rp; Vector<double> rd = residuals.rd; Vector<double> rs = residuals.rs; Vector<double> r_bar = A * (rs - z.PointwiseMultiply(rp)).PointwiseDivide(s); Vector<double> c_bar = rd + r_bar; c_bar.Negate(c_bar); Vector<double> stepX = CholeskyFactor.Solve(c_bar); Vector<double> stepS = A.TransposeThisAndMultiply(stepX) - rp; Vector<double> stepZ = -(rs + z.PointwiseMultiply(stepS)).PointwiseDivide(s); return new Variables(stepX, stepZ, stepS); }
public Variables ComputeStep(Variables currentIterate, Residuals residuals, ISolver <double> CholeskyFactor) { // Define shorter names Vector <double> z = currentIterate.z; Vector <double> s = currentIterate.s; Vector <double> rp = residuals.rp; Vector <double> rd = residuals.rd; Vector <double> rs = residuals.rs; Vector <double> r_bar = A * (rs - z.PointwiseMultiply(rp)).PointwiseDivide(s); Vector <double> c_bar = rd + r_bar; c_bar.Negate(c_bar); Vector <double> stepX = CholeskyFactor.Solve(c_bar); Vector <double> stepS = A.TransposeThisAndMultiply(stepX) - rp; Vector <double> stepZ = -(rs + z.PointwiseMultiply(stepS)).PointwiseDivide(s); return(new Variables(stepX, stepZ, stepS)); }
private double ComputeMeritFunction(Residuals residuals, double residualsNorm) { return((residualsNorm + Math.Abs(residuals.DualityGap)) / this.dataInfinityNorm); }
private double ComputeMeritFunction(Residuals residuals, double residualsNorm) { return (residualsNorm + Math.Abs(residuals.DualityGap)) / this.dataInfinityNorm; }