Bonmin  1.7
Public Member Functions | Private Attributes
MyTMINLP Class Reference

A C++ example for interfacing an MINLP with bonmin. More...

#include <MyTMINLP.hpp>

Inheritance diagram for MyTMINLP:
Bonmin::TMINLP

List of all members.

Public Member Functions

 MyTMINLP ()
 Default constructor.
virtual ~MyTMINLP ()
 virtual destructor.
 MyTMINLP (const MyTMINLP &other)
 Copy constructor.
virtual const SosInfososConstraints () const
virtual const BranchingInfobranchingInfo () const
void printSolutionAtEndOfAlgorithm ()
Overloaded functions specific to a TMINLP.

Assignment operator.

no data = nothing to assign

virtual bool get_variables_types (Index n, VariableType *var_types)
 Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer.
virtual bool get_variables_linearity (Index n, Ipopt::TNLP::LinearityType *var_types)
 Pass info about linear and nonlinear variables.
virtual bool get_constraints_linearity (Index m, Ipopt::TNLP::LinearityType *const_types)
 Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer.
Overloaded functions defining a TNLP.

This group of function implement the various elements needed to define and solve a TNLP.

They are the same as those in a standard Ipopt NLP problem

virtual bool get_nlp_info (Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, TNLP::IndexStyleEnum &index_style)
 Method to pass the main dimensions of the problem to Ipopt.
