13 #include "IpAlgTypes.hpp"
18 using namespace Ipopt;
24 tminlp2tnlp_(tminlp2tnlp)
28 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
29 "Can't get NLP infor in BranchingTQP");
49 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
50 "Can't evaluate objective function in BranchingTQP");
53 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
54 "Can't evaluate objective gradient in BranchingTQP");
55 bool new_lambda =
true;
59 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
60 "Can't evaluate objective Hessian structure in BranchingTQP");
69 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
70 "Can't evaluate objective Hessian values in BranchingTQP");
72 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
73 "Can't evaluate constraint values in BranchingTQP");
76 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
77 "Can't evaluate constraint Jacobian structure in BranchingTQP");
86 ASSERT_EXCEPTION(retval, TMINLP_INVALID,
87 "Can't evaluate constraint Jacobian values in BranchingTQP");
95 for (
int i=0; i<
n_; i++) {
98 for (
int i=0; i<
m_; i++) {
99 printf(
"g_vals_[%3d] = %15.8e\n", i,
g_vals_[i]);
126 IndexStyleEnum& index_style)
137 Index
m, Number* g_l, Number* g_u)
141 bool retval =
tminlp2tnlp_->get_bounds_info(n, x_l, x_u, m, g_l, g_u);
143 for (
int i=0; i<
n; i++) {
148 for (
int i=0; i<
m; i++) {
156 bool init_z, Number* z_L, Number* z_U,
157 Index
m,
bool init_lambda,
161 if (init_x ==
true) {
162 const double zero = 0.;
163 IpBlasDcopy(n, &zero, 0, x, 1);
165 if (init_z ==
true) {
171 if(init_lambda ==
true) {
174 for(
int i =
m_ ; i <
m; i++)
186 for (
int i=0; i<
m; i++) {
197 obj_value = IpBlasDdot(n, x, 1,
obj_grad_, 1);
235 const double zero = 0.;
236 IpBlasDcopy(
m_, &zero, 0, g, 1);
247 Index
m, Index nele_jac, Index* iRow,
248 Index *jCol, Number*
values)
251 DBG_ASSERT(jCol != NULL);
252 DBG_ASSERT(values == NULL);
274 Number obj_factor, Index
m,
const Number* lambda,
275 bool new_lambda, Index nele_hess,
276 Index* iRow, Index* jCol, Number*
values)
281 DBG_ASSERT(jCol != NULL);
282 DBG_ASSERT(values == NULL);
284 for (Index i=0; i<nele_hess; i++) {
290 for (Index i=0; i<nele_hess; i++) {
297 if (obj_factor==0.) {
298 const Number zero = 0.;
299 IpBlasDcopy(nele_hess, &zero, 0, values, 1);
302 IpBlasDcopy(nele_hess,
obj_hess_, 1, values, 1);
303 if (obj_factor != 1.) {
304 IpBlasDscal(nele_hess, obj_factor, values, 1);
313 Index
n,
const Number*
x,
314 const Number* z_L,
const Number* z_U,
315 Index
m,
const Number*
g,
316 const Number* lambda, Number obj_value,
317 const IpoptData* ip_data,
318 IpoptCalculatedQuantities* ip_cq)
322 double* xx =
new double[
n];
323 for (
int i=0; i<
n; i++) {
328 if(status == Ipopt::LOCAL_INFEASIBILITY)
330 tminlp2tnlp_->finalize_solution(status, n, xx, z_L, z_U, m, g, lambda,
331 obj, ip_data, ip_cq);
Ipopt::Number * x_sol_copy_
Copy of original x_sol_.
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)
Returns the constraint linearity.
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Returns the vector of the gradient of the objective w.r.t.
virtual ~BranchingTQP()
Default destructor.
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)
Method called by Ipopt to get the starting point.
Ipopt::Index * obj_hess_irow_
Ipopt::Index * g_jac_irow_
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)
Returns the constraint linearity.
Ipopt::Number * obj_grad_
Ipopt::SmartPtr< TMINLP2TNLP > tminlp2tnlp_
Pointer to the TMINLP2TNLP model which stores the bounds information.
Ipopt::Number * obj_hess_
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Returns the value of the objective function in x.
virtual bool get_constraints_linearity(Ipopt::Index m, LinearityType *const_types)
Returns the constraint linearity.
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)
Returns the jacobian of the 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)
Returns the constraint linearity.
void fint fint fint real fint real real real real real real * g
Ipopt::Index * g_jac_jcol_
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::Number * duals_sol_copy_
Copy of original duals_sol_.
Ipopt::Index * obj_hess_jcol_
Ipopt::TNLP::IndexStyleEnum index_style_
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Returns the vector of constraint values in x.
void fint fint fint real fint real * x