Skip to main content

penalty_objective

Function penalty_objective 

Source
pub fn penalty_objective(
    f_val: f64,
    constraint_violations: &[f64],
    penalty: f64,
) -> f64
Expand description

Penalty method for constrained optimization.

Given an objective function value f_val and an array of constraint violation values constraint_violations (where positive values indicate violation), returns the penalized objective:

f_val + penalty * sum(max(0, g_i)^2)

Uses Kahan summation for the penalty term accumulation.