MAiNGO
maingo::ubp::IpoptProblem Class Reference

Class for representing problems to be solved by IpOpt, providing an interface to the problem definition in problem.h used by MC++. More...

#include <ipoptProblem.h>

Inheritance diagram for maingo::ubp::IpoptProblem:

Public Member Functions

 IpoptProblem ()
 Standard constructor. More...
 
 IpoptProblem (unsigned nvarIn, unsigned neqIn, unsigned nineqIn, unsigned nineqSquashIn, UbpStructure *structureIn, std::vector< Constraint > *constraintPropertiesIn, std::shared_ptr< DagObj > dagObj)
 Constructor actually used in ubp.cpp. Initializes the corresponding members. More...
 
virtual ~IpoptProblem ()
 Destructor. More...
 
virtual bool get_nlp_info (Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, IndexStyleEnum &Index_style)
 Function called by Ipopt to get basic information on the problem. More...
 
virtual bool get_bounds_info (Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
 Function called by Ipopt to get information on variables bounds. More...
 
virtual bool get_starting_point (Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
 Function called by Ipopt to query the starting point for local search. More...
 
virtual bool eval_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
 Function called by Ipopt to evaluate the objective function. More...
 
virtual bool eval_grad_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
 Function called by Ipopt to evaluate the gradient of the objective function. More...
 
virtual bool eval_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
 Function called by Ipopt to evaluate the constraints. More...
 
virtual bool eval_jac_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
 Function called by Ipopt to evaluate the constraints. More...
 
virtual bool eval_h (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number *lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
 Function called by Ipopt to evaluate the Hessian - not implemented, just throws an exception! More...
 
virtual void finalize_solution (Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, const Ipopt::Number *z_L, const Ipopt::Number *z_U, Ipopt::Index m, const Ipopt::Number *g, const Ipopt::Number *lambda, Ipopt::Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
 Function called by Ipopt to communicate the result of the local search. More...
 
double get_solution (std::vector< double > &sol_x)
 Function called from the upper bounding wrapper to query the solution. More...
 
void set_bounds_and_starting_point (const std::vector< double > &xL, const std::vector< double > &xU, const std::vector< double > &xStart)
 Function called from the upper bounding wrapper to specify the variable bounds and starting point. More...
 

Private Member Functions

 IpoptProblem (const IpoptProblem &)
 
IpoptProblemoperator= (const IpoptProblem &)
 

Private Attributes

std::shared_ptr< DagObj_DAGobj
 
Internal IPOPT variables
Ipopt::Index _nvar
 
Ipopt::Index _nineq
 
Ipopt::Index _nineqSquash
 
Ipopt::Index _neq
 
UbpStructure_structure
 
std::vector< Constraint > * _constraintProperties
 
double _solution_f
 
std::vector< double > _xL
 
std::vector< double > _xU
 
std::vector< double > _xStart
 
std::vector< double > _solutionX
 

Detailed Description

Class for representing problems to be solved by IpOpt, providing an interface to the problem definition in problem.h used by MC++.

This class is a specialization of the problem definition class within the Ipopt C++ API. It provides an interface between Ipopt and the problem definition in problem.h. by evaluating the Model equations and preparing the information required by Ipopt. An instance of this class is handed to Ipopt as an argument of its optimizeTNLP routine in ubp.cpp. For more information on the basic interface see https://www.coin-or.org/Ipopt/documentation/node23.html.

Constructor & Destructor Documentation

◆ IpoptProblem() [1/3]

maingo::ubp::IpoptProblem::IpoptProblem ( )

Standard constructor.

◆ IpoptProblem() [2/3]

IpoptProblem::IpoptProblem ( unsigned  nvarIn,
unsigned  neqIn,
unsigned  nineqIn,
unsigned  nineqSquashIn,
UbpStructure structureIn,
std::vector< Constraint > *  constraintPropertiesIn,
std::shared_ptr< DagObj dagObj 
)

Constructor actually used in ubp.cpp. Initializes the corresponding members.

Parameters
[in]nvarInis the number of optimization variables
[in]neqInis the number of equality constraints
[in]nineqInis the number of inequality constraints
[in]nineqSquashInis the number of squash inequality constraints which are to be used only if the squash node has been used
[in]structureInis a struct containing information on sparsity patterns of the Lagrangian and Hessian
[in]constraintPropertiesInis a pointer to the constraint properties determined by MAiNGO
[in]dagObjis a pointer to the struct holding the DAG to be evaluated

◆ ~IpoptProblem()

IpoptProblem::~IpoptProblem ( )
virtual

Destructor.

◆ IpoptProblem() [3/3]

maingo::ubp::IpoptProblem::IpoptProblem ( const IpoptProblem )
private

default copy constructor declared private to prevent use

Member Function Documentation

◆ eval_f()

bool IpoptProblem::eval_f ( Ipopt::Index  n,
const Ipopt::Number *  x,
bool  new_x,
Ipopt::Number &  obj_value 
)
virtual

Function called by Ipopt to evaluate the objective function.

Parameters
[in]nis the number of optimization variables
[in]xis a pointer to an array containing the point at which the objective is to be evaluated
[in]new_xindicates whether the current x is different from the previous one handed to one of the evaluation functions
[out]obj_valueis the value of the objective function at the current point

◆ eval_g()

bool IpoptProblem::eval_g ( Ipopt::Index  n,
const Ipopt::Number *  x,
bool  new_x,
Ipopt::Index  m,
Ipopt::Number *  g 
)
virtual

Function called by Ipopt to evaluate the constraints.

Parameters
[in]nis the number of optimization variables
[in]xis a pointer to an array containing the point at which the objective is to be evaluated
[in]new_xindicates whether the current x is different from the previous one handed to one of the evaluation functions
[in]mis the total number of constraints (both equality and inequality)
[out]gis a pointer to an array containing the values of the constraints at the current point

◆ eval_grad_f()

bool IpoptProblem::eval_grad_f ( Ipopt::Index  n,
const Ipopt::Number *  x,
bool  new_x,
Ipopt::Number *  grad_f 
)
virtual

Function called by Ipopt to evaluate the gradient of the objective function.

Parameters
[in]nis the number of optimization variables
[in]xis a pointer to an array containing the point at which the objective is to be evaluated
[in]new_xindicates whether the current x is different from the previous one handed to one of the evaluation functions
[out]grad_fis a pointer to an array containing the gradient of the objective function at the current point

◆ eval_h()

bool IpoptProblem::eval_h ( Ipopt::Index  n,
const Ipopt::Number *  x,
bool  new_x,
Ipopt::Number  obj_factor,
Ipopt::Index  m,
const Ipopt::Number *  lambda,
bool  new_lambda,
Ipopt::Index  nele_hess,
Ipopt::Index *  iRow,
Ipopt::Index *  jCol,
Ipopt::Number *  values 
)
virtual

Function called by Ipopt to evaluate the Hessian - not implemented, just throws an exception!

Parameters
[in]nnot implemented
[in]xnot implemented
[in]new_xnot implemented
[in]obj_factornot implemented
[in]mnot implemented
[in]lambdanot implemented
[in]new_lambdanot implemented
[in]nele_hessnot implemented
[in]iRownot implemented
[in]jColnot implemented
[in]valuesnot implemented

◆ eval_jac_g()

bool IpoptProblem::eval_jac_g ( Ipopt::Index  n,
const Ipopt::Number *  x,
bool  new_x,
Ipopt::Index  m,
Ipopt::Index  nele_jac,
Ipopt::Index *  iRow,
Ipopt::Index *  jCol,
Ipopt::Number *  values 
)
virtual

Function called by Ipopt to evaluate the constraints.

Parameters
[in]nis the number of optimization variables
[in]xis a pointer to an array containing the point at which the objective is to be evaluated
[in]new_xindicates whether the current x is different from the previous one handed to one of the evaluation functions
[in]mis the total number of constraints (both equality and inequality)
[in]nele_jacis not documented in MAiNGO
[out]iRowis a pointer to an array containing the row indices according to the sparsity pattern (see https://www.coin-or.org/Ipopt/documentation/node23.html).
[out]jColis a pointer to an array containing the row indices according to the sparsity pattern (see https://www.coin-or.org/Ipopt/documentation/node23.html).
[in,out]valuesis a pointer to an array containing the jacobian of the constraints at the current point. If the function is called with values==NULL, only information on the structure of the Jacobian is required.

◆ finalize_solution()

void IpoptProblem::finalize_solution ( Ipopt::SolverReturn  status,
Ipopt::Index  n,
const Ipopt::Number *  x,
const Ipopt::Number *  z_L,
const Ipopt::Number *  z_U,
Ipopt::Index  m,
const Ipopt::Number *  g,
const Ipopt::Number *  lambda,
Ipopt::Number  obj_value,
const Ipopt::IpoptData *  ip_data,
Ipopt::IpoptCalculatedQuantities *  ip_cq 
)
virtual

Function called by Ipopt to communicate the result of the local search.

Parameters
[in]statusReturn code of Ipopt (not used since feasibility is checked in ubp.cpp and local optimality is not as important in this case).
[in]nis the number of optimization variables
[in]xis a pointer to an array containing the solution point of the local search
[in]obj_valueis the objective function value at the solution point
[in]z_Lnot used
[in]z_Unot used
[in]mnot used
[in]gnot used
[in]lambdanot used
[in]ip_datanot used
[in]ip_cqnot used

◆ get_bounds_info()

bool IpoptProblem::get_bounds_info ( Ipopt::Index  n,
Ipopt::Number *  x_l,
Ipopt::Number *  x_u,
Ipopt::Index  m,
Ipopt::Number *  g_l,
Ipopt::Number *  g_u 
)
virtual

Function called by Ipopt to get information on variables bounds.

Parameters
[in]nis the number of optimization variables
[in]mis the total number of constraints (both equality and inequality)
[out]x_lis a pointer to an array containing the lower bounds on the optimization variables
[out]x_uis a pointer to an array containing the upper bounds on the optimization variables
[out]g_lis a pointer to an array containing the lower bounds on the constraints (zero for equalities, and -2e19 for inequalities)
[out]g_uis a pointer to an array containing the upper bounds on the constraints (all zero)

◆ get_nlp_info()

bool IpoptProblem::get_nlp_info ( Ipopt::Index &  n,
Ipopt::Index &  m,
Ipopt::Index &  nnz_jac_g,
Ipopt::Index &  nnz_h_lag,
IndexStyleEnum &  Index_style 
)
virtual

Function called by Ipopt to get basic information on the problem.

Parameters
[out]nis the number of optimization variables
[out]mis the total number of constraints (both equality and inequality)
[out]nnz_jac_gis the number of non-zero elements of the Jacobian of the constraints (assumed to be dense)
[out]nnz_h_lagis the number of non-zero elements of the Hessian of the Lagrangian (not used since BigMC currently only relies on BFGS)
[out]Index_styleInformation on indexing of arrays (using C-style indexing, i.e., starting with 0)

◆ get_solution()

double IpoptProblem::get_solution ( std::vector< double > &  sol_x)

Function called from the upper bounding wrapper to query the solution.

Parameters
[out]sol_xis a vector containing the solution point
Returns
Objective value at solution point

◆ get_starting_point()

bool IpoptProblem::get_starting_point ( Ipopt::Index  n,
bool  init_x,
Ipopt::Number *  x,
bool  init_z,
Ipopt::Number *  z_L,
Ipopt::Number *  z_U,
Ipopt::Index  m,
bool  init_lambda,
Ipopt::Number *  lambda 
)
virtual

Function called by Ipopt to query the starting point for local search.

Parameters
[in]nis the number of optimization variables
[in]mis the total number of constraints (both equality and inequality)
[in]init_xindicates that a starting point for x is required
[out]xis a pointer to an array containing the initial point
[in]init_znot used in MAiNGO implementation
[in]z_Lnot used in MAiNGO implementation
[in]z_Unot used in MAiNGO implementation
[in]init_lambdanot used in MAiNGO implementation
[in]lambdanot used in MAiNGO implementation

◆ operator=()

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

default assignment operator declared private to prevent use

◆ set_bounds_and_starting_point()

void IpoptProblem::set_bounds_and_starting_point ( const std::vector< double > &  xL,
const std::vector< double > &  xU,
const std::vector< double > &  xStart 
)

Function called from the upper bounding wrapper to specify the variable bounds and starting point.

Parameters
[in]xLis a vector containing the lower bounds on the optimization variables
[in]xUis a vector containing the upper bounds on the optimization variables
[in]xStartis a vector containing the starting point to be used in local search

Member Data Documentation

◆ _constraintProperties

std::vector<Constraint>* maingo::ubp::IpoptProblem::_constraintProperties
private

pointer to constraint properties determined by MAiNGO

◆ _DAGobj

std::shared_ptr<DagObj> maingo::ubp::IpoptProblem::_DAGobj
private

pointer to object containing DAG for upper bounding

◆ _neq

Ipopt::Index maingo::ubp::IpoptProblem::_neq
private

number of equalities

◆ _nineq

Ipopt::Index maingo::ubp::IpoptProblem::_nineq
private

number of inequalities

◆ _nineqSquash

Ipopt::Index maingo::ubp::IpoptProblem::_nineqSquash
private

number of squash inequalities

◆ _nvar

Ipopt::Index maingo::ubp::IpoptProblem::_nvar
private

number of variables

◆ _solution_f

double maingo::ubp::IpoptProblem::_solution_f
private

solution value

◆ _solutionX

std::vector<double> maingo::ubp::IpoptProblem::_solutionX
private

vector holding the solution point

◆ _structure

UbpStructure* maingo::ubp::IpoptProblem::_structure
private

pointer to struct storing information on the problem structure

◆ _xL

std::vector<double> maingo::ubp::IpoptProblem::_xL
private

vector holding lower bounds

◆ _xStart

std::vector<double> maingo::ubp::IpoptProblem::_xStart
private

vector holding the initial point

◆ _xU

std::vector<double> maingo::ubp::IpoptProblem::_xU
private

vector holding upper bounds


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