modopt.merit_functions
Augmented Lagrangian merit function for pure inequality-constraints of the form c(x) >= 0. |
- class modopt.merit_functions.AugmentedLagrangianIneq(**kwargs)[source]
Augmented Lagrangian merit function for pure inequality-constraints of the form c(x) >= 0.
- Parameters
- fcallable
Objective function.
- ccallable
Constraint function representing the inequality constraints c(x) >= 0.
- gcallable
Objective gradient.
- jcallable
Constraint Jacobian.
- nxint
Number of optimization/design variables.
- ncint
Number of inequality constraints.
- Attributes
- rhonp.ndarray
Vector of penalty parameters corresponding to each inequality constraint.
- cachedict
Dictionary to store the latest function evaluations for ‘f’, ‘c’, ‘g’ and ‘j’. Keys are the function names ‘f’, ‘c’, ‘g’ and ‘j’, and values are tuples of the form (x, f(x)).
- eval_countdict
Dictionary to store the number of times each function has been evaluated. Keys are the function names ‘f’, ‘c’, ‘g’ and ‘j’, and values are the number of evaluations.
Methods
Clear the cache of function evaluations.
Compute the value of the augmented Lagrangian function at the point v.
Compute the gradient of the augmented Lagrangian function at the point v.
evaluate_function(x, lag_mult, s, f, c)Evaluate the augmented Lagrangian function at the point [x, lag_mult, s], given the objective function value f and constraint function values c at the point x.
evaluate_gradient(x, lag_mult, s, f, c, g, j)Evaluate the gradient of the augmented Lagrangian function at the point [x, lag_mult, s], given the objective function f, constraint function c, objective gradient g, and constraint Jacobian j at the point x.
set_rho(rho)Set the penalty parameters rho for the inequality constraints.
setup()Set up the merit function by initializing rho as a vector of zeros.
update_functions_in_cache(fnames, x)Update the function values in the cache for the specified functions in fnames with their values at the given point x.
- clear_cache()
Clear the cache of function evaluations.
- compute_function(v)[source]
Compute the value of the augmented Lagrangian function at the point v.
- Parameters
- vnp.ndarray
Point at which to evaluate the augmented Lagrangian function. The point v is a concatenation of the design variables x, Lagrange multipliers lag_mult and slack variables slacks. The point v has the form [x, lag_mult, slacks].
- Returns
- float
Value of the augmented Lagrangian function at the point v.
- compute_gradient(v)[source]
Compute the gradient of the augmented Lagrangian function at the point v.
- Parameters
- vnp.ndarray
Point at which to evaluate the gradient of the augmented Lagrangian function. The point v is a concatenation of the design variables x, Lagrange multipliers lag_mult and slack variables slacks. The point v has the form [x, lag_mult, slacks].
- Returns
- np.ndarray
Gradient of the augmented Lagrangian function at the point v.
- evaluate_function(x, lag_mult, s, f, c)[source]
Evaluate the augmented Lagrangian function at the point [x, lag_mult, s], given the objective function value f and constraint function values c at the point x.
- Parameters
- xnp.ndarray
Design variables.
- lag_multnp.ndarray
Lagrange multipliers.
- snp.ndarray
Slack variables.
- ffloat
Objective function value at the point x.
- cnp.ndarray
Constraint function values at the point x.
- Returns
- float
Value of the augmented Lagrangian function at the point x.
- evaluate_gradient(x, lag_mult, s, f, c, g, j)[source]
Evaluate the gradient of the augmented Lagrangian function at the point [x, lag_mult, s], given the objective function f, constraint function c, objective gradient g, and constraint Jacobian j at the point x.
- Parameters
- xnp.ndarray
Design variables.
- lag_multnp.ndarray
Lagrange multipliers.
- snp.ndarray
Slack variables.
- ffloat
Objective function value at the point x.
- cnp.ndarray
Constraint function values at the point x.
- gnp.ndarray
Objective gradient at the point x.
- jnp.ndarray
Constraint Jacobian at the point x.
- Returns
- np.ndarray
Gradient of the augmented Lagrangian function at the point x.
- set_rho(rho)[source]
Set the penalty parameters rho for the inequality constraints.
- Parameters
- rhonp.ndarray
Penalty parameter vector for the inequality constraints. Must be a 1D numpy array of length nc.
- update_functions_in_cache(fnames, x)
Update the function values in the cache for the specified functions in fnames with their values at the given point x. If the cache contains no values for a function in fnames or the cached values correspond to a point other than x, the function is evaluated at x and the cache is updated accordingly.
- Parameters
- fnamesstr or list of str
Function names whose values need to be updated in the cache. fnames must be one or a subset of [‘f’, ‘g’, ‘c’, ‘j’].
- xnp.ndarray
Point at which to update the functions in fnames.