|
Bonmin
1.7
|
A C++ example for interfacing an MINLP with bonmin. More...
#include <MyTMINLP.hpp>
Public Member Functions | |
| MyTMINLP () | |
| Default constructor. | |
| virtual | ~MyTMINLP () |
| virtual destructor. | |
| MyTMINLP (const MyTMINLP &other) | |
| Copy constructor. | |
| virtual const SosInfo * | sosConstraints () const |
| virtual const BranchingInfo * | branchingInfo () 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_ |
A C++ example for interfacing an MINLP with bonmin.
This class implements the following NLP :
Definition at line 28 of file MyTMINLP.hpp.
| 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.
| bool MyTMINLP::get_variables_types | ( | Index | n, |
| VariableType * | var_types | ||
| ) | [virtual] |
Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer.
| n | size of var_types (has to be equal to the number of variables in the problem) |
| var_types | types 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.
| m | size of const_types (has to be equal to the number of constraints in the problem) |
| const_types | types 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.
| n | number of variables in problem. |
| m | number of constraints. |
| nnz_jac_g | number of nonzeroes in Jacobian of constraints system. |
| nnz_h_lag | number of nonzeroes in Hessian of the Lagrangean. |
| index_style | indicate wether arrays are numbered from 0 (C-style) or from 1 (Fortran). |
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.
| n | size of x_l and x_u (has to be equal to the number of variables in the problem) |
| x_l | lower bounds on variables (function should fill it). |
| x_u | upper bounds on the variables (function should fill it). |
| m | size of g_l and g_u (has to be equal to the number of constraints in the problem). |
| g_l | lower bounds of the constraints (function should fill it). |
| g_u | upper bounds of the constraints (function should fill it). |
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.
| init_x | do we initialize primals? |
| x | pass starting primal points (function should fill it if init_x is 1). |
| m | size of lambda (has to be equal to the number of constraints in the problem). |
| init_lambda | do we initialize duals of constraints? |
| lambda | lower bounds of the constraints (function should fill it). |
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.
| n | size of array x (has to be the number of variables in the problem). |
| x | point where to evaluate. |
| new_x | Is this the first time we evaluate functions at this point? (in the present context we don't care). |
| obj_value | value of objective in x (has to be computed by the function). |
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.
| n | size of array x (has to be the number of variables in the problem). |
| x | point where to evaluate. |
| new_x | Is this the first time we evaluate functions at this point? (in the present context we don't care). |
| grad_f | gradient of objective taken in x (function has to fill it). |
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.
| n | size of array x (has to be the number of variables in the problem). |
| x | point where to evaluate. |
| new_x | Is this the first time we evaluate functions at this point? (in the present context we don't care). |
| m | size of array g (has to be equal to the number of constraints in the problem) |
| grad_f | values of the constraints (function has to fill it). |
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.
| n | size of array x (has to be the number of variables in the problem). |
| x | point where to evaluate. |
| new_x | Is this the first time we evaluate functions at this point? (in the present context we don't care). |
| m | size of array g (has to be equal to the number of constraints in the problem) |
| grad_f | values of the constraints (function has to fill it). |
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.
| n | size of array x (has to be the number of variables in the problem). |
| x | point where to evaluate. |
| new_x | Is this the first time we evaluate functions at this point? (in the present context we don't care). |
| m | size of array g (has to be equal to the number of constraints in the problem) |
| grad_f | values of the constraints (function has to fill it). |
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.
bool MyTMINLP::printSol_ [private] |
Definition at line 177 of file MyTMINLP.hpp.
Referenced by finalize_solution().
1.7.5.1