Class MeritFunctionL2
This class implements the penalty function used for the line search procedure in Sequential Quadratic Programming (SQP), as described by Klaus Schittkowski (1982).
The function, often denoted as \(\Phi(x, v, r)\), combines the objective function with equality and inequality constraints using an Augmented Lagrangian formulation. This approach ensures that the search direction \(d\) generated by the QP subproblem is a descent direction for the merit function, provided the penalty parameters \(r_j\) are sufficiently large.
* @see Schittkowski (1982): On the convergence of a sequential quadratic programming method-
Constructor Summary
ConstructorsConstructorDescriptionMeritFunctionL2(TwiceDifferentiableFunction objective, Constraint eqConstraint, Constraint iqConstraint, LinearInequalityConstraint bounds, RealVector x) Constructor for the Merit Function. -
Method Summary
Modifier and TypeMethodDescriptiongetR()Returns the penalty parameters vector.doublegetRmax()Returns the maximum allowed penalty value.gradX()Computes the gradient of the merit function with respect to x.gradY()Computes the gradient of the merit function with respect to the multipliers y.voidresetRj()Resets the penalty parameters vector \(r\) to its initial values.voidrUp()Increases the penalty parameters globally.voidupdate(RealVector newJ, RealMatrix newJE, RealMatrix newJI, RealVector newX, RealVector newY, RealVector newDx, RealVector newU) Updates internal states with the results from the QP subproblem.voidupdateRj(RealMatrix H, RealVector newY, RealVector newDx, RealVector newU, double sigmaValue, int iterations) Update the weight vector \(r_j\) (Penalty Parameters).doublevalue(double alpha) Evaluate merit function for a given step alpha.doublevalue0()Computes the merit function value at the current point (\(\alpha = 0\)).
-
Constructor Details
-
MeritFunctionL2
public MeritFunctionL2(TwiceDifferentiableFunction objective, Constraint eqConstraint, Constraint iqConstraint, LinearInequalityConstraint bounds, RealVector x) Constructor for the Merit Function.- Parameters:
objective- Objective function to minimizeeqConstraint- Equality constraintsiqConstraint- Inequality constraintsbounds- Linear box constraintsx- Initial starting point
-
-
Method Details
-
update
public void update(RealVector newJ, RealMatrix newJE, RealMatrix newJI, RealVector newX, RealVector newY, RealVector newDx, RealVector newU) Updates internal states with the results from the QP subproblem.This method must be called before performing a line search to ensure gradients and search directions are consistent with the current iterate.
- Parameters:
newJ- Gradient of objective at current xnewJE- Gradient of equality at current xnewJI- Gradient of inequality at current xnewX- Current iteratenewY- Lagrange multipliers from the previous iterationnewDx- Search direction solution from the QP subproblemnewU- Multipliers solution from the QP subproblem
-
value0
public double value0()Computes the merit function value at the current point (\(\alpha = 0\)). Internal helper for initialization and gradient consistency.- Returns:
- current penalty value
-
value
public double value(double alpha) Evaluate merit function for a given step alpha.Optimized version to minimize overhead while maintaining strict numerical consistency with the original backup summation order to prevent floating-point drift.
- Parameters:
alpha- line search step length- Returns:
- penalty value at x + alpha*dx
-
gradX
Computes the gradient of the merit function with respect to x.- Returns:
- \(\nabla_x \Phi(x, v, r)\)
-
gradY
Computes the gradient of the merit function with respect to the multipliers y.- Returns:
- \(\nabla_y \Phi(x, v, r)\)
-
updateRj
public void updateRj(RealMatrix H, RealVector newY, RealVector newDx, RealVector newU, double sigmaValue, int iterations) Update the weight vector \(r_j\) (Penalty Parameters).This is a critical step in Schittkowski's algorithm. The penalty parameters \(r_j\) are updated after solving the QP subproblem but before the line search. They are chosen such that the search direction \(dx\) is a descent direction for the merit function: \(\nabla \Phi(x, v, r)^T d_{QP} < 0\).
- Parameters:
H- Hessian Matrix (or its BFGS approximation)newY- last estimate of multipliersnewDx- primal direction solution from QPnewU- dual direction (multipliers) from QPsigmaValue- value of the additional slack variable in augmented QPiterations- current iteration count
-
resetRj
public void resetRj()Resets the penalty parameters vector \(r\) to its initial values. Useful when the optimizer performs a restart or recovery from a bad step. -
rUp
public void rUp()Increases the penalty parameters globally. Used in augmented QP mode when the standard descent conditions are not met. -
getR
Returns the penalty parameters vector.- Returns:
- vector r
-
getRmax
public double getRmax()Returns the maximum allowed penalty value.- Returns:
- rMax
-