MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::MMA Class Reference

MMA (Method of Moving Asymptotes) solves a nonlinear optimization problem involving an objective function, inequality constraints, and variable bounds. More...

#include <mma.hpp>

Collaboration diagram for mfem::MMA:
[legend]

Public Member Functions

 MMA (int nVar, int nCon, real_t *xval, int iterationNumber=0)
 Serial constructor.
 
 MMA (const int nVar, int nCon, Vector &xval, int iterationNumber=0)
 Serial constructor.
 
 MMA (MPI_Comm comm_, int nVar, int nCon, real_t *xval, int iterationNumber=0)
 Parallel constructor.
 
 MMA (MPI_Comm comm_, const int nVar, const int nCon, const Vector &xval, int iterationNumber=0)
 Parallel constructor.
 
 ~MMA ()
 Destructor.
 
void Update (const Vector &dfdx, const Vector &gx, const Vector &dgdx, const Vector &xmin, const Vector &xmax, Vector &xval)
 Update the optimization parameters for a constrained nonlinear program.
 
void Update (const Vector &dfdx, const Vector &xmin, const Vector &xmax, Vector &xval)
 Update the optimization parameters for an unconstrained nonlinear program.
 
void SetIteration (int iterationNumber)
 Change the iteration number.
 
int GetIteration () const
 Return the current iteration number.
 
void SetPrintLevel (int print_lvl)
 change the print level
 

Protected Attributes

::std::unique_ptr< real_t[]> a
 
::std::unique_ptr< real_t[]> b
 
::std::unique_ptr< real_t[]> c
 
::std::unique_ptr< real_t[]> d
 
real_t a0
 
real_t machineEpsilon
 
real_t epsimin
 
real_t z
 
real_t zet
 
int nCon
 
int nVar
 
int iter = 0
 
int print_level = 1
 
::std::unique_ptr< real_t[]> low
 
::std::unique_ptr< real_t[]> upp
 
::std::unique_ptr< real_t[]> x
 
::std::unique_ptr< real_t[]> y
 
::std::unique_ptr< real_t[]> xsi
 
::std::unique_ptr< real_t[]> eta
 
::std::unique_ptr< real_t[]> lam
 
::std::unique_ptr< real_t[]> mu
 
::std::unique_ptr< real_t[]> s
 

Friends

class MMASubSvanberg
 

Detailed Description

MMA (Method of Moving Asymptotes) solves a nonlinear optimization problem involving an objective function, inequality constraints, and variable bounds.

This class finds \({\bf x} \in R^n\) that solves the following nonlinear program:

\[ \begin{array}{ll} \min_{{\bf x} \in R^n} & F({\bf x})\\ \textrm{subject to} & C({\bf x})_i \leq 0,\quad \textrm{for all}\quad i = 1,\ldots m\\ & {\bf x}_{\textrm{lo}} \leq {\bf x} \leq {\bf x}_{\textrm{hi}}. \end{array} \]

Here \(F : R^n \to R\) is the objective function, and \(C : R^n \to R^m\) is a set of \(m\) inequality constraints. The variable bounds are sometimes called box constraints. By convention, the routine seeks \({\bf x}\) that minimizes the objective function, \(F\). Maximization problems should be reformulated as a minimization of \(-F\).

The objective functions are replaced by convex functions chosen based on gradient information, and solved using a dual method. The unique optimal solution of this subproblem is returned as the next iteration point. Optimality is determined by the KKT conditions.

The "Update" function in MMA advances the optimization and must be called in every optimization iteration. Current and previous iteration points construct the "moving asymptotes". The design variables, objective function, constraints are passed to an approximating subproblem. The design variables are updated and returned. Its implementation closely follows the original formulation of 'Svanberg, K. (2007). MMA and GCMMA-two methods for nonlinear optimization. vol, 1, 1-15.'

When used in parallel, all Vectors are assumed to be true dof vectors, and the operators are expected to be defined for tdof vectors.

Definition at line 69 of file mma.hpp.

Constructor & Destructor Documentation

◆ MMA() [1/4]

mfem::MMA::MMA ( int nVar,
int nCon,
real_t * xval,
int iterationNumber = 0 )

Serial constructor.

Serial MMA.