virtual bool get_bounds_info (Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
 Method to pass the bounds on variables and constraints to Ipopt.
virtual bool get_starting_point (Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda)
 Method to to pass the starting point for optimization to Ipopt.
virtual bool eval_f (Index n, const Number *x, bool new_x, Number &obj_value)
 Method which compute the value of the objective function at point x.
virtual bool eval_grad_f (Index n, const Number *x, bool new_x, Number *grad_f)
 Method which compute the gradient of the objective at a point x.
virtual bool eval_g (Index n, const Number *x, bool new_x, Index m, Number *g)
 Method which compute the value of the functions defining the constraints at a point x.
virtual bool eval_jac_g (Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
 Method to compute the Jacobian of the functions defining the constraints.
virtual bool eval_h (Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values)
 Method to compute the Jacobian of the functions defining the constraints.
virtual void finalize_solution (TMINLP::SolverReturn status, Index n, const Number *x, Number obj_value)
 Method called by Ipopt at the end of optimization.

Private Attributes

bool printSol_

Detailed Description

A C++ example for interfacing an MINLP with bonmin.

This class implements the following NLP :

\[ \begin{array}{l} \min - x_0 - x_1 - x_2 \\ \mbox{s.t}\\ (x_1 - \frac{1}{2})^2 + (x_2 - \frac{1}{2})^2 \leq \frac{1}{4} \\ x_0 - x_1 \leq 0 \\ x_0 + x_2 + x_3 \leq 2\\ x_0 \in \{0,1\}^n \; (x_1, x_2) \in R^2 \; x_3 \in N \end{array} \]

Definition at line 28 of file MyTMINLP.hpp.


Constructor & Destructor Documentation

MyTMINLP::MyTMINLP ( ) [inline]

Default constructor.

Definition at line 32 of file MyTMINLP.hpp.

virtual MyTMINLP::~MyTMINLP ( ) [inline, virtual]

virtual destructor.

Definition at line 36 of file MyTMINLP.hpp.

MyTMINLP::MyTMINLP ( const MyTMINLP other) [inline]

Copy constructor.

Definition at line 40 of file MyTMINLP.hpp.


Member Function Documentation

bool MyTMINLP::get_variables_types ( Index  n,
VariableType var_types 
) [virtual]

Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer.

Parameters:
nsize of var_types (has to be equal to the number of variables in the problem)
var_typestypes of the variables (has to be filled by function).

Definition at line 13 of file MyTMINLP.cpp.

References Bonmin::TMINLP::BINARY, Bonmin::TMINLP::CONTINUOUS, and Bonmin::TMINLP::INTEGER.

bool MyTMINLP::get_variables_linearity ( Index  n,
Ipopt::TNLP::LinearityType *  var_types 
) [virtual]

Pass info about linear and nonlinear variables.

Definition at line 24 of file MyTMINLP.cpp.

bool MyTMINLP::get_constraints_linearity ( Index  m,
Ipopt::TNLP::LinearityType *  const_types 
) [virtual]

Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer.

Parameters:
msize of const_types (has to be equal to the number of constraints in the problem)
const_typestypes of the constraints (has to be filled by function).

Definition at line 35 of file MyTMINLP.cpp.

bool MyTMINLP::get_nlp_info ( Index &  n,
Index &  m,
Index &  nnz_jac_g,
Index &  nnz_h_lag,
TNLP::IndexStyleEnum &  index_style 
) [virtual]

Method to pass the main dimensions of the problem to Ipopt.

Parameters:
nnumber of variables in problem.
mnumber of constraints.
nnz_jac_gnumber of nonzeroes in Jacobian of constraints system.
nnz_h_lagnumber of nonzeroes in Hessian of the Lagrangean.
index_styleindicate wether arrays are numbered from 0 (C-style) or from 1 (Fortran).
Returns:
true in case of success.

Definition at line 44 of file MyTMINLP.cpp.

bool MyTMINLP::get_bounds_info ( Index  n,
Number *  x_l,
Number *  x_u,
Index  m,
Number *  g_l,
Number *  g_u 
) [virtual]

Method to pass the bounds on variables and constraints to Ipopt.

Parameters:
nsize of x_l and x_u (has to be equal to the number of variables in the problem)
x_llower bounds on variables (function should fill it).
x_uupper bounds on the variables (function should fill it).
msize of g_l and g_u (has to be equal to the number of constraints in the problem).
g_llower bounds of the constraints (function should fill it).
g_uupper bounds of the constraints (function should fill it).
Returns:
true in case of success.

Definition at line 56 of file MyTMINLP.cpp.

bool MyTMINLP::get_starting_point ( Index  n,
bool  init_x,
Number *  x,
bool  init_z,
Number *  z_L,
Number *  z_U,
Index  m,
bool  init_lambda,
Number *  lambda 
) [virtual]

Method to to pass the starting point for optimization to Ipopt.

Parameters:
init_xdo we initialize primals?
xpass starting primal points (function should fill it if init_x is 1).
msize of lambda (has to be equal to the number of constraints in the problem).
init_lambdado we initialize duals of constraints?
lambdalower bounds of the constraints (function should fill it).
Returns:
true in case of success.

Definition at line 85 of file MyTMINLP.cpp.

bool MyTMINLP::eval_f ( Index  n,
const Number *  x,
bool  new_x,
Number &  obj_value 
) [virtual]

Method which compute the value of the objective function at point x.

Parameters:
nsize of array x (has to be the number of variables in the problem).
xpoint where to evaluate.
new_xIs this the first time we evaluate functions at this point? (in the present context we don't care).
obj_valuevalue of objective in x (has to be computed by the function).
Returns:
true in case of success.

Definition at line 103 of file MyTMINLP.cpp.

bool MyTMINLP::eval_grad_f ( Index  n,
const Number *  x,
bool  new_x,
Number *  grad_f 
) [virtual]

Method which compute the gradient of the objective at a point x.

Parameters:
nsize of array x (has to be the number of variables in the problem).
xpoint where to evaluate.
new_xIs this the first time we evaluate functions at this point? (in the present context we don't care).
grad_fgradient of objective taken in x (function has to fill it).
Returns:
true in case of success.

Definition at line 111 of file MyTMINLP.cpp.

bool MyTMINLP::eval_g ( Index  n,
const Number *  x,
bool  new_x,
Index  m,
Number *  g 
) [virtual]

Method which compute the value of the functions defining the constraints at a point x.

Parameters:
nsize of array x (has to be the number of variables in the problem).
xpoint where to evaluate.
new_xIs this the first time we evaluate functions at this point? (in the present context we don't care).
msize of array g (has to be equal to the number of constraints in the problem)
grad_fvalues of the constraints (function has to fill it).
Returns:
true in case of success.

Definition at line 122 of file MyTMINLP.cpp.

bool MyTMINLP::eval_jac_g ( Index  n,
const Number *  x,
bool  new_x,
Index  m,
Index  nele_jac,
Index *  iRow,
Index *  jCol,
Number *  values 
) [virtual]

Method to compute the Jacobian of the functions defining the constraints.

If the parameter values==NULL fill the arrays iCol and jRow which store the position of the non-zero element of the Jacobian. If the paramenter values!=NULL fill values with the non-zero elements of the Jacobian.

Parameters:
nsize of array x (has to be the number of variables in the problem).
xpoint where to evaluate.
new_xIs this the first time we evaluate functions at this point? (in the present context we don't care).
msize of array g (has to be equal to the number of constraints in the problem)
grad_fvalues of the constraints (function has to fill it).
Returns:
true in case of success.

Definition at line 135 of file MyTMINLP.cpp.

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

Method to compute the Jacobian of the functions defining the constraints.

If the parameter values==NULL fill the arrays iCol and jRow which store the position of the non-zero element of the Jacobian. If the paramenter values!=NULL fill values with the non-zero elements of the Jacobian.

Parameters:
nsize of array x (has to be the number of variables in the problem).
xpoint where to evaluate.
new_xIs this the first time we evaluate functions at this point? (in the present context we don't care).
msize of array g (has to be equal to the number of constraints in the problem)
grad_fvalues of the constraints (function has to fill it).
Returns:
true in case of success.

Definition at line 181 of file MyTMINLP.cpp.

void MyTMINLP::finalize_solution ( TMINLP::SolverReturn  status,
Index  n,
const Number *  x,
Number  obj_value 
) [virtual]

Method called by Ipopt at the end of optimization.

Definition at line 205 of file MyTMINLP.cpp.

References printSol_.

virtual const SosInfo* MyTMINLP::sosConstraints ( ) const [inline, virtual]

Implements Bonmin::TMINLP.

Definition at line 169 of file MyTMINLP.hpp.

virtual const BranchingInfo* MyTMINLP::branchingInfo ( ) const [inline, virtual]

Implements Bonmin::TMINLP.

Definition at line 170 of file MyTMINLP.hpp.

void MyTMINLP::printSolutionAtEndOfAlgorithm ( ) [inline]

Definition at line 173 of file MyTMINLP.hpp.


Member Data Documentation

bool MyTMINLP::printSol_ [private]

Definition at line 177 of file MyTMINLP.hpp.

Referenced by finalize_solution().


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