pymoto.MMA

class pymoto.MMA(variables, responses, function, slice_network=False, move=0.1, xmin=0.0, xmax=1.0, verbosity=2, mmaversion='MMA2007', **kwargs)

Class for the Method of Moving Asymptotes (MMA) optimization algorithm

References

  • Svanberg, K. (1987). The Method of Moving Asymptotes. IJNME, 24(2), 359–373. https://doi.org/10.1002/nme.1620240207

  • Svanberg, K. (2007). MMA and GCMMA – two methods for nonlinear optimization. Kth, 1, 1–15.

__init__(variables, responses, function, slice_network=False, move=0.1, xmin=0.0, xmax=1.0, verbosity=2, mmaversion='MMA2007', **kwargs)
Parameters:
  • variables – One or more variable Signals defining the design variables

  • responses – One or more response Signals, where the first is to be minimized and the others are constraints in negative null form.

  • function – The Network defining the optimization problem

Keyword Arguments:
  • slice_network – If True, only the modules connecting variable and response signals are evaluated

  • move – Move limit on relative variable change per iteration (can be passed as scalar: same value for all variables, vector: each variable has a unique value, list of scalars/vectors: for each variable signal)

  • xmin – Minimum design variable (can be passed as scalar: same value for all variables, vector: each variable has a unique value, list of scalars/vectors: for each variable signal)

  • xmax – Maximum design variable (can be passed as scalar: same value for all variables, vector: each variable has a unique value, list of scalars/vectors: for each variable signal)

  • verbosity – Level of information to print 0 - No prints 1 - Only convergence message 2 - Convergence and iteration info (default) 3 - Additional info on variables and GCMMA inner iteration info (when applicable) 4 - Additional info on sensitivity information

  • mmaversion – Which MMA algorithm to use “MMA1987” - Original version of MMA “MMA2007” - Improved version of MMA “GCMMA” - Globally-convergent version of MMA

  • **kwargs – Additional MMA options (see code for details)

Methods

__init__(variables, responses, function[, ...])

calculate_dg()

Calculate Jacobian dg/dx

calculate_g()

Calculate function response g(x)

mmasub(xval, g, dg[, rho])

optimize([maxiter, tolx, tolf, evaluate_last])

Perform a gradient-based optimization

print_iteration_info(g[, ...])

Print iteration information

print_variable_info([dg])

Print information on variables (and sensitivities)

step(x, g, dg)

Performs a single optimization step

subsolv(epsimin, low, upp, alfa, beta, P, Q, ...)

This function solves the MMA subproblem

Attributes

x

Set current design variable vector

step(x: ndarray = None, g: ndarray = None, dg: ndarray = None) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>, <class 'numpy.ndarray'>)

Performs a single optimization step

Parameters:
  • x (np.ndarray, optional) – The design vector to evaluate. When not provided, use information set in state

  • g (np.ndarray, optional) – The function values to use. When not provided, will be calculated on demand

  • dg (np.ndarray, optional) – The sensitivity values to use. When not provided, will be calculated on demand

Returns:

New design vector g: (Evaluated) response values dg: (Evaluated) design sensitivities

Return type:

xnew

mmasub(xval, g, dg, rho=1e-05)
calculate_dg()

Calculate Jacobian dg/dx

calculate_g()

Calculate function response g(x)

optimize(maxiter: int = 100, tolx: float = 0.0001, tolf: float = 0.0001, evaluate_last: bool = False)

Perform a gradient-based optimization

Parameters:
  • maxiter (int, optional) – Maximum number of iteration. Defaults to 100.

  • tolx (float, optional) – Stopping criterium for relative design change. Defaults to 1e-4.

  • tolf (float, optional) – Stopping criterium for relative objective change. Defaults to 1e-4.

print_iteration_info(g: ndarray, report_feasibility: bool = False, xold: ndarray = None, xnew: ndarray = None)

Print iteration information

Parameters:
  • g (np.ndarray) – Response values

  • report_feasibility (bool, optional) – Print # violated constraints and worst value. Defaults to False.

  • xold (np.ndarray, optional) – If provided, shows information on design change. Defaults to None.

  • xnew (np.ndarray, optional) – If provided, shows information on design change. Defaults to None.

print_variable_info(dg: ndarray = None)

Print information on variables (and sensitivities)

Parameters:

dg (np.ndarray, optional) – If provided, information on sensitivities will also be printed. Defaults to None.

static subsolv(epsimin, low, upp, alfa, beta, P, Q, a0, a, b, c, d, x0=None)

This function solves the MMA subproblem

minimize f_0(vec{x}) + a_0*z + sum_i^m[ c_i*y_i + 1/2*d_i*y_i^2 ], subject to f_i(vec{x}) - a_i*z - y_i <= b_i, for i = 1, …, m

alfa_j <= x_j <= beta_j, for j = 1, …, n y_i >= 0, for i = 1, …, m z >= 0.

where:

MMA approximation: \(f_i(\vec{x}) = \sum_j\left( p_{ij}/(upp_j-x_j) + q_{ij}/(x_j-low_j) \right)\) m: The number of general constraints n: The number of variables in \(\vec{x}\)

Parameters:
  • epsimin – Solution tolerance on maximum residual

  • low – Column vector with the lower asymptotes

  • upp – Column vector with the upper asymptotes

  • alfa – Vector with the lower bounds for the variables \(\vec{x}\)

  • beta – Vector with the upper bounds for the variables \(\vec{x}\)

  • P – Upper asymptotic amplitudes

  • Q – Lower asymptotic amplitudes

  • a0 – The constants \(a_0\) in the term \(a_0\cdot z\)

  • a – Vector with the constants \(a_i\) in the terms \(a_i \cdot z\)

  • c – Vector with the constants \(c_i\) in the terms \(c_i \cdot y_i\)

  • d – Vector with the constants \(d_i\) in the terms \(0.5 \cdot d_i \cdot y_i^2\)

  • x0 (optional) – Initial guess, in case not given \(x_0 = (\alpha + \beta)/2\) is used

Returns:

Vector with the optimal values of the variables \(\vec{x}\) in the current MMA subproblem y: Vector with the optimal values of the variables \(y_i\) in the current MMA subproblem z: Scalar with the optimal value of the variable \(z\) in the current MMA subproblem lam: Lagrange multipliers for the \(m\) general MMA constraints xsi: Lagrange multipliers for the :math:’n’ constraints \(alfa_j - x_j <= 0\) eta: Lagrange multipliers for the :math:’n’ constraints \(x_j - beta_j <= 0\) mu: Lagrange multipliers for the \(m\) constraints \(-y_i <= 0\) zet: Lagrange multiplier for the single constraint \(-z <= 0\) s: Slack variables for the m general MMA constraints

Return type:

x

property x

Set current design variable vector