11 using namespace Ipopt;
15 TMINLPLinObj::TMINLPLinObj():
16 tminlp_(NULL), m_(0), n_(0),
35 Ipopt::TNLP::IndexStyleEnum index_style;
36 tminlp_->get_nlp_info(n, m , nnz_jac, nnz_h, index_style);
37 offset_ = index_style == Ipopt::TNLP::FORTRAN_STYLE;
46 Ipopt::TNLP::IndexStyleEnum& index_style){
50 tminlp_->get_nlp_info(n,m,nnz_jac_g, nnz_h_lag,index_style);
60 bool& use_x_scaling, Index
n,
62 bool& use_g_scaling, Index
m,
68 if(g_scaling && use_g_scaling)
70 if(x_scaling && use_x_scaling)
71 x_scaling[n - 1] = 1.;
74 double * mod_obj_scaling = &dummy;
75 if(use_g_scaling && g_scaling){
76 mod_obj_scaling = g_scaling;}
77 return tminlp_->get_scaling_parameters(*mod_obj_scaling, use_x_scaling, n - 1, x_scaling,
78 use_g_scaling, m - 1, g_scaling + 1);
87 Ipopt::TNLP::LinearityType* const_types){
90 const_types[0] = Ipopt::TNLP::NON_LINEAR;
91 return tminlp_->get_constraints_linearity(m-1, const_types +1);}
95 Index
m, Number* g_l, Number* g_u){
105 return tminlp_->get_bounds_info(n - 1, x_l, x_u,
m_ - 1,
111 bool init_z, Number* z_L, Number* z_U,
112 Index
m,
bool init_lambda,
117 bool return_value =
tminlp_->get_starting_point(n - 1, init_x, x, init_z, z_L, z_U,
118 m - 1, init_lambda, lambda + 1);
119 tminlp_->eval_f(n-1, x,
true, x[n-1]);
120 if(init_lambda && lambda != NULL)
133 bool ret_val =
tminlp_->eval_f(n - 1, x, new_x, g[0]);
135 return ret_val &&
tminlp_->eval_g(n - 1, x,
false, m - 1, g+1);
140 Index
m, Index nele_jac, Index* iRow,
141 Index *jCol, Number*
values){
149 for(
int i = 0 ; i <
n_ ; i++){
151 bool ret_val =
tminlp_->eval_jac_g(n -1, x, new_x,
m_ -1,
nnz_jac_ - n_, iRow + n_, jCol + n_, NULL);
152 for(
int i = n_ ; i <
nnz_jac_ ; i++){
157 ret_val &=
tminlp_->eval_grad_f(n-1, x, new_x, values);
159 ret_val &=
tminlp_->eval_jac_g(n - 1, x,
false, m - 1, nele_jac -
n_, NULL, NULL, values + n);
166 Number obj_factor, Index
m,
const Number* lambda,
167 bool new_lambda, Index nele_hess,
168 Index* iRow, Index* jCol, Number*
values){
172 return tminlp_->eval_h(
n_ - 1, x, new_x, (lambda != NULL)? lambda[0]: 1.,
m_ - 1, (lambda != NULL)? lambda + 1: NULL, new_lambda,
173 nele_hess, iRow, jCol, values);
179 Index i, Number& gi){
184 bool ret_val =
tminlp_->eval_f(n-1, x, new_x, gi);
188 return tminlp_->eval_gi(n-1, x, new_x, i - 1, gi);
193 Index i, Index& nele_grad_gi, Index* jCol,
200 for(
int i = 0 ; i <
n ; i++) jCol[i] = i +
offset_;
202 bool ret_val=
tminlp_->eval_grad_f(n-1, x, new_x, values);
206 return tminlp_->eval_grad_gi(n - 1, x, new_x, i - 1, nele_grad_gi,
int nnz_jac_
number of non-zeroes in the jacobian of the transformed MINLP.
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.
Ipopt::SmartPtr< TMINLP > tminlp()
return pointer to tminlp_.
int n_
Ipopt::Number of variables in the transformed MINLP.
virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
Return the constraints linearity.
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)
Return scaling parameters.
bool IsValid(const OSSmartPtr< U > &smart_ptr)
int m_
Ipopt::Number of constraints in the transformed MINLP.
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.
void gutsOfDestructor()
Reset all data.
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.
Ipopt::SmartPtr< TMINLP > tminlp_
Reference TMINLP which is to be relaxed.
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_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, Ipopt::TNLP::IndexStyleEnum &index_style)
Return the number of variables and constraints, and the number of non-zeros in the jacobian and the h...
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.
void setTminlp(Ipopt::SmartPtr< TMINLP > tminlp)
set reference TMINLP
int offset_
offset for jacobian.
void fint fint fint real fint real real real real real real * g
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.
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 ~TMINLPLinObj()
destructor.
void fint fint fint real fint real * x