Parameters
nVartotal number of design parameters
nConnumber of inequality constraints (i.e., \(C\))
xvalinitial values for design parameters (a pointer to nVar doubles). Caller retains ownership of this pointer/data.
iterationNumberthe starting iteration number

Definition at line 975 of file mma.cpp.

◆ MMA() [2/4]

mfem::MMA::MMA ( const int nVar,
int nCon,
Vector & xval,
int iterationNumber = 0 )

Serial constructor.

Parameters
nVartotal number of design parameters
nConnumber of inequality constraints (i.e., \(C\))
xvalinitial values for design parameters (size should be nVar). Caller retains ownership of this Vector.
iterationNumberthe starting iteration number

Definition at line 991 of file mma.cpp.

◆ MMA() [3/4]

mfem::MMA::MMA ( MPI_Comm comm_,
int nVar,
int nCon,
real_t * xval,
int iterationNumber = 0 )

Parallel constructor.

Parameters
comm_the MPI communicator participating in the NLP solve
nVarnumber of design parameters on this MPI rank
nContotal number of inequality constraints (i.e., \(C\)). Every MPI rank provides the same value here.
xvalinitial values for design parameters on this MPI rank (a pointer to nVar doubles). Caller retains ownership of this pointer/data.
iterationNumberthe starting iteration number. All MPI ranks should pass in the same value here.

Each MPI rank has a subset of the total design variable vector, and calls for that MPI rank always address its subset of the design variable vector and gradients with respect to its subset of the design variable vector.

If you wanted to determine the global number of design variables, it would be determined as follows:

int globalDesignVars;
MPI_Allreduce(&nVar, &globalDesignVars, 1, MPI_INT, MPI_SUM, comm_);
int nVar
Definition mma.hpp:237

Definition at line 996 of file mma.cpp.

◆ MMA() [4/4]

mfem::MMA::MMA ( MPI_Comm comm_,
const int nVar,
const int nCon,
const Vector & xval,
int iterationNumber = 0 )

Parallel constructor.

Parameters
comm_the MPI communicator participating in the NLP solve
nVarnumber of design parameters on this MPI rank
nContotal number of inequality constraints (i.e., \(C\)). Every MPI rank provides the same value here.
xvalinitial values for design parameters (size should be nVar). Caller retains ownership of this Vector.
iterationNumberthe starting iteration number. All MPI ranks should pass in the same value here.

Each MPI rank has a subset of the total design variable vector, and calls for that MPI rank always address its subset of the design variable vector and gradients with respect to its subset of the design variable vector.

If you wanted to determine the global number of design variables, it would be determined as follows:

int globalDesignVars;
MPI_Allreduce(&nVar, &globalDesignVars, 1, MPI_INT, MPI_SUM, comm_);

Definition at line 1022 of file mma.cpp.

◆ ~MMA()

mfem::MMA::~MMA ( )

Destructor.

Definition at line 1028 of file mma.cpp.

Member Function Documentation

◆ GetIteration()

int mfem::MMA::GetIteration ( ) const
inline

Return the current iteration number.

Definition at line 224 of file mma.hpp.

◆ SetIteration()

void mfem::MMA::SetIteration ( int iterationNumber)
inline

Change the iteration number.

Parameters
iterationNumberthe new iteration number

Definition at line 221 of file mma.hpp.

◆ SetPrintLevel()

void mfem::MMA::SetPrintLevel ( int print_lvl)
inline

change the print level

Parameters
print_lvlthe new print level

Definition at line 230 of file mma.hpp.

◆ Update() [1/2]

void mfem::MMA::Update ( const Vector & dfdx,
const Vector & gx,
const Vector & dgdx,
const Vector & xmin,
const Vector & xmax,
Vector & xval )

Update the optimization parameters for a constrained nonlinear program.

Parameters
dfdxvector of size nVar holding the gradients of the objective function with respect to the design variables, \(\frac{\partial F}{\partial {\bf x}_i}\) for each variable on this rank.
gxvector of size nCon holding the values of the inequality constraints. Every MPI rank should pass in the same values here.
dgdxvector of size \(\textrm{nCon}\cdot\textrm{nVar}\) holding the gradients of the constraints in row-major order. For example, {dg0dx0, dg0dx1, ...,} {dg1dx0, dg1dx1, ..., }, ...
xminvector of size nVar holding the lower bounds on the design values. xmin and xmax are the box constraints.
xmaxvector of size nVar holding the upper bounds on the design values. xmin and xmax are the box constraints.
xvalvector of size nVar. On entry, this holds the value of the design variables where the objective, constraints, and their gradients were evaluated. On exit, this holds the result of the MMA iteration, the next design variable value to use.

