Couenne::CouenneTNLP Class Reference

Class for handling NLPs using CouenneProblem. More...

#include <CouenneTNLP.hpp>

Collaboration diagram for Couenne::CouenneTNLP:

Collaboration graph
[legend]
List of all members.

Methods for quasi-Newton approximation. If the second

derivatives are approximated by Ipopt, it is better to do this only in the space of nonlinear variables. The following methods are call by Ipopt if the quasi-Newton approximation is selected. If -1 is returned as number of nonlinear variables, Ipopt assumes that all variables are nonlinear. Otherwise, it calls get_list_of_nonlinear_variables with an array into which the indices of the nonlinear variables should be written - the array has the lengths num_nonlin_vars, which is identical with the return value of get_number_of_nonlinear_variables (). It is assumed that the indices are counted starting with 1 in the FORTRAN_STYLE, and 0 for the C_STYLE.

virtual Ipopt::Index get_number_of_nonlinear_variables ()
virtual bool get_list_of_nonlinear_variables (Ipopt::Index num_nonlin_vars, Ipopt::Index *pos_nonlin_vars)
 get real list
virtual void setObjective (expression *newObj)
 Change objective function and modify gradient expressions accordingly.
CouenneSparseMatrix *& optHessian ()
 Get methods.
bool & getSaveOptHessian ()
 set and get saveOptHessian_
CouenneProblemproblem_
 Pointer to the object containing all info.
CouNumbersol0_
 Initial solution.
CouNumbersol_
 Optimal solution.
CouNumber bestZ_
 Value of the optimal solution.
std::vector< std::pair< int,
expression * > > 
gradient_
 expression gradient (packed sparse vector)
std::set< int > nonLinVars_
 list of nonlinear variables
ExprJac Jac_
 Jacobian.
ExprHessHLa_
 Hessian --- there are 1+m of them, but all are squeezed in a single object.
CouenneSparseMatrixoptHessian_
 Stores the values of the Hessian of the Lagrangian at optimum for later use.
bool saveOptHessian_
 flag to be set to save this solution's Lagrangian hessian in above structure

Public Member Functions

 CouenneTNLP ()
 Empty constructor.
 CouenneTNLP (CouenneProblem *)
 Constructor.
 CouenneTNLP (const CouenneTNLP &)
 Copy constructor.
CouenneTNLPoperator= (const CouenneTNLP &rhs)
 Assignment.
CouenneTNLPclone ()
 Clone.
virtual ~CouenneTNLP ()
 Destructor.
void setInitSol (double *sol)
 set initial solution
CouNumbergetSolution ()
 returns best solution (if it exists)
CouNumber getSolValue ()
 returns value of the best solution
virtual bool get_nlp_info (Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, enum Ipopt::TNLP::IndexStyleEnum &index_style)
 return the number of variables and constraints, and the number of non-zeros in the jacobian and the hessian.
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)
 return the information about the bound on the variables and constraints.
virtual bool get_variables_linearity (Ipopt::Index n, Ipopt::TNLP::LinearityType *var_types)
 return the variables linearity (TNLP::Linear or TNLP::NonLinear).
virtual bool get_constraints_linearity (Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
 return the constraint linearity.
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)
 return the starting point.
virtual bool eval_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
 return the value of the objective function
virtual bool eval_grad_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
 return the vector of the gradient of the objective w.r.t. x
virtual bool eval_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
 return the vector of constraint values
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)
 return the jacobian of the constraints.
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)
 return the hessian of the lagrangian.
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)
 This method is called when the algorithm is complete so the TNLP can store/write the solution.
