MAiNGO
maingo::ubp::UbpNLopt Class Reference

Wrapper for handling the upper bounding problems by interfacing NLopt. More...

#include <ubpNLopt.h>

Inheritance diagram for maingo::ubp::UbpNLopt:
maingo::ubp::UpperBoundingSolver

Public Member Functions

 UbpNLopt (mc::FFGraph &DAG, const std::vector< mc::FFVar > &DAGvars, const std::vector< mc::FFVar > &DAGfunctions, const std::vector< babBase::OptimizationVariable > &variables, const unsigned nineqIn, const unsigned neqIn, const unsigned nineqSquashIn, Settings *settingsIn, Logger *loggerIn, std::vector< Constraint > *constraintPropertiesIn, UBS_USE useIn)
 Constructor, stores information on the problem and initializes the local-subsolvers used. More...
 
- Public Member Functions inherited from maingo::ubp::UpperBoundingSolver
 UpperBoundingSolver (mc::FFGraph &DAG, const std::vector< mc::FFVar > &DAGvars, const std::vector< mc::FFVar > &DAGfunctions, const std::vector< babBase::OptimizationVariable > &variables, const unsigned nineqIn, const unsigned neqIn, const unsigned nineqSquashIn, Settings *settingsIn, Logger *loggerIn, std::vector< Constraint > *constraintPropertiesIn, UBS_USE useIn)
 Constructor, stores information on the problem and constructs an own copy of the directed acyclic graph. More...
 
virtual ~UpperBoundingSolver ()
 Virtual destructor, only needed to make sure the correct destructor of the derived classes is called. More...
 
virtual SUBSOLVER_RETCODE solve (babBase::BabNode const &currentNode, double &objectiveValue, std::vector< double > &solutionPoint)
 Function called by B&B solver for solving the upper bounding problem on the current node. This calls the internal (protected) function solve_nlp that needs to be re-implemented by the derived classes. More...
 
SUBSOLVER_RETCODE multistart (babBase::BabNode const &currentNode, double &objectiveValue, std::vector< double > &solutionPoint, std::vector< SUBSOLVER_RETCODE > &feasible, std::vector< double > &optimalObjectives, bool &initialPointFeasible)
 Multistart heuristic for automatically solving the UBP from multiple starting points. More...
 
SUBSOLVER_RETCODE check_feasibility (const std::vector< double > &currentPoint, double &objectiveValue) const
 Function for checking feasibility of a point. More...
 

Private Member Functions

virtual SUBSOLVER_RETCODE _solve_nlp (const std::vector< double > &lowerVarBounds, const std::vector< double > &upperVarBounds, double &objectiveValue, std::vector< double > &solutionPoint)
 Function for actually solving the NLP sub-problem. More...
 
 UbpNLopt (const UbpNLopt &)
 
UbpNLoptoperator= (const UbpNLopt &)
 

Static Private Member Functions

Functions provided to the NLopt interface
static double _NLopt_get_objective (const std::vector< double > &x, std::vector< double > &grad, void *f_data)
 Function returning the objective value to the NLopt interface. More...
 
static void _NLopt_get_ineq (unsigned m, double *result, unsigned n, const double *x, double *grad, void *f_data)
 Function providing gradient and value information on inequalities to the NLopt interface. More...
 
static void _NLopt_get_eq (unsigned m, double *result, unsigned n, const double *x, double *grad, void *f_data)
 Function providing gradient and value information on equalities to the NLopt interface. More...
 

Private Attributes

NLopt solver objects (_subopt is required for Augmented Lagrangian methods, see NLopt website)
nlopt::opt _NLopt
 
nlopt::opt _NLoptSubopt
 

Additional Inherited Members

- Public Types inherited from maingo::ubp::UpperBoundingSolver
enum  UBS_USE { USE_PRE = 0, USE_BAB }
 Enum for communicating what the intended purpose of the solver is. This determines which settings are used. More...
 
- Protected Member Functions inherited from maingo::ubp::UpperBoundingSolver
void _determine_structure ()
 Function for determining the number of variables participating in each function and the type of a function (linear, bilinear, quadratic, non-linear) More...
 
void _determine_sparsity_jacobian ()
 Function for setting the information about the sparsity structure in the Jacobian. More...
 
void _determine_sparsity_hessian ()
 Function for determining the non-zero entries in the Hessian of the Lagrangian function. More...
 
std::vector< double > _generate_multistart_point (bool &usedCenter, const std::vector< double > &lowerVarBounds, const std::vector< double > &upperVarBounds)
 Function for generating a point used in multistart. More...
 
SUBSOLVER_RETCODE _check_ineq (const std::vector< double > &modelOutput) const
 Function checking if inequality constraints are fulfilled. More...
 
SUBSOLVER_RETCODE _check_ineq_squash (const std::vector< double > &modelOutput) const
 Function checking if squash inequality constraints are fulfilled (no tolerance allowed) More...
 
SUBSOLVER_RETCODE _check_eq (const std::vector< double > &modelOutput) const
 Function checking if equality constraints are fulfilled. More...
 
SUBSOLVER_RETCODE _check_bounds (const std::vector< double > &currentPoint) const
 Function checking if bounds are fulfilled. More...
 
SUBSOLVER_RETCODE _check_integrality (const std::vector< double > &currentPoint) const
 Function checking if discrete variables are indeed discrete. More...
 
