Class QPSubproblem
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IntersectionResultboxIntersections(double[] z, double[] d, double[] lb, double[] ub) Find the intersection of a segment (or line) with the rectangular boxlb ≤ x ≤ ub, where the segment is parameterised asx(t) = z + t*d.static IntersectionResultboxIntersections(double[] zIn, double[] dIn, double[] lbIn, double[] ubIn, boolean entireLine) Find the intersection of a segment (or line) with the rectangular boxlb ≤ x ≤ ub, where the segment is parameterised asx(t) = z + t*d.static IntersectionResultboxSphereIntersections(double[] z, double[] d, double[] lb, double[] ub, double trustRadius) Convenience overload ofboxSphereIntersections(double[], double[], double[], double[], double, boolean)withentireLine = false.static IntersectionResultboxSphereIntersections(double[] z, double[] d, double[] lb, double[] ub, double trustRadius, boolean entireLine) Find the intersection of a segment (or line) with both a boxlb ≤ x ≤ uband a ball||x|| ≤ trustRadius.static IntersectionResult[]boxSphereIntersectionsWithExtraInfo(double[] z, double[] d, double[] lb, double[] ub, double trustRadius) Convenience overload ofboxSphereIntersectionsWithExtraInfo(double[], double[], double[], double[], double, boolean)withentireLine = false.static IntersectionResult[]boxSphereIntersectionsWithExtraInfo(double[] z, double[] d, double[] lb, double[] ub, double trustRadius, boolean entireLine) Find the intersection between segment (or line) and box/sphere constraints.static Matrix[]eqpKktFact(Matrix H, Matrix c, Matrix A, Matrix b) Solve the equality-constrained quadratic programstatic booleaninsideBoxBoundaries(double[] x, double[] lb, double[] ub) Check whetherlb ≤ x ≤ ubelementwise.static MatrixmodifiedDogleg(Matrix A, Object Y, Matrix b, double trustRadius, double[] lb, double[] ub) Approximately minimize1/2 ||A x + b||^2subject to||x|| < Deltaandlb ≤ x ≤ ubusing a modified dogleg approach.static CGInfoprojectedCG(LinearOperator H, Matrix c, Object Z, Object Y, Matrix b) Solve the equality-constrained quadratic programstatic CGInfoprojectedCG(LinearOperator H, Matrix c, Object Z, Object Y, Matrix b, double trustRadius, double[] lb, double[] ub, double tolerance) Solve EQP problem with projected CG method.static CGInfoprojectedCG(LinearOperator H, Matrix c, Object Z, Object Y, Matrix b, double trustRadius, double[] lb, double[] ub, double tolerance, long maxIterations, long maxInfeasibleIterations, boolean returnAll) Solve the equality-constrained quadratic programstatic double[]reinforceBoxBoundaries(double[] x, double[] lb, double[] ub) Return clipped value of x.static IntersectionResultsphereIntersections(double[] z, double[] d, double trustRadius) Find the intersection between segment (or line) and spherical constraints.static IntersectionResultsphereIntersections(double[] z, double[] d, double trustRadius, boolean entireLine) Find the intersection of a segment (or line) with the ball||x|| ≤ trustRadius, where the segment is parameterised asx(t) = z + t*d.
-
Constructor Details
-
QPSubproblem
public QPSubproblem()
-
-
Method Details
-
eqpKktFact
Solve the equality-constrained quadratic programminimize q(x) = 1/2 x^T G x + x^T c subject to A x = b
whereGis the symmetricn x nHessian,c, xare length-nvectors, andAis them x nJacobian of constraints (withm ≤ n).See Nocedal & Wright, Numerical Optimization, 2nd ed. (2006), chapter 16.1.
- Parameters:
H-n x nHessian matrix of the EQP problemc- length-ngradient of the quadratic objective functionA-m x nJacobian matrix of the equality constraintsb- length-mright-hand side of the constraint equation, sign-flipped- Returns:
- two-element array
[x, lambda]containing the solution and Lagrange multipliers
-
sphereIntersections
Find the intersection between segment (or line) and spherical constraints.Find the intersection between the segment (or line) defined by the parametric equation
x(t) = z + t*dand the ball||x|| <= trust_radius.- Parameters:
z- length-ninitial pointd- length-ndirectiontrustRadius- ball radius- Returns:
- the
t-interval over which the segment lies inside the ball, orintersect=falseif it never enters
-
sphereIntersections
public static IntersectionResult sphereIntersections(double[] z, double[] d, double trustRadius, boolean entireLine) Find the intersection of a segment (or line) with the ball||x|| ≤ trustRadius, where the segment is parameterised asx(t) = z + t*d.- Parameters:
z- length-ninitial pointd- length-ndirectiontrustRadius- ball radiusentireLine- iftrue, allowtto range over all ofR; iffalse, restrict0 ≤ t ≤ 1- Returns:
- the
t-interval over which the segment lies inside the ball, orintersect=falseif it never enters
-
boxIntersections
Find the intersection of a segment (or line) with the rectangular boxlb ≤ x ≤ ub, where the segment is parameterised asx(t) = z + t*d. Convenience overload that disables the "entire line" mode.- Parameters:
z- length-ninitial pointd- length-ndirectionlb- length-nlower bounds of the boxub- length-nupper bounds of the box- Returns:
(tA, tB, intersect)-- thet-interval over which the segment lies inside the box, orintersect=false.
-
boxIntersections
public static IntersectionResult boxIntersections(double[] zIn, double[] dIn, double[] lbIn, double[] ubIn, boolean entireLine) Find the intersection of a segment (or line) with the rectangular boxlb ≤ x ≤ ub, where the segment is parameterised asx(t) = z + t*d.- Parameters:
zIn- length-ninitial pointdIn- length-ndirectionlbIn- length-nlower bounds of the boxubIn- length-nupper bounds of the boxentireLine- iftrue, allowtto range over all ofR; iffalse, restrict0 ≤ t ≤ 1- Returns:
- the
t-interval over which the segment lies inside the box, orintersect=falseif it never enters
-
boxSphereIntersections
public static IntersectionResult boxSphereIntersections(double[] z, double[] d, double[] lb, double[] ub, double trustRadius) Convenience overload ofboxSphereIntersections(double[], double[], double[], double[], double, boolean)withentireLine = false.- Parameters:
z- initial pointd- directionlb- box lower boundsub- box upper boundstrustRadius- sphere radius- Returns:
- the intersection
t-interval
-
boxSphereIntersections
public static IntersectionResult boxSphereIntersections(double[] z, double[] d, double[] lb, double[] ub, double trustRadius, boolean entireLine) Find the intersection of a segment (or line) with both a boxlb ≤ x ≤ uband a ball||x|| ≤ trustRadius.- Parameters:
z- initial pointd- directionlb- box lower boundsub- box upper boundstrustRadius- sphere radiusentireLine- iftrue, allowtto range over all ofR; iffalse, restrict to the segment- Returns:
- the intersection
t-interval
-
boxSphereIntersectionsWithExtraInfo
public static IntersectionResult[] boxSphereIntersectionsWithExtraInfo(double[] z, double[] d, double[] lb, double[] ub, double trustRadius) Convenience overload ofboxSphereIntersectionsWithExtraInfo(double[], double[], double[], double[], double, boolean)withentireLine = false.- Parameters:
z- initial pointd- directionlb- box lower boundsub- box upper boundstrustRadius- sphere radius- Returns:
- three-element array
{boxSphere, sphere, box}ofIntersectionResult
-
boxSphereIntersectionsWithExtraInfo
public static IntersectionResult[] boxSphereIntersectionsWithExtraInfo(double[] z, double[] d, double[] lb, double[] ub, double trustRadius, boolean entireLine) Find the intersection between segment (or line) and box/sphere constraints.Find the intersection between the segment (or line) defined by the parametric equation
x(t) = z + t*d, the rectangular boxlb <= x <= uband the ball||x|| <= trust_radius.- Parameters:
z- [n] initial pointd- [n] directionlb- [n] lower bounds to each one of the components ofx, used to delimit the rectangular boxub- [n] upper bounds to each one of the components ofx, used to delimit the rectangular boxtrustRadius- ball radiusentireLine- Whentrue, the function returns the intersection between the linex(t) = z + t*d(tcan assume any value) and the constraints. Whenfalse, the function returns the intersection between the segmentx(t) = z + t*d,0 <= t <= 1and the constraints.- Returns:
- [3] The first element is the combined intersection result.
The second element is the intersection result from
sphereIntersections. The third element is the intersection result fromboxIntersections.
-
reinforceBoxBoundaries
public static double[] reinforceBoxBoundaries(double[] x, double[] lb, double[] ub) Return clipped value of x.- Parameters:
x- [n] position vector to force into boundslb- [n] lower boundsub- [n] upper bounds- Returns:
- coerced copy of
xsuch thatlb ≤ x ≤ ubfor all entries
-
insideBoxBoundaries
public static boolean insideBoxBoundaries(double[] x, double[] lb, double[] ub) Check whetherlb ≤ x ≤ ubelementwise.- Parameters:
x- length-nposition to testlb- length-nlower boundsub- length-nupper bounds- Returns:
trueiff every entry satisfieslb[i] ≤ x[i] ≤ ub[i]
-
modifiedDogleg
public static Matrix modifiedDogleg(Matrix A, Object Y, Matrix b, double trustRadius, double[] lb, double[] ub) Approximately minimize1/2 ||A x + b||^2subject to||x|| < Deltaandlb ≤ x ≤ ubusing a modified dogleg approach. Implementation based on Byrd-Hribar-Nocedal (1999), pp.885-886.- Parameters:
A-m x nmatrix in the minimization problem (m < nexpected)Y-MatrixorLinearOperatorthat applies the projectionQ = A^T (A A^T)^-^1; for any inputx,y = Q xis the minimum-norm solution ofA y = xb- length-mvector in the minimization problemtrustRadius- trust radiusDelta(sphere boundary)lb- length-nlower bounds;Double.NEGATIVE_INFINITYdisables the bound for that component. Algorithm assumeslb ≤ 0ub- length-nupper bounds;Double.POSITIVE_INFINITYdisables the bound for that component. Algorithm assumesub ≥ 0- Returns:
- length-
nsolution vector
-
projectedCG
Solve the equality-constrained quadratic programminimize 1/2 x^T H x + x^T c subject to A x + b = 0
with the projected conjugate-gradient method. Convenience overload with no trust-region or box constraints.- Parameters:
H- operator that computesH von a length-nvectorc- length-ngradient of the quadratic objectiveZ-MatrixorLinearOperatorthat projectsxinto the null space ofAY-MatrixorLinearOperatorthat, givenb, returns the minimum-norm solution ofA x + b = 0b- length-mright-hand side of the constraint equation- Returns:
- solution vector and additional CG info
-
projectedCG
public static CGInfo projectedCG(LinearOperator H, Matrix c, Object Z, Object Y, Matrix b, double trustRadius, double[] lb, double[] ub, double tolerance) Solve EQP problem with projected CG method.Solve equality-constrained quadratic programming problem
min 1/2 x^T H x + x^t csubject toA x + b = 0and, possibly, to trust region constraints||x|| < trust_radiusand box constraintslb <= x <= ub.Without spherical or box constraints and with enough iterations, the method returns the exact optimum. With those constraints active, the returned value is only an inexpensive approximation.
- Parameters:
H- operator that computesH von a length-nvectorc- length-ngradient of the quadratic objectiveZ-MatrixorLinearOperatorthat projectsxinto the null space ofAY-MatrixorLinearOperatorthat, givenb, returns the minimum-norm solution ofA x + b = 0b- length-mright-hand side of the constraint equationtrustRadius- trust-region radius;Double.POSITIVE_INFINITYdisables the trust-region constraintlb- length-nlower bounds;Double.NEGATIVE_INFINITYdisables the bound for that componentub- length-nupper bounds;Double.POSITIVE_INFINITYdisables the bound for that componenttolerance- termination tolerance for the projected residual- Returns:
- solution vector and additional CG info
-
projectedCG
public static CGInfo projectedCG(LinearOperator H, Matrix c, Object Z, Object Y, Matrix b, double trustRadius, double[] lb, double[] ub, double tolerance, long maxIterations, long maxInfeasibleIterations, boolean returnAll) Solve the equality-constrained quadratic programminimize 1/2 x^T H x + x^T c subject to A x + b = 0 and (optionally) ||x|| < trustRadius, lb ≤ x ≤ ub
with the projected conjugate-gradient method (Algorithm 6.2 of Gould-Hribar-Nocedal, 2001).Without spherical or box constraints and with enough iterations, the method returns the exact optimum. With those constraints active, the returned value is only an inexpensive approximation.
- Parameters:
H- operator that computesH vc- length-ngradient of the quadratic objectiveZ-MatrixorLinearOperatorprojecting into null(A)Y-MatrixorLinearOperatorfor the minimum-norm solution ofA x + b = 0b- length-mright-hand side of the constraint equationtrustRadius- trust-region radius;Double.POSITIVE_INFINITYdisables the trust-region constraintlb- length-nlower bounds (use-infto disable per dim)ub- length-nupper bounds (use+infto disable per dim)tolerance- termination tolerance for the projected residualmaxIterations- max CG iterations;-1for the defaultn - mmaxInfeasibleIterations- max iterations spent infeasible w.r.t. box constraints;-1for the defaultn - mreturnAll- iftrue, the result includes the iterate trajectory- Returns:
- solution vector and additional CG info
-