virtual bool intermediate_callback (Ipopt::AlgorithmMode mode, Ipopt::Index iter, Ipopt::Number obj_value, Ipopt::Number inf_pr, Ipopt::Number inf_du, Ipopt::Number mu, Ipopt::Number d_norm, Ipopt::Number regularization_size, Ipopt::Number alpha_du, Ipopt::Number alpha_pr, Ipopt::Index ls_trials, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
 Intermediate Callback method for the user.

Detailed Description

Class for handling NLPs using CouenneProblem.

Definition at line 27 of file CouenneTNLP.hpp.


Constructor & Destructor Documentation

CouenneTNLP::CouenneTNLP (  ) 

Empty constructor.

Definition at line 32 of file CouenneTNLP.cpp.

Referenced by clone().

CouenneTNLP::CouenneTNLP ( CouenneProblem  ) 

Constructor.

Definition at line 58 of file CouenneTNLP.cpp.

References Couenne::AUX, e, gradient_, Couenne::LINEAR, nonLinVars_, problem_, Couenne::STOP_AT_AUX, and Couenne::VAR.

CouenneTNLP::CouenneTNLP ( const CouenneTNLP  ) 

Copy constructor.

Definition at line 124 of file CouenneTNLP.cpp.

References operator=().

CouenneTNLP::~CouenneTNLP (  )  [virtual]

Destructor.

Definition at line 44 of file CouenneTNLP.cpp.

References gradient_, HLa_, optHessian_, sol0_, and sol_.


Member Function Documentation

CouenneTNLP & CouenneTNLP::operator= ( const CouenneTNLP rhs  ) 

Assignment.

Definition at line 129 of file CouenneTNLP.cpp.

References bestZ_, gradient_, HLa_, Jac_, nonLinVars_, optHessian_, problem_, saveOptHessian_, sol0_, and sol_.

Referenced by CouenneTNLP().

CouenneTNLP * CouenneTNLP::clone (  ) 

Clone.

Definition at line 150 of file CouenneTNLP.cpp.

References CouenneTNLP().

void CouenneTNLP::setInitSol ( double *  sol  ) 

set initial solution

Definition at line 177 of file CouenneTNLP.cpp.

References problem_, and sol0_.

CouNumber* Couenne::CouenneTNLP::getSolution (  )  [inline]

returns best solution (if it exists)

Definition at line 53 of file CouenneTNLP.hpp.

References sol_.

CouNumber Couenne::CouenneTNLP::getSolValue (  )  [inline]

returns value of the best solution

Definition at line 57 of file CouenneTNLP.hpp.

References bestZ_.

virtual bool Couenne::CouenneTNLP::get_nlp_info ( Ipopt::Index &  n,
Ipopt::Index &  m,
Ipopt::Index &  nnz_jac_g,
Ipopt::Index &  nnz_h_lag,
enum Ipopt::TNLP::IndexStyleEnum &  index_style 
) [virtual]

return the number of variables and constraints, and the number of non-zeros in the jacobian and the hessian.

The index_style parameter lets you specify C or Fortran style indexing for the sparse matrix iRow and jCol parameters. C_STYLE is 0-based, and FORTRAN_STYLE is 1-based.

virtual bool Couenne::CouenneTNLP::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]

return the information about the bound on the variables and constraints.

The value that indicates that a bound does not exist is specified in the parameters nlp_lower_bound_inf and nlp_upper_bound_inf. By default, nlp_lower_bound_inf is -1e19 and nlp_upper_bound_inf is 1e19. (see TNLPAdapter)

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

return the variables linearity (TNLP::Linear or TNLP::NonLinear).

The var_types array should be allocated with length at least n. (default implementation just return false and does not fill the array).

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

return the constraint linearity.

array should be alocated with length at least n. (default implementation just return false and does not fill the array).

virtual bool Couenne::CouenneTNLP::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]

return the starting point.

The bool variables indicate whether the algorithm wants you to initialize x, z_L/z_u, and lambda, respectively. If, for some reason, the algorithm wants you to initialize these and you cannot, return false, which will cause Ipopt to stop. You will have to run Ipopt with different options then.

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

return the value of the objective function

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

return the vector of the gradient of the objective w.r.t. x

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

return the vector of constraint values

virtual bool Couenne::CouenneTNLP::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]

return the jacobian of the constraints.

The vectors iRow and jCol only need to be set once. The first call is used to set the structure only (iRow and jCol will be non-NULL, and values will be NULL) For subsequent calls, iRow and jCol will be NULL.

virtual bool Couenne::CouenneTNLP::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]

return the hessian of the lagrangian.

The vectors iRow and jCol only need to be set once (during the first call). The first call is used to set the structure only (iRow and jCol will be non-NULL, and values will be NULL) For subsequent calls, iRow and jCol will be NULL. This matrix is symmetric - specify the lower diagonal only. A default implementation is provided, in case the user wants to se quasi-Newton approximations to estimate the second derivatives and doesn't not neet to implement this method.

virtual void Couenne::CouenneTNLP::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]

This method is called when the algorithm is complete so the TNLP can store/write the solution.

