slsqp_jax.merit

Han–Powell L1 merit function, penalty-parameter update, and the backtracking line search.

slsqp_jax.merit

L1 Merit Function and Line Search for SLSQP.

This module implements the Han-Powell L1-exact penalty merit function and backtracking line search used to globalize the SLSQP algorithm.

The merit function is:

φ(x; ρ) = f(x) + ρ * (‖c_eq(x)‖_1 + ‖max(0, -c_ineq(x))‖_1)

where ρ is the penalty parameter, chosen large enough to ensure descent.

class slsqp_jax.merit.LineSearchResult[source]

Bases: NamedTuple

Result from the line search.

Attributes:

alpha: The step size found. f_val: Function value at new point. eq_val: Equality constraint values at new point. ineq_val: Inequality constraint values at new point. success: Whether the line search succeeded. n_evals: Number of function evaluations.

alpha: Float[Array, '']

Alias for field number 0

f_val: Float[Array, '']

Alias for field number 1

eq_val: Float[Array, 'm_eq']

Alias for field number 2

ineq_val: Float[Array, 'm_ineq']

Alias for field number 3

success: Bool[Array, '']

Alias for field number 4

n_evals: Int[Array, '']

Alias for field number 5

slsqp_jax.merit.compute_merit(f_val, eq_val, ineq_val, penalty)[source]

Compute the L1-exact penalty merit function value.

Return type:

Float[Array, '']

Parameters:
  • f_val (Float[Array, ''])

  • eq_val (Float[Array, 'm_eq'])

  • ineq_val (Float[Array, 'm_ineq'])

  • penalty (Float[Array, ''])

The merit function is:

φ(x; ρ) = f(x) + ρ * (‖c_eq(x)‖_1 + ‖max(0, -c_ineq(x))‖_1)

Args:

f_val: Objective function value f(x). eq_val: Equality constraint values c_eq(x). ineq_val: Inequality constraint values c_ineq(x). penalty: Penalty parameter ρ.

Returns:

Merit function value φ(x; ρ).

slsqp_jax.merit.update_penalty_parameter(current_penalty, multipliers_eq, multipliers_ineq, margin=1.1)[source]

Update the penalty parameter based on Lagrange multipliers.

The penalty should be larger than the maximum absolute multiplier to ensure the merit function provides a descent direction.

ρ >= max(abs(λ_i), abs(μ_j)) + margin

Return type:

Float[Array, '']

Parameters:
  • current_penalty (Float[Array, ''])

  • multipliers_eq (Float[Array, 'm_eq'])

  • multipliers_ineq (Float[Array, 'm_ineq'])

  • margin (float)

Args:

current_penalty: Current penalty parameter. multipliers_eq: Lagrange multipliers for equality constraints. multipliers_ineq: Lagrange multipliers for inequality constraints. margin: Safety margin factor (default 1.1).

Returns:

Updated penalty parameter.

Perform backtracking line search with the L1 merit function.

Return type:

LineSearchResult

Parameters:
  • fn (Callable)

  • eq_constraint_fn (Callable | None)

  • ineq_constraint_fn (Callable | None)

  • x (Float[Array, 'n'])

  • direction (Float[Array, 'n'])

  • args (Any)

  • f_val (Float[Array, ''])

  • eq_val (Float[Array, 'm_eq'])

  • ineq_val (Float[Array, 'm_ineq'])

  • penalty (Float[Array, ''])

  • grad (Float[Array, 'n'])

  • c1 (float)

  • rho (float)

  • max_iter (int)

  • alpha_init (float)

  • bounds (Float[Array, 'n 2'] | None)

  • lower_bound_mask (tuple[bool, ...] | None)

  • upper_bound_mask (tuple[bool, ...] | None)

  • eq_jac (Float[Array, 'm_eq n'] | None)

  • ineq_jac (Float[Array, 'm_ineq_general n'] | None)

Finds α such that the Armijo condition is satisfied:

φ(x + α*d; ρ) ≤ φ(x; ρ) + c1 * α * φ’(x; d, ρ)

where φ is the L1 merit function and φ’ is the proper directional derivative including constraint Jacobian terms:

φ’(x; d, ρ) = ∇f·d + ρ Σ sign(c_eq_i)(J_eq d)_i
  • ρ Σ_{j: c_ineq_j<0} (J_ineq d)_j

When constraint Jacobians are not provided, falls back to the simpler ∇f·d approximation.

Args:

fn: Objective function fn(x, args) -> (f_val, aux). eq_constraint_fn: Equality constraint function or None. ineq_constraint_fn: Inequality constraint function or None. x: Current point. direction: Search direction. args: Arguments to pass to functions. f_val: Current objective value. eq_val: Current equality constraint values. ineq_val: Current inequality constraint values (including bounds). penalty: Penalty parameter. grad: Gradient of objective at x. c1: Armijo condition parameter (default 1e-4). rho: Step reduction factor (default 0.5). max_iter: Maximum number of iterations. alpha_init: Initial step size (default 1.0). bounds: Optional box constraints, shape (n, 2) with [lower, upper] per variable. lower_bound_mask: Tuple of bools indicating which lower bounds are finite. upper_bound_mask: Tuple of bools indicating which upper bounds are finite. eq_jac: Equality constraint Jacobian at x (m_eq, n), or None. ineq_jac: General inequality constraint Jacobian at x

(m_ineq_general, n), or None. Does NOT include bound constraint rows.

Returns:

LineSearchResult with the found step size and function values.