A C++ example for interfacing an MINLP with bonmin. More...
#include <MyTMINLP.hpp>


Public Member Functions | |
| MyTMINLP () | |
| Default constructor. More... | |
| virtual | ~MyTMINLP () |
| virtual destructor. More... | |
| MyTMINLP (const MyTMINLP &other) | |
| Copy constructor. More... | |
| virtual const SosInfo * | sosConstraints () const |
| virtual const BranchingInfo * | branchingInfo () const |
| void | printSolutionAtEndOfAlgorithm () |
| MyTMINLP () | |
| Default constructor. More... | |
| virtual | ~MyTMINLP () |
| virtual destructor. More... | |
| MyTMINLP (const MyTMINLP &other) | |
| Copy constructor. More... | |
| 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. More... | |
| virtual bool | get_variables_linearity (Index n, Ipopt::TNLP::LinearityType *var_types) |
| Pass info about linear and nonlinear variables. More... | |
| virtual bool | get_constraints_linearity (Index m, Ipopt::TNLP::LinearityType *const_types) |
| Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer. More... | |
| virtual bool | get_variables_types (Index n, VariableType *var_types) |
| Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer. More... | |
| virtual bool | get_variables_linearity (Index n, Ipopt::TNLP::LinearityType *var_types) |
| Pass info about linear and nonlinear variables. More... | |
| virtual bool | get_constraints_linearity (Index m, Ipopt::TNLP::LinearityType *const_types) |
| Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer. More... | |
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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| virtual void | finalize_solution (TMINLP::SolverReturn status, Index n, const Number *x, Number obj_value) |
| Method called by Ipopt at the end of optimization. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| virtual void | finalize_solution (TMINLP::SolverReturn status, Index n, const Number *x, Number obj_value) |
| Method called by Ipopt at the end of optimization. More... | |
Public Member Functions inherited from Bonmin::TMINLP | |
| virtual const PerturbInfo * | perturbInfo () const |
| virtual bool | hasUpperBoundingObjective () |
| Say if has a specific function to compute upper bounds. More... | |
| virtual bool | eval_upper_bound_f (Ipopt::Index n, const Ipopt::Number *x, Ipopt::Number &obj_value) |
| overload this method to return the value of an alternative objective function for upper bounding (to use it hasUpperBoundingObjective should return true). More... | |
| virtual bool | get_constraint_convexities (int m, TMINLP::Convexity *constraints_convexities) const |
| Get accest to constraint convexities. More... | |
| virtual bool | get_number_nonconvex (int &number_non_conv, int &number_concave) const |
| Get dimension information on nonconvex constraints. More... | |
| virtual bool | get_constraint_convexities (int number_non_conv, MarkedNonConvex *non_convs) const |
| Get array describing the constraints marked nonconvex in the model. More... | |
| virtual bool | get_simple_concave_constraints (int number_concave, SimpleConcaveConstraint *simple_concave) const |
| Fill array containing indices of simple concave constraints. More... | |
| virtual bool | hasLinearObjective () |
| Say if problem has a linear objective (for OA) More... | |
| bool | hasGeneralInteger () |
| Say if problem has general integer variables. More... | |
| virtual const int * | get_const_xtra_id () const |
| Access array describing constraint to which perspectives should be applied. More... | |
| TMINLP () | |
| Default destructor. More... | |
| virtual | ~TMINLP () |
| Default destructor. More... | |
| virtual bool | get_nlp_info (Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, Ipopt::TNLP::IndexStyleEnum &index_style)=0 |
| overload this method to return the number of variables and constraints, and the number of non-zeros in the jacobian and the hessian. More... | |
| virtual bool | get_scaling_parameters (Ipopt::Number &obj_scaling, bool &use_x_scaling, Ipopt::Index n, Ipopt::Number *x_scaling, bool &use_g_scaling, Ipopt::Index m, Ipopt::Number *g_scaling) |
| overload this method to return scaling parameters. More... | |
| virtual bool | get_variables_types (Ipopt::Index n, VariableType *var_types)=0 |
| overload this method to provide the variables types. More... | |
| virtual bool | get_variables_linearity (Ipopt::Index n, Ipopt::TNLP::LinearityType *var_types)=0 |
| overload this method to provide the variables linearity. More... | |
| virtual bool | get_constraints_linearity (Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)=0 |
| overload this method to provide the constraint linearity. 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)=0 |
| overload this method to return the information about the bound on the variables and constraints. 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)=0 |
| overload this method to return the starting point. More... | |
| virtual bool | eval_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)=0 |
| overload this method to return the value of the objective function More... | |
| virtual bool | eval_grad_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)=0 |
| overload this method to return the vector of the gradient of the objective w.r.t. More... | |
| virtual bool | eval_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)=0 |
| overload this method to return the vector of constraint values 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)=0 |
| overload this method to return the jacobian of 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)=0 |
| overload this method to return the hessian of the lagrangian. More... | |
| virtual bool | eval_gi (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index i, Ipopt::Number &gi) |
| Compute the value of a single constraint. More... | |
| virtual bool | eval_grad_gi (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index i, Ipopt::Index &nele_grad_gi, Ipopt::Index *jCol, Ipopt::Number *values) |
| Compute the structure or values of the gradient for one constraint. More... | |
| virtual void | finalize_solution (TMINLP::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, Ipopt::Number obj_value)=0 |
| This method is called when the algorithm is complete so the TNLP can store/write the solution. More... | |
Private Attributes | |
| bool | printSol_ |
Additional Inherited Members | |
Public Types inherited from Bonmin::TMINLP | |
| enum | SolverReturn { SUCCESS, INFEASIBLE, CONTINUOUS_UNBOUNDED, LIMIT_EXCEEDED, USER_INTERRUPT, MINLP_ERROR } |
| Return statuses of algorithm. More... | |
| enum | VariableType { CONTINUOUS, BINARY, INTEGER } |
| Type of the variables. More... | |
| enum | Convexity { Convex, NonConvex, SimpleConcave } |
| Used to mark constraints of the problem. More... | |
Protected Member Functions inherited from Bonmin::TMINLP | |
| TMINLP (const TMINLP &) | |
| Copy constructor. More... | |
| void | operator= (const TMINLP &) |
| Overloaded Equals Operator. More... | |
A C++ example for interfacing an MINLP with bonmin.
This class implements the following NLP :
This class implements the following NLP :
Definition at line 28 of file MyTMINLP.hpp.
|
inline |
Default constructor.
Definition at line 32 of file MyTMINLP.hpp.
|
inlinevirtual |
virtual destructor.
Definition at line 36 of file MyTMINLP.hpp.
|
inline |
Copy constructor.
Definition at line 40 of file MyTMINLP.hpp.
|
inline |
Default constructor.
Definition at line 32 of file MyTMINLP.hpp.
|
inlinevirtual |
virtual destructor.
Definition at line 36 of file MyTMINLP.hpp.
|
inline |
Copy constructor.
Definition at line 40 of file MyTMINLP.hpp.
|
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.
|
virtual |
Pass info about linear and nonlinear variables.
Definition at line 24 of file MyTMINLP.cpp.
|
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.
|
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.
|
virtual |
Method to pass the bounds on variables and constraints to Ipopt.
\param n size of x_l and x_u (has to be equal to the number of variables in the problem) \param x_l lower bounds on variables (function should fill it). \param x_u upper bounds on the variables (function should fill it). \param m size of g_l and g_u (has to be equal to the number of constraints in the problem). \param g_l lower bounds of the constraints (function should fill it). \param g_u upper bounds of the constraints (function should fill it).
Definition at line 56 of file MyTMINLP.cpp.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
virtual |
Method called by Ipopt at the end of optimization.
Definition at line 205 of file MyTMINLP.cpp.
|
inlinevirtual |
Implements Bonmin::TMINLP.
Definition at line 169 of file MyTMINLP.hpp.
|
inlinevirtual |
Implements Bonmin::TMINLP.
Definition at line 170 of file MyTMINLP.hpp.
|
inline |
Definition at line 173 of file MyTMINLP.hpp.
|
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). |
|
virtual |
Pass info about linear and nonlinear variables.
|
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). |
|
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). |
|
virtual |
Method to pass the bounds on variables and constraints to Ipopt.
\param n size of x_l and x_u (has to be equal to the number of variables in the problem) \param x_l lower bounds on variables (function should fill it). \param x_u upper bounds on the variables (function should fill it). \param m size of g_l and g_u (has to be equal to the number of constraints in the problem). \param g_l lower bounds of the constraints (function should fill it). \param g_u upper bounds of the constraints (function should fill it).
|
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). |
|
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). |
|
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). |
|
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). |
|
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). |
|
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). |
|
virtual |
Method called by Ipopt at the end of optimization.
|
inlinevirtual |
Implements Bonmin::TMINLP.
Definition at line 169 of file MyTMINLP.hpp.
|
inlinevirtual |
Implements Bonmin::TMINLP.
Definition at line 170 of file MyTMINLP.hpp.
|
inline |
Definition at line 173 of file MyTMINLP.hpp.
|
private |
Definition at line 177 of file MyTMINLP.hpp.
1.8.5