- Protected Attributes inherited from maingo::ubp::UpperBoundingSolver
Settings_maingoSettings
 
Logger_logger
 
std::shared_ptr< DagObj_DAGobj
 
UBS_USE _intendedUse
 
std::vector< Constraint > * _constraintProperties
 
unsigned _nvar
 
unsigned _nineq
 
unsigned _nineqSquash
 
unsigned _neq
 
std::vector< babBase::OptimizationVariable_originalVariables
 
std::vector< double > _originalUpperBounds
 
std::vector< double > _originalLowerBounds
 
UbpStructure _structure
 

Detailed Description

Wrapper for handling the upper bounding problems by interfacing NLopt.

This class constructs and solves upper bounding problems using different solvers from the NLopt toolbox (http://ab-initio.mit.edu/wiki/index.php/NLopt). It thus evaluates the Model equations using either regular floating point arithmetics or FADBAD++ to obtain function values and gradients, and solves the resulting NLPs. The solution point obtained is checked for feasibility within the given tolerances.

Constructor & Destructor Documentation

◆ UbpNLopt() [1/2]

UbpNLopt::UbpNLopt ( mc::FFGraph &  DAG,
const std::vector< mc::FFVar > &  DAGvars,
const std::vector< mc::FFVar > &  DAGfunctions,
const std::vector< babBase::OptimizationVariable > &  variables,
const unsigned  nineqIn,
const unsigned  neqIn,
const unsigned  nineqSquashIn,
Settings settingsIn,
Logger loggerIn,
std::vector< Constraint > *  constraintPropertiesIn,
UBS_USE  useIn 
)

Constructor, stores information on the problem and initializes the local-subsolvers used.

Parameters
[in]DAGis the directed acyclic graph constructed in MAiNGO.cpp needed to construct an own DAG for the lower bounding solver
[in]DAGvarsare the variables corresponding to the DAG
[in]DAGfunctionsare the functions corresponding to the DAG
[in]variablesis a vector containing the initial optimization variables defined in problem.h
[in]nineqInis the number of inequality constraints
[in]neqInis the number of equality constraints
[in]nineqSquashInis the number of squash inequality constraints which are to be used only if the squash node has been used
[in]settingsInis a pointer to the MAiNGO settings
[in]loggerInis a pointer to the MAiNGO logger object
[in]constraintPropertiesInis a pointer to the constraint properties determined by MAiNGO
[in]useIncommunicates what the solver is to be used for

◆ UbpNLopt() [2/2]

maingo::ubp::UbpNLopt::UbpNLopt ( const UbpNLopt )
private

default copy constructor declared private to prevent use

Member Function Documentation

◆ _NLopt_get_eq()

void UbpNLopt::_NLopt_get_eq ( unsigned  m,
double *  result,
unsigned  n,
const double *  x,
double *  grad,
void *  f_data 
)
staticprivate

Function providing gradient and value information on equalities to the NLopt interface.

Parameters
[in]mis the number of constraints
[in]nis the dimension of x
[in,out]resultholds the values at x
[in]xis the current point
[in,out]gradis the derivative
[in]f_datais not used

◆ _NLopt_get_ineq()

void UbpNLopt::_NLopt_get_ineq ( unsigned  m,
double *  result,
unsigned  n,
const double *  x,
double *  grad,
void *  f_data 
)
staticprivate

Function providing gradient and value information on inequalities to the NLopt interface.

Parameters
[in]mis the number of constraints
[in]nis the dimension of x
[in,out]resultholds the values at x
[in]xis the current point
[in,out]gradis the derivative
[in]f_datais not used

◆ _NLopt_get_objective()

double UbpNLopt::_NLopt_get_objective ( const std::vector< double > &  x,
std::vector< double > &  grad,
void *  f_data 
)
staticprivate

Function returning the objective value to the NLopt interface.

Parameters
[in]xis the current point
[in]gradis the derivative
[in]f_datais not used

◆ _solve_nlp()

SUBSOLVER_RETCODE UbpNLopt::_solve_nlp ( const std::vector< double > &  lowerVarBounds,
const std::vector< double > &  upperVarBounds,
double &  objectiveValue,
std::vector< double > &  solutionPoint 
)
privatevirtual

Function for actually solving the NLP sub-problem.

Parameters
[in]lowerVarBoundsis the vector containing the lower bounds on the variables within the current node
[in]upperVarBoundsis the vector containing the upper bounds on the variables within the current node
[out]objectiveValueis the objective value obtained for the solution point of the upper bounding problem (need not be a local optimum!)
[in,out]solutionPointis the point at which objectiveValue was achieved (can in principle be any point within the current node!); it is also used for communicating the initial point (usually the LBP solution point)
Returns
Return code, either SUBSOLVER_FEASIBLE or SUBSOLVER_INFEASIBLE, indicating whether the returned solutionPoint (!!) is feasible or not

Reimplemented from maingo::ubp::UpperBoundingSolver.

◆ operator=()

UbpNLopt& maingo::ubp::UbpNLopt::operator= ( const UbpNLopt )
private

default assignment operator declared private to prevent use

Member Data Documentation

◆ _NLopt

nlopt::opt maingo::ubp::UbpNLopt::_NLopt
private

NLopt solver object

◆ _NLoptSubopt

nlopt::opt maingo::ubp::UbpNLopt::_NLoptSubopt
private

NLopt solver object


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