virtual bool Couenne::CouenneTNLP::intermediate_callback ( Ipopt::AlgorithmMode  mode,
Ipopt::Index  iter,
Ipopt::Number  obj_value,
Ipopt::Number  inf_pr,
Ipopt::Number  inf_du,
Ipopt::Number  mu,
Ipopt::Number  d_norm,
Ipopt::Number  regularization_size,
Ipopt::Number  alpha_du,
Ipopt::Number  alpha_pr,
Ipopt::Index  ls_trials,
const Ipopt::IpoptData *  ip_data,
Ipopt::IpoptCalculatedQuantities *  ip_cq 
) [virtual]

Intermediate Callback method for the user.

Providing dummy default implementation. For details see IntermediateCallBack in IpNLP.hpp.

Index CouenneTNLP::get_number_of_nonlinear_variables (  )  [virtual]

Definition at line 707 of file CouenneTNLP.cpp.

References nonLinVars_.

virtual bool Couenne::CouenneTNLP::get_list_of_nonlinear_variables ( Ipopt::Index  num_nonlin_vars,
Ipopt::Index *  pos_nonlin_vars 
) [virtual]

get real list

void CouenneTNLP::setObjective ( expression newObj  )  [virtual]

Change objective function and modify gradient expressions accordingly.

Definition at line 570 of file CouenneTNLP.cpp.

References gradient_, HLa_, problem_, and Couenne::STOP_AT_AUX.

CouenneSparseMatrix*& Couenne::CouenneTNLP::optHessian (  )  [inline]

Get methods.

Definition at line 182 of file CouenneTNLP.hpp.

References optHessian_.

bool& Couenne::CouenneTNLP::getSaveOptHessian (  )  [inline]

set and get saveOptHessian_

Definition at line 186 of file CouenneTNLP.hpp.

References saveOptHessian_.


Member Data Documentation

CouenneProblem* Couenne::CouenneTNLP::problem_ [private]

Pointer to the object containing all info.

Definition at line 192 of file CouenneTNLP.hpp.

Referenced by CouenneTNLP(), operator=(), setInitSol(), and setObjective().

CouNumber* Couenne::CouenneTNLP::sol0_ [private]

Initial solution.

Definition at line 195 of file CouenneTNLP.hpp.

Referenced by operator=(), setInitSol(), and ~CouenneTNLP().

CouNumber* Couenne::CouenneTNLP::sol_ [private]

Optimal solution.

Definition at line 198 of file CouenneTNLP.hpp.

Referenced by getSolution(), operator=(), and ~CouenneTNLP().

CouNumber Couenne::CouenneTNLP::bestZ_ [private]

Value of the optimal solution.

Definition at line 201 of file CouenneTNLP.hpp.

Referenced by getSolValue(), and operator=().

std::vector<std::pair <int, expression *> > Couenne::CouenneTNLP::gradient_ [private]

expression gradient (packed sparse vector)

Definition at line 204 of file CouenneTNLP.hpp.

Referenced by CouenneTNLP(), operator=(), setObjective(), and ~CouenneTNLP().

std::set<int> Couenne::CouenneTNLP::nonLinVars_ [private]

list of nonlinear variables

Definition at line 207 of file CouenneTNLP.hpp.

Referenced by CouenneTNLP(), get_number_of_nonlinear_variables(), and operator=().

ExprJac Couenne::CouenneTNLP::Jac_ [private]

Jacobian.

Definition at line 210 of file CouenneTNLP.hpp.

Referenced by operator=().

ExprHess* Couenne::CouenneTNLP::HLa_ [private]

Hessian --- there are 1+m of them, but all are squeezed in a single object.

Definition at line 214 of file CouenneTNLP.hpp.

Referenced by operator=(), setObjective(), and ~CouenneTNLP().

CouenneSparseMatrix* Couenne::CouenneTNLP::optHessian_ [private]

Stores the values of the Hessian of the Lagrangian at optimum for later use.

Definition at line 217 of file CouenneTNLP.hpp.

Referenced by operator=(), optHessian(), and ~CouenneTNLP().

bool Couenne::CouenneTNLP::saveOptHessian_ [private]

flag to be set to save this solution's Lagrangian hessian in above structure

Definition at line 220 of file CouenneTNLP.hpp.

Referenced by getSaveOptHessian(), and operator=().


The documentation for this class was generated from the following files:
Generated on Thu Sep 22 03:15:01 2011 by  doxygen 1.4.7