The caller retains ownership of all Vectors passed into this method.

Definition at line 1072 of file mma.cpp.

◆ Update() [2/2]

void mfem::MMA::Update ( const Vector & dfdx,
const Vector & xmin,
const Vector & xmax,
Vector & xval )

Update the optimization parameters for an unconstrained nonlinear program.

Parameters
dfdxvector of size nVar holding the gradients of the objective function with respect to the design variables, \(\frac{\partial F}{\partial {\bf x}_i}\) for each variable on this rank.
xminvector of size nVar holding the lower bounds on the design values. xmin and xmax are the box constraints.
xmaxvector of size nVar holding the upper bounds on the design values. xmin and xmax are the box constraints.
xvalvector of size nVar. On entry, this holds the value of the design variables where the objective, constraints, and their gradients were evaluated. On exit, this holds the result of the MMA iteration, the next design variable value to use.

The caller retains ownership of all Vectors passed into this method. This should be used when the number of inequality constraints is zero.

Definition at line 1083 of file mma.cpp.

Friends And Related Symbol Documentation

◆ MMASubSvanberg

friend class MMASubSvanberg
friend

Definition at line 312 of file mma.hpp.

Member Data Documentation

◆ a

::std::unique_ptr<real_t[]> mfem::MMA::a
protected

Definition at line 234 of file mma.hpp.

◆ a0

real_t mfem::MMA::a0
protected

Definition at line 235 of file mma.hpp.

◆ b

::std::unique_ptr<real_t[]> mfem::MMA::b
protected

Definition at line 234 of file mma.hpp.

◆ c

::std::unique_ptr<real_t[]> mfem::MMA::c
protected

Definition at line 234 of file mma.hpp.

◆ d

::std::unique_ptr<real_t[]> mfem::MMA::d
protected

Definition at line 234 of file mma.hpp.

◆ epsimin

real_t mfem::MMA::epsimin
protected

Definition at line 235 of file mma.hpp.

◆ eta

::std::unique_ptr<real_t[]> mfem::MMA::eta
protected

Definition at line 247 of file mma.hpp.

◆ iter

int mfem::MMA::iter = 0
protected

Definition at line 240 of file mma.hpp.

◆ lam

::std::unique_ptr<real_t[]> mfem::MMA::lam
protected

Definition at line 247 of file mma.hpp.

◆ low

::std::unique_ptr<real_t[]> mfem::MMA::low
protected

Definition at line 246 of file mma.hpp.

◆ machineEpsilon

real_t mfem::MMA::machineEpsilon
protected

Definition at line 235 of file mma.hpp.

◆ mu

::std::unique_ptr<real_t[]> mfem::MMA::mu
protected

Definition at line 247 of file mma.hpp.

◆ nCon

int mfem::MMA::nCon
protected

Definition at line 237 of file mma.hpp.

◆ nVar

int mfem::MMA::nVar
protected

Definition at line 237 of file mma.hpp.

◆ print_level

int mfem::MMA::print_level = 1
protected

Definition at line 243 of file mma.hpp.

◆ s

::std::unique_ptr<real_t[]> mfem::MMA::s
protected

Definition at line 247 of file mma.hpp.

◆ upp

::std::unique_ptr<real_t[]> mfem::MMA::upp
protected

Definition at line 246 of file mma.hpp.

◆ x

::std::unique_ptr<real_t[]> mfem::MMA::x
protected

Definition at line 247 of file mma.hpp.

◆ xsi

::std::unique_ptr<real_t[]> mfem::MMA::xsi
protected

Definition at line 247 of file mma.hpp.

◆ y

::std::unique_ptr<real_t[]> mfem::MMA::y
protected

Definition at line 247 of file mma.hpp.

◆ z

real_t mfem::MMA::z
protected

Definition at line 236 of file mma.hpp.

◆ zet

real_t mfem::MMA::zet
protected

Definition at line 236 of file mma.hpp.


The documentation for this class was generated from the following files: